Fix global route planner python agent

Ensure waypoint.right_lane_marking/left_lane_marking exist before
accessing
This commit is contained in:
Bernd Gassmann 2021-09-24 10:13:06 +02:00 committed by bernat
parent 893fe216f0
commit d112c3bfed
1 changed files with 2 additions and 2 deletions

View File

@ -227,7 +227,7 @@ class GlobalRoutePlanner(object):
if not segment['entry'].is_junction:
next_waypoint, next_road_option, next_segment = None, None, None
if waypoint.right_lane_marking.lane_change & carla.LaneChange.Right and not right_found:
if waypoint.right_lane_marking and waypoint.right_lane_marking.lane_change & carla.LaneChange.Right and not right_found:
next_waypoint = waypoint.get_right_lane()
if next_waypoint is not None \
and next_waypoint.lane_type == carla.LaneType.Driving \
@ -240,7 +240,7 @@ class GlobalRoutePlanner(object):
exit_waypoint=next_waypoint, intersection=False, exit_vector=None,
path=[], length=0, type=next_road_option, change_waypoint=next_waypoint)
right_found = True
if waypoint.left_lane_marking.lane_change & carla.LaneChange.Left and not left_found:
if waypoint.left_lane_marking and waypoint.left_lane_marking.lane_change & carla.LaneChange.Left and not left_found:
next_waypoint = waypoint.get_left_lane()
if next_waypoint is not None \
and next_waypoint.lane_type == carla.LaneType.Driving \