25 lines
1.1 KiB
Python
Executable File
25 lines
1.1 KiB
Python
Executable File
|
|
# This recipe is a modification of lane_explorer.py example.
|
|
# It draws the path of an actor through the world, printing information at each waypoint.
|
|
|
|
# ...
|
|
current_w = map.get_waypoint(vehicle.get_location())
|
|
while True:
|
|
|
|
next_w = map.get_waypoint(vehicle.get_location(), lane_type=carla.LaneType.Driving | carla.LaneType.Shoulder | carla.LaneType.Sidewalk )
|
|
# Check if the vehicle is moving
|
|
if next_w.id != current_w.id:
|
|
vector = vehicle.get_velocity()
|
|
# Check if the vehicle is on a sidewalk
|
|
if current_w.lane_type == carla.LaneType.Sidewalk:
|
|
draw_waypoint_union(debug, current_w, next_w, cyan if current_w.is_junction else red, 60)
|
|
else:
|
|
draw_waypoint_union(debug, current_w, next_w, cyan if current_w.is_junction else green, 60)
|
|
debug.draw_string(current_w.transform.location, str('%15.0f km/h' % (3.6 * math.sqrt(vector.x**2 + vector.y**2 + vector.z**2))), False, orange, 60)
|
|
draw_transform(debug, current_w.transform, white, 60)
|
|
|
|
# Update the current waypoint and sleep for some time
|
|
current_w = next_w
|
|
time.sleep(args.tick_time)
|
|
# ...
|