Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function help #11

Open
Fengmoon93 opened this issue Aug 25, 2020 · 1 comment
Open

function help #11

Fengmoon93 opened this issue Aug 25, 2020 · 1 comment

Comments

@Fengmoon93
Copy link

thanks for sharing.

def sort_lanes_based_on_point_in_polygon_score(
        self,
        lane_seqs: List[List[int]],
        xy_seq: np.ndarray,
        city_name: str,
        avm: ArgoverseMap,
) -> List[List[int]]:
    """Filter lane_seqs based on the number of coordinates inside the bounding polygon of lanes.

    Args:
        lane_seqs: Sequence of lane sequences
        xy_seq: Trajectory coordinates
        city_name: City name (PITT/MIA)
        avm: Argoverse map_api instance
    Returns:
        sorted_lane_seqs: Sequences of lane sequences sorted based on the point_in_polygon score

    """
    point_in_polygon_scores = []
    for lane_seq in lane_seqs:
        point_in_polygon_scores.append(
            self.get_point_in_polygon_score(lane_seq, xy_seq, city_name,
                                            avm))
    randomized_tiebreaker = np.random.random(len(point_in_polygon_scores))

    sorted_point_in_polygon_scores_idx = np.lexsort(
        (randomized_tiebreaker, np.array(point_in_polygon_scores)))[::-1]
    sorted_lane_seqs = [
        lane_seqs[i] for i in sorted_point_in_polygon_scores_idx
    ]
    sorted_scores = [
        point_in_polygon_scores[i]
        for i in sorted_point_in_polygon_scores_idx
    ]
    return sorted_lane_seqs, sorted_scores

why using the randomized_tiebreaker in the function?
sort by point_in_polygon_scores first and then sort by the random value?

@jagjeet-singh
Copy link
Owner

Hi,

That's a good question. Point in polygon score is likely to sort the lane sequences such that similar lane sequences will be nearby in the order. Randomized tie-breaker helps in complementing those with diverse lane sequences.
For eg. Consider an actor approaching an intersection. There are multiple straight through lane sequences because of the branching at the next intersection. If we have to select 3 lane sequences, we'd prefer left, right and straight ones.
The point in polygon score will not be able to account for the overlap in the straight-through ones.
Randomized tie-breaker on top of point in polygon will improve the chances of choosing our preferred 3 lane sequences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants