MCPcopy Create free account
hub / github.com/OpenDriveLab/TCP / draw_traffic_signs

Method draw_traffic_signs

scenario_runner/no_rendering_mode.py:586–611  ·  view source on GitHub ↗
(surface, font_surface, actor, color=COLOR_ALUMINIUM_2, trigger_color=COLOR_PLUM_0)

Source from the content-addressed store, hash-verified

584 left, start, right]], 4)
585
586 def draw_traffic_signs(surface, font_surface, actor, color=COLOR_ALUMINIUM_2, trigger_color=COLOR_PLUM_0):
587 transform = actor.get_transform()
588 waypoint = carla_map.get_waypoint(transform.location)
589
590 angle = -waypoint.transform.rotation.yaw - 90.0
591 font_surface = pygame.transform.rotate(font_surface, angle)
592 pixel_pos = world_to_pixel(waypoint.transform.location)
593 offset = font_surface.get_rect(center=(pixel_pos[0], pixel_pos[1]))
594 surface.blit(font_surface, offset)
595
596 # Draw line in front of stop
597 forward_vector = carla.Location(waypoint.transform.get_forward_vector())
598 left_vector = carla.Location(-forward_vector.y, forward_vector.x,
599 forward_vector.z) * waypoint.lane_width / 2 * 0.7
600
601 line = [(waypoint.transform.location + (forward_vector * 1.5) + (left_vector)),
602 (waypoint.transform.location + (forward_vector * 1.5) - (left_vector))]
603
604 line_pixel = [world_to_pixel(p) for p in line]
605 pygame.draw.lines(surface, color, True, line_pixel, 2)
606
607 # draw bounding box
608 if self.show_triggers:
609 corners = Util.get_bounding_box(actor)
610 corners = [world_to_pixel(p) for p in corners]
611 pygame.draw.lines(surface, trigger_color, True, corners, 2)
612
613 def lateral_shift(transform, shift):
614 transform.rotation.yaw += 90

Callers

nothing calls this directly

Calls 2

get_transformMethod · 0.80
get_bounding_boxMethod · 0.80

Tested by

no test coverage detected