def make_two_lane_road(): return create_dragway(road_id=RoadGeometryId("two_lanes"), num_lanes=2, length=10., lane_width=4., shoulder_width=0., maximum_height=1., linear_tolerance=1e-6, angular_tolerance=1e-6)
def test_dragway(self): kNumLanes = 2 kLength = 100. kLaneWidth = 4. kShoulderWidth = 1. kHeight = 5. kTol = 1e-6 # Instantiate a two-lane straight road. rg_id = RoadGeometryId("two_lane_road") rg = create_dragway(rg_id, kNumLanes, kLength, kLaneWidth, kShoulderWidth, kHeight, kTol, kTol) segment = rg.junction(0).segment(0) lane_0 = segment.lane(0) lane_1 = segment.lane(1) # Alternate constructor. create_dragway(road_id=rg_id, num_lanes=kNumLanes, length=kLength, lane_width=kLaneWidth, shoulder_width=kShoulderWidth, maximum_height=kHeight, linear_tolerance=kTol, angular_tolerance=kTol) # Test the Lane <-> Geo space coordinate conversion. lane_pos = LanePosition(0., 0., 0.) geo_pos_result = lane_0.ToGeoPosition(lane_pos) geo_pos_expected = GeoPosition(0., -kLaneWidth / 2., 0.) self.assertTrue( np.allclose(geo_pos_result.xyz(), geo_pos_expected.xyz())) geo_pos = GeoPosition(1., kLaneWidth / 2., 3.) nearest_pos = GeoPosition(0., 0., 0.) distance = 0. lane_pos_result = \ lane_1.ToLanePosition(geo_pos, nearest_pos, distance) lane_pos_expected = LanePosition(1., 0., 3.) self.assertTrue( np.allclose(lane_pos_result.srh(), lane_pos_expected.srh())) self.assertTrue(np.allclose(nearest_pos.xyz(), geo_pos.xyz())) self.assertTrue(distance == 0.)
def make_test_dragway(lane_width, length): kNumLanes = 2 kShoulderWidth = 1. kHeight = 5. kTol = 1e-6 rg_id = RoadGeometryId("two_lane_road") return create_dragway( road_id=rg_id, num_lanes=kNumLanes, length=length, lane_width=lane_width, shoulder_width=kShoulderWidth, maximum_height=kHeight, linear_tolerance=kTol, angular_tolerance=kTol)
def make_two_lane_road(): return create_dragway( road_id=RoadGeometryId("two_lanes"), num_lanes=2, length=10., lane_width=4., shoulder_width=0., maximum_height=1., linear_tolerance=1e-6, angular_tolerance=1e-6)