srunner/tools/scenario_helper.py
def generate_target_waypoint_in_route(waypoint, route):
    """
    This method follow waypoints to a junction
    @returns a waypoint list according to turn input
    """
    wmap = CarlaDataProvider.get_map()
    reached_junction = False

    # Get the route location
    shortest_distance = float('inf')
    for index, route_pos in enumerate(route):
        wp = route_pos[0]
        trigger_location = waypoint.transform.location

        dist_to_route = trigger_location.distance(wp)
        if dist_to_route <= shortest_distance:
            closest_index = index
            shortest_distance = dist_to_route

    route_location = route[closest_index][0]
    index = closest_index

    while True:
        # Get the next route location
        index = min(index + 1, len(route))
        route_location = route[index][0]
        road_option = route[index][1]

        # Enter the junction
        if not reached_junction and (road_option in (RoadOption.LEFT, RoadOption.RIGHT, RoadOption.STRAIGHT)):
            reached_junction = True

        # End condition for the behavior, at the end of the junction
        if reached_junction and (road_option not in (RoadOption.LEFT, RoadOption.RIGHT, RoadOption.STRAIGHT)):
            break

    return wmap.get_waypoint(route_location)

    This method follow waypoints to a junction
    @returns a waypoint list according to turn input
    
This method follow waypoints to a junction
@returns a waypoint list according to turn input
This method follow waypoints to a junction @returns a waypoint list according to turn input
def generate_target_waypoint_in_route(waypoint, route):
    wmap = CarlaDataProvider.get_map()
    reached_junction = False
    shortest_distance = float('inf')
    for index, route_pos in enumerate(route):
        wp = route_pos[0]
        trigger_location = waypoint.transform.location
        dist_to_route = trigger_location.distance(wp)
        if dist_to_route <= shortest_distance:
            closest_index = index
            shortest_distance = dist_to_route
    route_location = route[closest_index][0]
    index = closest_index
    while True:
        index = min(index + 1, len(route))
        route_location = route[index][0]
        road_option = route[index][1]
        if not reached_junction and (road_option in (RoadOption.LEFT, RoadOption.RIGHT, RoadOption.STRAIGHT)):
            reached_junction = True
        if reached_junction and (road_option not in (RoadOption.LEFT, RoadOption.RIGHT, RoadOption.STRAIGHT)):
            break
    return wmap.get_waypoint(route_location)
def generate_target_waypoint_in_route ( waypoint , route ) : wmap = CarlaDataProvider . get_map ( ) reached_junction = False shortest_distance = float ( 'inf' ) for index , route_pos in enumerate ( route ) : wp = route_pos [ 0 ] trigger_location = waypoint . transform . location dist_to_route = trigger_location . distance ( wp ) if dist_to_route <= shortest_distance : closest_index = index shortest_distance = dist_to_route route_location = route [ closest_index ] [ 0 ] index = closest_index while True : index = min ( index + 1 , len ( route ) ) route_location = route [ index ] [ 0 ] road_option = route [ index ] [ 1 ] if not reached_junction and ( road_option in ( RoadOption . LEFT , RoadOption . RIGHT , RoadOption . STRAIGHT ) ) : reached_junction = True if reached_junction and ( road_option not in ( RoadOption . LEFT , RoadOption . RIGHT , RoadOption . STRAIGHT ) ) : break return wmap . get_waypoint ( route_location )
This method follow waypoints to a junction
@returns a waypoint list according to turn input
This method follow waypoints to a junction @returns a waypoint list according to turn input
"""
    This method follow waypoints to a junction
    @returns a waypoint list according to turn input
    """ # Get the route location # Get the next route location # Enter the junction # End condition for the behavior, at the end of the junction
waypoint
route