本文整理汇总了Python中car.Car.steering_for_angle方法的典型用法代码示例。如果您正苦于以下问题:Python Car.steering_for_angle方法的具体用法?Python Car.steering_for_angle怎么用?Python Car.steering_for_angle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类car.Car
的用法示例。
在下文中一共展示了Car.steering_for_angle方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: playback
# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import steering_for_angle [as 别名]
def playback():
record_start_time = None
playback_start_time = datetime.datetime.now()
car = Car()
car.set_rc_mode()
start_heading = car.dynamics.heading
recording = Recording()
while recording.read():
dyn = recording.current()
if record_start_time == None:
record_start_time = dyn.datetime
record_start_heading = dyn.heading
t_now = datetime.datetime.now()
t_wait = (dyn.datetime - record_start_time) - (t_now - playback_start_time)
if t_wait.total_seconds() > 0:
time.sleep(t_wait.total_seconds())
# adjust steering based on heading error
actual_turn = degrees_diff(start_heading, car.dynamics.heading)
expected_turn = degrees_diff(record_start_heading, dyn.heading)
original_steer_angle = car.angle_for_steering(dyn.str)
steer_angle = original_steer_angle + degrees_diff(actual_turn, expected_turn)
str = car.steering_for_angle(steer_angle)
car.set_esc_and_str(dyn.esc, str)
car.set_manual_mode()
print 'all done'
示例2: Car
# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import steering_for_angle [as 别名]
import time
from car import Car
car = Car()
try:
car.set_rc_mode()
steer_angle = 0.0
max_angle = 30.0
min_angle = -max_angle
step_seconds = 0.02
step = max_degrees_per_second * step_seconds
while True:
steer_angle += step
if steer_angle >= max_angle:
step = -abs(step)
if steer_angle <= min_angle:
step = abs(step)
steer_ms = car.steering_for_angle(steer_angle)
car.set_esc_and_str(1500, steer_ms)
time.sleep(0.02)
finally:
car.set_manual_mode()
示例3: play_route
# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import steering_for_angle [as 别名]
def play_route(route, car = None, print_progress = False, k_smooth = 0.4, d_ahead = 0.05, t_ahead = 0.2):
last_ms = None
#print route
if car is None:
car = Car()
queue = Queue.Queue()
try:
car.set_rc_mode()
car.add_listener(queue)
message = queue.get(block=True, timeout = 0.5)
#print repr(message)
last_ms = message.ms
start_time = time.time()
# keep going until we run out of track
car.lcd.display_text('press any key\nto abort')
while car.lcd.getch() is None:
try:
message = queue.get(block=True, timeout = 0.5)
except:
print 'message timed out at: '+datetime.datetime.now().strftime("%H:%M:%S.%f")
print 'last message received:' + repr(message)
print
raise
(x,y) = car.front_position()
(rear_x,rear_y) = car.rear_position()
car_velocity = car.get_velocity_meters_per_second()
route.set_position(x,y,rear_x,rear_y,car_velocity)
steering_angle = steering_angle_by_look_ahead_curve(car,route,d_ahead,t_ahead)
#steering_angle = steering_angle_by_look_ahead(car,route,d_ahead,t_ahead)
str_ms = car.steering_for_angle(steering_angle)
esc_ms = esc_for_velocity(route.velocity(), car, route.is_reverse())
if print_progress:
print("t: {:.1f} i: {} xg: {:.2f} gy:{:.2f} gv: {:.2f} v:{:.2f} x: {:.2f} y:{:.2f} reverse: {} cte:{:.2f} heading:{:.2f} segment_heading: {:.2f} steering_degrees: {:.2f} esc:{}".format(
time.time() - start_time,
route.index,
route.nodes[route.index+1].x,
route.nodes[route.index+1].y,
route.velocity(),
car_velocity,
x,
y,
route.is_reverse(),
cte,
car_heading,
segment_heading,
steering_angle,
esc_ms))
# send to car
car.set_esc_and_str(esc_ms, str_ms)
if route.done() and car_velocity == 0:
break;
finally:
car.set_esc_and_str(1500,1500)
car.set_manual_mode()
car.remove_listener(queue)
示例4: Car
# 需要导入模块: from car import Car [as 别名]
# 或者: from car.Car import steering_for_angle [as 别名]
import time
from car import Car
from geometry import *
#goal is to find a way to point the wheels straight ahead
car = Car()
time.sleep(1)
original_heading = car.dynamics.heading
car.set_rc_mode()
speed = 1500
while(True):
heading = angle_diff(original_heading, car.dynamics.heading)
steering = car.steering_for_angle(-heading)
car.set_esc_and_str(speed, steering)
#print "Heading: {} Steering: {}".format(heading, steering)
time.sleep(0.01)
car.set_manual_mode()