def test_interface(self): """ Main test part """ self.assertTrue(admap.init("test_files/TPK.adm.txt")) # map loaded lanes = admap.getLanes() self.assertEqual(len(lanes), 141) # map matching mapMatching = admap.AdMapMatching() geoPoint = admap.GeoPoint() geoPoint.longitude = admap.Longitude(8.4401803) geoPoint.latitude = admap.Latitude(49.0191987) geoPoint.altitude = admap.Altitude(0.) mapMatchingResults = mapMatching.getMapMatchedPositions( geoPoint, physics.Distance(0.01), physics.Probability(0.05)) self.assertEqual(len(mapMatchingResults), 1) # route planning routingStart = mapMatchingResults[0].lanePoint.paraPoint routingEnd = admap.ParaPoint() routingEnd.laneId = routingStart.laneId routingEnd.parametricOffset = physics.ParametricValue(0.0) routeResult = admap.planRoute(admap.createRoutingPoint(routingStart), admap.createRoutingPoint(routingEnd)) routeLength = admap.calcLength(routeResult.roadSegments[0]) self.assertEqual(int(float(routeLength)), 4) admap.cleanup()
def _initialize_ego_vehicle(self): # laneId: offset 240151:0.55 self._initialize_object(admap.Longitude(8.00125444865324766), admap.Latitude(48.99758627528235877), math.pi / 2, self.egoPosition, self.egoMapMatchedBoundingBox) self.egoSpeed = physics.Speed(5.) # laneId: offset 120149:0.16 positionEndGeo = admap.createGeoPoint( admap.Longitude(8.00188527300496979), admap.Latitude(48.99821051747871792), admap.Altitude(0.)) self.egoRoute = admap.planRoute( self.egoMapMatchedBoundingBox.referencePointPositions[ admap.ObjectReferencePoints.Center][0].lanePoint.paraPoint, positionEndGeo)
def test_interface(self): """ Main test part """ self.assertTrue(admap.init("resources/Town01.txt")) print("== Map Loaded ==") self._initialize_ego_vehicle() self.world_model = rssmap.initializeWorldModel( 1, self._get_ego_vehicle_dynamics()) print("== Initial world model ==") print(self.world_model) otherVehicleId = 20 otherVehicleSpeed = physics.Speed(10.) otherVehiclePosition = admap.ENUObjectPosition() otherVehicleMapMatchedBoundingBox = admap.MapMatchedObjectBoundingBox() # laneId: offset 120149:0.16 around the intersection in front same direction on ego route self._initialize_object(admap.Longitude(8.00188527300496979), admap.Latitude(48.99821051747871792), 0, otherVehiclePosition, otherVehicleMapMatchedBoundingBox) self.assertTrue( rssmap.appendScenes( self.egoVehicleId, self.egoMapMatchedBoundingBox, self.egoSpeed, self.egoRoute, otherVehicleId, rss.ObjectType.OtherVehicle, otherVehicleMapMatchedBoundingBox, otherVehicleSpeed, self._get_object_vehicle_dynamics(), rssmap.RestrictSpeedLimitMode.IncreasedSpeedLimit10, admap.LandmarkIdSet(), self.world_model)) self.assertTrue( rssmap.finalizeWorldModel(self._get_ego_vehicle_dynamics(), self.world_model)) print("== Final world model ==") print(self.world_model) rss_response_resolving = rss.RssResponseResolving() rss_situation_checking = rss.RssSituationChecking() rss_sitation_extraction = rss.RssSituationExtraction() rss_situation_snapshot = rss.SituationSnapshot() self.assertTrue( rss_sitation_extraction.extractSituations(self.world_model, rss_situation_snapshot)) print("== Situation Snaphost ==") print(rss_situation_snapshot) rss_state_snapshot = rss.RssStateSnapshot() self.assertTrue( rss_situation_checking.checkSituations(rss_situation_snapshot, rss_state_snapshot)) rss_proper_response = rss.ProperResponse() self.assertTrue( rss_response_resolving.provideProperResponse( rss_state_snapshot, rss_proper_response)) acceleration_restriction = rss.AccelerationRestriction() self.assertTrue( rss.transformProperResponse(self.world_model, rss_proper_response, acceleration_restriction)) print("== Acceleration Restrictions ==") print(acceleration_restriction) longitudinal_distance = rss_situation_snapshot.situations[ 0].relativePosition.longitudinalDistance self.assertTrue(rss_proper_response.isSafe) self.assertEqual(longitudinal_distance, physics.Distance(104.413)) self.world_model.timeIndex += 1