Example #1
0
def test_compute_midpoint_line_curved_maintain_4_waypts():
    """
    Make sure that if we provide left and right boundary polylines,
    we can get the correct centerline by averaging left and right waypoints.

    Note that because of the curve and the arc interpolation, the land width and centerline in the middle points 
    will be shifted.
    """
    right_ln_bnds = np.array([[-1, 3], [1, 3], [4, 0], [4, -2]])
    left_ln_bnds = np.array([[-1, 1], [1, 1], [2, 0], [2, -2]])

    centerline_pts, lane_width = compute_midpoint_line(left_ln_bnds,
                                                       right_ln_bnds,
                                                       num_interp_pts=4)

    from argoverse.utils.mpl_plotting_utils import draw_polygon_mpl

    fig = plt.figure(figsize=(22.5, 8))
    ax = fig.add_subplot(111)

    draw_polygon_mpl(ax, right_ln_bnds, "g")
    draw_polygon_mpl(ax, left_ln_bnds, "b")
    draw_polygon_mpl(ax, centerline_pts, "r")

    gt_centerline_pts = np.array([[-1, 2], [1, 2], [3, 0], [3, -2]])
    gt_lane_width = 2.0

    assert np.allclose(centerline_pts[0], gt_centerline_pts[0])
    assert np.allclose(centerline_pts[-1], gt_centerline_pts[-1])
Example #2
0
def test_compute_midpoint_line_straightline_maintain_2_waypts():
    """
    Make sure that if we provide left and right boundary polylines,
    we can get the correct centerline by averaging left and right waypoints.
    """
    right_ln_bnds = np.array([[-1, 4], [-1, 2], [-1, 0], [-1, -2], [-1, -4]])
    left_ln_bnds = np.array([[2, 4], [2, 2], [2, 0], [2, -2], [2, -4]])

    centerline_pts, lane_width = compute_midpoint_line(left_ln_bnds,
                                                       right_ln_bnds,
                                                       num_interp_pts=2)

    gt_centerline_pts = np.array([[0.5, 4], [0.5, -4]])
    gt_lane_width = 3.0
    assert np.allclose(centerline_pts, gt_centerline_pts)
    assert np.isclose(lane_width, gt_lane_width)
Example #3
0
def test_compute_midpoint_line_cul_de_sac_left_onept():
    """
    Make sure that if we provide left and right boundary polylines,
    we can get the correct centerline by averaging left and right waypoints.
    """
    right_ln_bnds = np.array([[0, 2], [1, 1], [2, 0], [1, -1], [0, -2]])
    left_ln_bnds = np.array([[0, 0]])

    centerline_pts, lane_width = compute_midpoint_line(left_ln_bnds,
                                                       right_ln_bnds,
                                                       num_interp_pts=5)

    gt_centerline_pts = np.array([[0, 1], [0.5, 0.5], [1, 0], [0.5, -0.5],
                                  [0, -1]])
    gt_lane_width = (2 + 2 + 2 + np.sqrt(2) + np.sqrt(2)) / 5

    assert np.allclose(centerline_pts, gt_centerline_pts)
    assert np.isclose(lane_width, gt_lane_width)