Merge remote-tracking branch 'origin/manishthani/no_rendering_opendrive' into marcgpuig/opendrive
This commit is contained in:
commit
0149a86037
|
@ -443,7 +443,8 @@ class MapImage(object):
|
||||||
|
|
||||||
def draw_lane_marking(surface, points, solid=True):
|
def draw_lane_marking(surface, points, solid=True):
|
||||||
if solid:
|
if solid:
|
||||||
pygame.draw.lines(surface, COLOR_ORANGE_0, False, points, 2)
|
if len(points) > 1:
|
||||||
|
pygame.draw.lines(surface, COLOR_ORANGE_0, False, points, 2)
|
||||||
else:
|
else:
|
||||||
broken_lines = [x for n, x in enumerate(zip(*(iter(points),) * 20)) if n % 3 == 0]
|
broken_lines = [x for n, x in enumerate(zip(*(iter(points),) * 20)) if n % 3 == 0]
|
||||||
for line in broken_lines:
|
for line in broken_lines:
|
||||||
|
@ -493,43 +494,55 @@ class MapImage(object):
|
||||||
|
|
||||||
def does_cross_solid_line(waypoint, shift):
|
def does_cross_solid_line(waypoint, shift):
|
||||||
w = carla_map.get_waypoint(lateral_shift(waypoint.transform, shift), project_to_road=False)
|
w = carla_map.get_waypoint(lateral_shift(waypoint.transform, shift), project_to_road=False)
|
||||||
if w is None or w.road_id != waypoint.road_id:
|
if w is None or w.lane_change == carla.LaneChange.None or w.road_id != waypoint.road_id:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return (w.lane_id * waypoint.lane_id < 0) or w.lane_id == waypoint.lane_id
|
return (w.lane_id * waypoint.lane_id < 0) or w.lane_id == waypoint.lane_id
|
||||||
|
|
||||||
topology = [x[0] for x in carla_map.get_topology()]
|
def draw_topology (carla_topology, index):
|
||||||
topology = sorted(topology, key=lambda w: w.transform.location.z)
|
topology = [x[index] for x in carla_topology]
|
||||||
|
topology = sorted(topology, key=lambda w: w.transform.location.z)
|
||||||
|
for waypoint in topology:
|
||||||
|
waypoints = [waypoint]
|
||||||
|
|
||||||
for waypoint in topology:
|
nxt = waypoint.next(precision)
|
||||||
waypoints = [waypoint]
|
if len(nxt) > 0:
|
||||||
nxt = waypoint.next(precision)[0]
|
nxt = nxt[0]
|
||||||
while nxt.road_id == waypoint.road_id:
|
while nxt.road_id == waypoint.road_id:
|
||||||
waypoints.append(nxt)
|
waypoints.append(nxt)
|
||||||
nxt = nxt.next(precision)[0]
|
nxt = nxt.next(precision)
|
||||||
|
if len(nxt) > 0:
|
||||||
|
nxt = nxt[0]
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
left_marking = [lateral_shift(w.transform, -w.lane_width * 0.5) for w in waypoints]
|
left_marking = [lateral_shift(w.transform, -w.lane_width * 0.5) for w in waypoints]
|
||||||
right_marking = [lateral_shift(w.transform, w.lane_width * 0.5) for w in waypoints]
|
right_marking = [lateral_shift(w.transform, w.lane_width * 0.5) for w in waypoints]
|
||||||
|
|
||||||
polygon = left_marking + [x for x in reversed(right_marking)]
|
polygon = left_marking + [x for x in reversed(right_marking)]
|
||||||
polygon = [world_to_pixel(x) for x in polygon]
|
polygon = [world_to_pixel(x) for x in polygon]
|
||||||
|
|
||||||
pygame.draw.polygon(map_surface, COLOR_ALUMINIUM_5, polygon, 10)
|
if len(polygon) > 2:
|
||||||
pygame.draw.polygon(map_surface, COLOR_ALUMINIUM_5, polygon)
|
pygame.draw.polygon(map_surface, COLOR_ALUMINIUM_5, polygon, 10)
|
||||||
|
pygame.draw.polygon(map_surface, COLOR_ALUMINIUM_5, polygon)
|
||||||
|
|
||||||
if not waypoint.is_intersection:
|
if not waypoint.is_intersection:
|
||||||
sample = waypoints[int(len(waypoints) / 2)]
|
sample = waypoints[int(len(waypoints) / 2)]
|
||||||
draw_lane_marking(
|
draw_lane_marking(
|
||||||
map_surface,
|
map_surface,
|
||||||
[world_to_pixel(x) for x in left_marking],
|
[world_to_pixel(x) for x in left_marking],
|
||||||
does_cross_solid_line(sample, -sample.lane_width * 1.1))
|
does_cross_solid_line(sample, -sample.lane_width * 1.2))
|
||||||
draw_lane_marking(
|
draw_lane_marking(
|
||||||
map_surface,
|
map_surface,
|
||||||
[world_to_pixel(x) for x in right_marking],
|
[world_to_pixel(x) for x in right_marking],
|
||||||
does_cross_solid_line(sample, sample.lane_width * 1.1))
|
does_cross_solid_line(sample, sample.lane_width * 1.2))
|
||||||
for n, wp in enumerate(waypoints):
|
for n, wp in enumerate(waypoints):
|
||||||
if (n % 400) == 0:
|
if (n % 400) == 0:
|
||||||
draw_arrow(map_surface, wp.transform)
|
draw_arrow(map_surface, wp.transform)
|
||||||
|
|
||||||
|
topology = carla_map.get_topology()
|
||||||
|
draw_topology(topology, 0)
|
||||||
|
draw_topology(topology, 1)
|
||||||
|
|
||||||
actors = carla_world.get_actors()
|
actors = carla_world.get_actors()
|
||||||
stops_transform = [actor.get_transform() for actor in actors if 'stop' in actor.type_id]
|
stops_transform = [actor.get_transform() for actor in actors if 'stop' in actor.type_id]
|
||||||
|
|
Loading…
Reference in New Issue