srunner/tools/scenario_helper.py
def generate_target_waypoint_list_multilane(waypoint, change='left',  # pylint: disable=too-many-return-statements
                                            distance_same_lane=10, distance_other_lane=25,
                                            total_lane_change_distance=25, check=True,
                                            lane_changes=1, step_distance=2):
    """
    This methods generates a waypoint list which leads the vehicle to a parallel lane.
    The change input must be 'left' or 'right', depending on which lane you want to change.

    The default step distance between waypoints on the same lane is 2m.
    The default step distance between the lane change is set to 25m.

    @returns a waypoint list from the starting point to the end point on a right or left parallel lane.
    The function might break before reaching the end point, if the asked behavior is impossible.
    """

    plan = []
    plan.append((waypoint, RoadOption.LANEFOLLOW))  # start position

    option = RoadOption.LANEFOLLOW

    # Same lane
    distance = 0
    while distance < distance_same_lane:
        next_wps = plan[-1][0].next(step_distance)
        if not next_wps:
            return None, None
        next_wp = next_wps[0]
        distance += next_wp.transform.location.distance(plan[-1][0].transform.location)
        plan.append((next_wp, RoadOption.LANEFOLLOW))

    if change == 'left':
        option = RoadOption.CHANGELANELEFT
    elif change == 'right':
        option = RoadOption.CHANGELANERIGHT
    else:
        # ERROR, input value for change must be 'left' or 'right'
        return None, None

    lane_changes_done = 0
    lane_change_distance = total_lane_change_distance / lane_changes

    # Lane change
    while lane_changes_done < lane_changes:

        # Move forward
        next_wps = plan[-1][0].next(lane_change_distance)
        if not next_wps:
            return None, None
        next_wp = next_wps[0]

        # Get the side lane
        if change == 'left':
            if check and str(next_wp.lane_change) not in ['Left', 'Both']:
                return None, None
            side_wp = next_wp.get_left_lane()
        else:
            if check and str(next_wp.lane_change) not in ['Right', 'Both']:
                return None, None
            side_wp = next_wp.get_right_lane()

        if not side_wp or side_wp.lane_type != carla.LaneType.Driving:
            return None, None

        # Update the plan
        plan.append((side_wp, option))
        lane_changes_done += 1

    # Other lane
    distance = 0
    while distance < distance_other_lane:
        next_wps = plan[-1][0].next(step_distance)
        if not next_wps:
            return None, None
        next_wp = next_wps[0]
        distance += next_wp.transform.location.distance(plan[-1][0].transform.location)
        plan.append((next_wp, RoadOption.LANEFOLLOW))

    target_lane_id = plan[-1][0].lane_id

    return plan, target_lane_id

    This methods generates a waypoint list which leads the vehicle to a parallel lane.
    The change input must be 'left' or 'right', depending on which lane you want to change.

    The default step distance between waypoints on the same lane is 2m.
    The default step distance between the lane change is set to 25m.

    @returns a waypoint list from the starting point to the end point on a right or left parallel lane.
    The function might break before reaching the end point, if the asked behavior is impossible.
    
This methods generates a waypoint list which leads the vehicle to a parallel lane.
The change input must be 'left' or 'right', depending on which lane you want to change.

The default step distance between waypoints on the same lane is 2m.
The default step distance between the lane change is set to 25m.

@returns a waypoint list from the starting point to the end point on a right or left parallel lane.
The function might break before reaching the end point, if the asked behavior is impossible.
This methods generates a waypoint list which leads the vehicle to a parallel lane . The change input must be ' left ' or ' right ' depending on which lane you want to change . The default step distance between waypoints on the same lane is 2m . The default step distance between the lane change is set to 25m . @returns a waypoint list from the starting point to the end point on a right or left parallel lane . The function might break before reaching the end point if the asked behavior is impossible .
def generate_target_waypoint_list_multilane(waypoint, change='left',  
                                            distance_same_lane=10, distance_other_lane=25,
                                            total_lane_change_distance=25, check=True,
                                            lane_changes=1, step_distance=2):
    plan = []
    plan.append((waypoint, RoadOption.LANEFOLLOW))  
    option = RoadOption.LANEFOLLOW
    distance = 0
    while distance < distance_same_lane:
        next_wps = plan[-1][0].next(step_distance)
        if not next_wps:
            return None, None
        next_wp = next_wps[0]
        distance += next_wp.transform.location.distance(plan[-1][0].transform.location)
        plan.append((next_wp, RoadOption.LANEFOLLOW))
    if change == 'left':
        option = RoadOption.CHANGELANELEFT
    elif change == 'right':
        option = RoadOption.CHANGELANERIGHT
    else:
        return None, None
    lane_changes_done = 0
    lane_change_distance = total_lane_change_distance / lane_changes
    while lane_changes_done < lane_changes:
        next_wps = plan[-1][0].next(lane_change_distance)
        if not next_wps:
            return None, None
        next_wp = next_wps[0]
        if change == 'left':
            if check and str(next_wp.lane_change) not in ['Left', 'Both']:
                return None, None
            side_wp = next_wp.get_left_lane()
        else:
            if check and str(next_wp.lane_change) not in ['Right', 'Both']:
                return None, None
            side_wp = next_wp.get_right_lane()
        if not side_wp or side_wp.lane_type != carla.LaneType.Driving:
            return None, None
        plan.append((side_wp, option))
        lane_changes_done += 1
    distance = 0
    while distance < distance_other_lane:
        next_wps = plan[-1][0].next(step_distance)
        if not next_wps:
            return None, None
        next_wp = next_wps[0]
        distance += next_wp.transform.location.distance(plan[-1][0].transform.location)
        plan.append((next_wp, RoadOption.LANEFOLLOW))
    target_lane_id = plan[-1][0].lane_id
    return plan, target_lane_id
def generate_target_waypoint_list_multilane ( waypoint , change = 'left' , distance_same_lane = 10 , distance_other_lane = 25 , total_lane_change_distance = 25 , check = True , lane_changes = 1 , step_distance = 2 ) : plan = [ ] plan . append ( ( waypoint , RoadOption . LANEFOLLOW ) ) option = RoadOption . LANEFOLLOW distance = 0 while distance < distance_same_lane : next_wps = plan [ - 1 ] [ 0 ] . next ( step_distance ) if not next_wps : return None , None next_wp = next_wps [ 0 ] distance += next_wp . transform . location . distance ( plan [ - 1 ] [ 0 ] . transform . location ) plan . append ( ( next_wp , RoadOption . LANEFOLLOW ) ) if change == 'left' : option = RoadOption . CHANGELANELEFT elif change == 'right' : option = RoadOption . CHANGELANERIGHT else : return None , None lane_changes_done = 0 lane_change_distance = total_lane_change_distance / lane_changes while lane_changes_done < lane_changes : next_wps = plan [ - 1 ] [ 0 ] . next ( lane_change_distance ) if not next_wps : return None , None next_wp = next_wps [ 0 ] if change == 'left' : if check and str ( next_wp . lane_change ) not in [ 'Left' , 'Both' ] : return None , None side_wp = next_wp . get_left_lane ( ) else : if check and str ( next_wp . lane_change ) not in [ 'Right' , 'Both' ] : return None , None side_wp = next_wp . get_right_lane ( ) if not side_wp or side_wp . lane_type != carla . LaneType . Driving : return None , None plan . append ( ( side_wp , option ) ) lane_changes_done += 1 distance = 0 while distance < distance_other_lane : next_wps = plan [ - 1 ] [ 0 ] . next ( step_distance ) if not next_wps : return None , None next_wp = next_wps [ 0 ] distance += next_wp . transform . location . distance ( plan [ - 1 ] [ 0 ] . transform . location ) plan . append ( ( next_wp , RoadOption . LANEFOLLOW ) ) target_lane_id = plan [ - 1 ] [ 0 ] . lane_id return plan , target_lane_id
This methods generates a waypoint list which leads the vehicle to a parallel lane.
This methods generates a waypoint list which leads the vehicle to a parallel lane .
# pylint: disable=too-many-return-statements """
    This methods generates a waypoint list which leads the vehicle to a parallel lane.
    The change input must be 'left' or 'right', depending on which lane you want to change.

    The default step distance between waypoints on the same lane is 2m.
    The default step distance between the lane change is set to 25m.

    @returns a waypoint list from the starting point to the end point on a right or left parallel lane.
    The function might break before reaching the end point, if the asked behavior is impossible.
    """ # start position # Same lane # ERROR, input value for change must be 'left' or 'right' # Lane change # Move forward # Get the side lane # Update the plan # Other lane
waypoint
change
distance_same_lane
distance_other_lane
total_lane_change_distance
check
lane_changes
step_distance