srunner/tools/scenario_helper.py
def choose_at_junction(current_waypoint, next_choices, direction=0):
    """
    This function chooses the appropriate waypoint from next_choices based on direction
    """
    current_transform = current_waypoint.transform
    current_location = current_transform.location
    projected_location = current_location + \
        carla.Location(
            x=math.cos(math.radians(current_transform.rotation.yaw)),
            y=math.sin(math.radians(current_transform.rotation.yaw)))
    current_vector = vector(current_location, projected_location)
    cross_list = []
    cross_to_waypoint = {}
    for waypoint in next_choices:
        waypoint = waypoint.next(10)[0]
        select_vector = vector(current_location, waypoint.transform.location)
        cross = np.cross(current_vector, select_vector)[2]
        cross_list.append(cross)
        cross_to_waypoint[cross] = waypoint
    select_cross = None
    if direction > 0:
        select_cross = max(cross_list)
    elif direction < 0:
        select_cross = min(cross_list)
    else:
        select_cross = min(cross_list, key=abs)

    return cross_to_waypoint[select_cross]

    This function chooses the appropriate waypoint from next_choices based on direction
    
This function chooses the appropriate waypoint from next_choices based on direction
This function chooses the appropriate waypoint from next_choices based on direction
def choose_at_junction(current_waypoint, next_choices, direction=0):
    current_transform = current_waypoint.transform
    current_location = current_transform.location
    projected_location = current_location + \
        carla.Location(
            x=math.cos(math.radians(current_transform.rotation.yaw)),
            y=math.sin(math.radians(current_transform.rotation.yaw)))
    current_vector = vector(current_location, projected_location)
    cross_list = []
    cross_to_waypoint = {}
    for waypoint in next_choices:
        waypoint = waypoint.next(10)[0]
        select_vector = vector(current_location, waypoint.transform.location)
        cross = np.cross(current_vector, select_vector)[2]
        cross_list.append(cross)
        cross_to_waypoint[cross] = waypoint
    select_cross = None
    if direction > 0:
        select_cross = max(cross_list)
    elif direction < 0:
        select_cross = min(cross_list)
    else:
        select_cross = min(cross_list, key=abs)
    return cross_to_waypoint[select_cross]
def choose_at_junction ( current_waypoint , next_choices , direction = 0 ) : current_transform = current_waypoint . transform current_location = current_transform . location projected_location = current_location + carla . Location ( x = math . cos ( math . radians ( current_transform . rotation . yaw ) ) , y = math . sin ( math . radians ( current_transform . rotation . yaw ) ) ) current_vector = vector ( current_location , projected_location ) cross_list = [ ] cross_to_waypoint = { } for waypoint in next_choices : waypoint = waypoint . next ( 10 ) [ 0 ] select_vector = vector ( current_location , waypoint . transform . location ) cross = np . cross ( current_vector , select_vector ) [ 2 ] cross_list . append ( cross ) cross_to_waypoint [ cross ] = waypoint select_cross = None if direction > 0 : select_cross = max ( cross_list ) elif direction < 0 : select_cross = min ( cross_list ) else : select_cross = min ( cross_list , key = abs ) return cross_to_waypoint [ select_cross ]
This function chooses the appropriate waypoint from next_choices based on direction
This function chooses the appropriate waypoint from next_choices based on direction
"""
    This function chooses the appropriate waypoint from next_choices based on direction
    """
current_waypoint
next_choices
direction