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

Method _render_vehicles

PythonAPI/examples/no_rendering_mode.py:1214–1233  ·  view source on GitHub ↗

Renders the vehicles' bounding boxes

(self, surface, list_v, world_to_pixel)

Source from the content-addressed store, hash-verified

1212 pygame.draw.polygon(surface, color, corners)
1213
1214 def _render_vehicles(self, surface, list_v, world_to_pixel):
1215 """Renders the vehicles' bounding boxes"""
1216 for v in list_v:
1217 color = COLOR_SKY_BLUE_0
1218 if int(v[0].attributes['number_of_wheels']) == 2:
1219 color = COLOR_CHOCOLATE_1
1220 if v[0].attributes['role_name'] == 'hero':
1221 color = COLOR_CHAMELEON_0
1222 # Compute bounding box points
1223 bb = v[0].bounding_box.extent
1224 corners = [carla.Location(x=-bb.x, y=-bb.y),
1225 carla.Location(x=bb.x - 0.8, y=-bb.y),
1226 carla.Location(x=bb.x, y=0),
1227 carla.Location(x=bb.x - 0.8, y=bb.y),
1228 carla.Location(x=-bb.x, y=bb.y),
1229 carla.Location(x=-bb.x, y=-bb.y)
1230 ]
1231 v[1].transform(corners)
1232 corners = [world_to_pixel(p) for p in corners]
1233 pygame.draw.lines(surface, color, False, corners, int(math.ceil(4.0 * self.map_image.scale)))
1234
1235 def render_actors(self, surface, vehicles, traffic_lights, speed_limits, walkers):
1236 """Renders all the actors"""

Callers 1

render_actorsMethod · 0.95

Calls 1

LocationMethod · 0.45

Tested by

no test coverage detected