def test_compute_lane_width_curved_width1(): """ Compute the lane width of the following curved lane segment Should have width 1 at each pair of boundary waypoints. -------boundary / ----boundary / / | | | \\ \\ ----- \\----- """ left_even_pts = np.array([[0, 2], [-2, 2], [-3, 1], [-3, 0], [-2, -1], [0, -1]]) right_even_pts = np.array([[0, 3], [-2, 3], [-4, 1], [-4, 0], [-2, -2], [0, -2]]) lane_width = compute_lane_width(left_even_pts, right_even_pts) gt_lane_width = 1.0 assert np.isclose(lane_width, gt_lane_width) lane_width = compute_lane_width(right_even_pts, left_even_pts) gt_lane_width = 1.0 assert np.isclose(lane_width, gt_lane_width)
def test_compute_lane_width_curved_not_width1(): """ Compute the lane width of the following curved lane segment ------- / ---- / / | | | \\ \\ ----- \\----- We get waypoint distances of [1,1,1,1,0.707..., 1,1] """ left_even_pts = np.array([[0, 2], [-2, 2], [-3, 1], [-3, 0], [-2.5, -0.5], [-2, -1], [0, -1]]) right_even_pts = np.array([[0, 3], [-2, 3], [-4, 1], [-4, 0], [-3, -1], [-2, -2], [0, -2]]) lane_width = compute_lane_width(left_even_pts, right_even_pts) gt_lane_width = 0.9581581115980783 assert np.isclose(lane_width, gt_lane_width) lane_width = compute_lane_width(right_even_pts, left_even_pts) gt_lane_width = 0.9581581115980783 assert np.isclose(lane_width, gt_lane_width)
def test_compute_lane_width_straight(): """ Compute the lane width of the following straight lane segment (waypoints indicated with "o" symbol): o o | | o o | | o o We can swap boundaries for this lane, and the width should be identical. """ left_even_pts = np.array([[1, 1], [1, 0], [1, -1]]) right_even_pts = np.array([[-1, 1], [-1, 0], [-1, -1]]) lane_width = compute_lane_width(left_even_pts, right_even_pts) gt_lane_width = 2.0 assert np.isclose(lane_width, gt_lane_width) lane_width = compute_lane_width(right_even_pts, left_even_pts) gt_lane_width = 2.0 assert np.isclose(lane_width, gt_lane_width)
def test_compute_lane_width_telescoping(): """ Compute the lane width of the following straight lane segment (waypoints indicated with "o" symbol): o o \\ // o o \\ // o o \\ // o We can swap boundaries for this lane, and the width should be identical. """ left_even_pts = np.array([[3, 2], [2, 1], [1, 0], [0, -1]]) right_even_pts = np.array([[-3, 2], [-2, 1], [-1, 0], [0, -1]]) lane_width = compute_lane_width(left_even_pts, right_even_pts) gt_lane_width = (6.0 + 4.0 + 2.0 + 0.0) / 4 assert np.isclose(lane_width, gt_lane_width) lane_width = compute_lane_width(right_even_pts, left_even_pts) gt_lane_width = (6.0 + 4.0 + 2.0 + 0.0) / 4 assert np.isclose(lane_width, gt_lane_width)