MCPcopy Create free account
hub / github.com/AdaCompNUS/summit / draw_traffic_signs

Method draw_traffic_signs

PythonAPI/examples/no_rendering_mode.py:663–689  ·  view source on GitHub ↗

Draw stop traffic signs and its bounding box if enabled

(surface, font_surface, actor, color=COLOR_ALUMINIUM_2, trigger_color=COLOR_PLUM_0)

Source from the content-addressed store, hash-verified

661 pygame.draw.lines(surface, color, False, [world_to_pixel(x) for x in [left, start, right]], 4)
662
663 def draw_traffic_signs(surface, font_surface, actor, color=COLOR_ALUMINIUM_2, trigger_color=COLOR_PLUM_0):
664 """Draw stop traffic signs and its bounding box if enabled"""
665 transform = actor.get_transform()
666 waypoint = carla_map.get_waypoint(transform.location)
667
668 angle = -waypoint.transform.rotation.yaw - 90.0
669 font_surface = pygame.transform.rotate(font_surface, angle)
670 pixel_pos = world_to_pixel(waypoint.transform.location)
671 offset = font_surface.get_rect(center=(pixel_pos[0], pixel_pos[1]))
672 surface.blit(font_surface, offset)
673
674 # Draw line in front of stop
675 forward_vector = carla.Location(waypoint.transform.get_forward_vector())
676 left_vector = carla.Location(-forward_vector.y, forward_vector.x,
677 forward_vector.z) * waypoint.lane_width / 2 * 0.7
678
679 line = [(waypoint.transform.location + (forward_vector * 1.5) + (left_vector)),
680 (waypoint.transform.location + (forward_vector * 1.5) - (left_vector))]
681
682 line_pixel = [world_to_pixel(p) for p in line]
683 pygame.draw.lines(surface, color, True, line_pixel, 2)
684
685 # Draw bounding box of the stop trigger
686 if self.show_triggers:
687 corners = Util.get_bounding_box(actor)
688 corners = [world_to_pixel(p) for p in corners]
689 pygame.draw.lines(surface, trigger_color, True, corners, 2)
690
691 # def draw_crosswalk(surface, transform=None, color=COLOR_ALUMINIUM_2):
692 # """Given two points A and B, draw white parallel lines from A to B"""

Callers

nothing calls this directly

Calls 4

get_waypointMethod · 0.80
rotateMethod · 0.80
LocationMethod · 0.45
get_bounding_boxMethod · 0.45

Tested by

no test coverage detected