def _build_world_state(self): param_server = ParameterServer(json=self._json_params) world = World(param_server) if self._map_interface is None: self.CreateMapInterface(self.full_map_file_name) world.SetMap(self._map_interface) else: world.SetMap(self._map_interface) for agent in self._agent_list: agent.GenerateRoadCorridor(self._map_interface) world.AddAgent(agent) world.UpdateAgentRTree() return world
def test_lateral_highway_unsafe(self): """ Checking Lateral Responses (true means safe) """ params = ParameterServer() map = "bark/runtime/tests/data/city_highway_straight.xodr" params["EvaluatorRss"]["MapFilename"] = map map_interface = EvaluatorRSSTests.load_map(map) world = World(params) world.SetMap(map_interface) goal_polygon_1 = Polygon2d( [0, 0, 0], [Point2d(-1, -1), Point2d(-1, 1), Point2d(1, 1), Point2d(1, -1)]) goal_polygon_1 = goal_polygon_1.Translate(Point2d(5.5, 120)) goal_polygon_2 = Polygon2d( [0, 0, 0], [Point2d(-1, -1), Point2d(-1, 1), Point2d(1, 1), Point2d(1, -1)]) goal_polygon_2 = goal_polygon_2.Translate(Point2d(1.8, 120)) # Hard coded ego_state = np.array([0, 5.0, 10, np.pi / 2, 10]) # straight north other_state = np.array([0, 3.1, 0, np.pi / 2, 10]) # straight north ego = TestAgent(ego_state, goal_polygon_1, map_interface, params) other = TestAgent(other_state, goal_polygon_2, map_interface, params) world.AddAgent(ego) world.AddAgent(other) world.UpdateAgentRTree() viewer = MPViewer(params=params, use_world_bounds=True) viewer.drawWorld(world) viewer.show(block=False) evaluator_rss = EvaluatorRSS(ego.id, params) self.assertEqual( False, evaluator_rss.PairwiseDirectionalEvaluate(world)[other.id][1])
def test_longitude_highway_unsafe(self): """ Checking Longitudinal Responses (true means safe) """ params = ParameterServer() map = "bark/runtime/tests/data/city_highway_straight.xodr" params["EvaluatorRss"]["MapFilename"] = map map_interface = EvaluatorRSSTests.load_map(map) world = World(params) world.SetMap(map_interface) goal_polygon = Polygon2d( [0, 0, 0], [Point2d(-1, -1), Point2d(-1, 1), Point2d(1, 1), Point2d(1, -1)]) goal_polygon = goal_polygon.Translate(Point2d(1.8, 120)) # The safety distance seems more conservative than in the paper # Hard coded ego_state = np.array([0, 1.8, -60.0, np.pi / 2, 10]) other_state = np.array([0, 1.8, -68.0, np.pi / 2, 10]) ego = TestAgent(ego_state, goal_polygon, map_interface, params) other = TestAgent(other_state, goal_polygon, map_interface, params) world.AddAgent(ego) world.AddAgent(other) world.UpdateAgentRTree() viewer = MPViewer(params=params, use_world_bounds=True) viewer.drawWorld(world) viewer.show(block=False) evaluator_rss = EvaluatorRSS(ego.id, params) pw_directional_evaluation_return = evaluator_rss.PairwiseDirectionalEvaluate( world) self.assertEqual(False, pw_directional_evaluation_return[other.id][0])
def test_lateral_merging_safe(self): """ Checking Lateral Responses (true means safe) """ params = ParameterServer() map = "bark/runtime/tests/data/DR_DEU_Merging_MT_v01_centered.xodr" params["EvaluatorRss"]["MapFilename"] = map map_interface = EvaluatorRSSTests.load_map(map) world = World(params) world.SetMap(map_interface) goal_polygon = Polygon2d( [0, 0, 0], [Point2d(-1, -1), Point2d(-1, 1), Point2d(1, 1), Point2d(1, -1)]) goal_polygon = goal_polygon.Translate(Point2d(-15.4, 108.6)) # Hard coded ego_state = np.array([0, 68.1, 108, -np.pi, 5]) other_state = np.array([0, 64.1, 105, -np.pi, 5]) ego = TestAgent(ego_state, goal_polygon, map_interface, params) other = TestAgent(other_state, goal_polygon, map_interface, params) world.AddAgent(ego) world.AddAgent(other) world.UpdateAgentRTree() viewer = MPViewer(params=params, use_world_bounds=True) viewer.drawWorld(world) viewer.show(block=False) evaluator_rss = EvaluatorRSS(ego.id, params) world.AddEvaluator("rss", evaluator_rss) pw_directional_evaluation_return = evaluator_rss.PairwiseDirectionalEvaluate( world) self.assertEqual(True, pw_directional_evaluation_return[other.id][1])