def test_configurable_scenario_generation_parametric_observer(self): params = ParameterServer() mapfile = os.path.join(os.path.dirname(__file__), "data/city_highway_straight.xodr") conf_params = params["Scenario"]["Generation"][ "ConfigurableScenarioGeneration"] conf_params["MapFilename"] = mapfile conf_params["ObserverModel"] = { "Description": "world_observer", "ConfigObserverModel": { "Type": "ObserverModelParametricReader" } } scenario_generation = ConfigurableScenarioGeneration(num_scenarios=2, params=params) scenario_generation.dump_scenario_list("test.scenario") scenario_loader = ScenarioGeneration() scenario_loader.load_scenario_list("test.scenario") self.assertEqual(len(scenario_loader._scenario_list), 2) self.assertEqual( len(scenario_loader._scenario_list[0]._agent_list), len(scenario_generation._scenario_list[0]._agent_list)) scenario = scenario_loader.get_scenario(idx=0) params.Save("default_params_observer.json")
def test_configurable_scenario_generation_interaction_merging_track_ids(self): sink_source_dict = { "SourceSink": [[1001.92, 1005.59], [883.064, 1009.07] ], "Description": "merging_deu_standard", "ConfigAgentStatesGeometries": {"Type": "InteractionDataTrackIdsStatesGeometries"}, "ConfigBehaviorModels": {"Type": "InteractionDataBehaviors"}, "ConfigExecutionModels": {"Type": "FixedExecutionType"}, "ConfigDynamicModels": {"Type": "FixedDynamicType"}, "ConfigGoalDefinitions": {"Type": "FixedGoalTypes"}, "ConfigControlledAgents": {"Type": "AgentIds", "ControlledIds" : [1]}, "AgentParams" : {} } params = ParameterServer() params["Scenario"]["Generation"]["ConfigurableScenarioGeneration"]["SinksSources"] = [sink_source_dict] params["Scenario"]["Generation"]["ConfigurableScenarioGeneration"]["MapFilename"] = \ "bark/runtime/tests/data/DR_DEU_Merging_MT_v01_shifted.xodr" scenario_generation = ConfigurableScenarioGeneration(num_scenarios=2,params=params) scenario_generation.dump_scenario_list("test.scenario") scenario_loader = ScenarioGeneration() scenario_loader.load_scenario_list("test.scenario") self.assertEqual(len(scenario_loader._scenario_list), 2) self.assertEqual(len(scenario_loader._scenario_list[0]._agent_list), len(scenario_generation._scenario_list[0]._agent_list)) scenario = scenario_loader.get_scenario(idx=0) params.Save("default_params_interaction_dataset.json")
def test_configurable_scenario_generation_sample_behavior_types(self): sink_source_dict = [{ "SourceSink": [[5111.626, 5006.8305], [5110.789, 5193.1725]], "Description": "left_lane", "ConfigAgentStatesGeometries": {"Type": "UniformVehicleDistribution", "LanePositions": [0]}, "ConfigBehaviorModels": {"Type": "FixedBehaviorType", "ModelType": "BehaviorIDMClassic", "ModelParams": {"BehaviorIDMClassic::MaxVelocity": 60.0}}, "ConfigExecutionModels": {"Type": "FixedExecutionType"}, "ConfigDynamicModels": {"Type": "FixedDynamicType"}, "ConfigGoalDefinitions": {"Type": "FixedGoalTypes"}, "ConfigControlledAgents": {"Type": "NoneControlled"}, "AgentParams": {} }, { "SourceSink": [[5111.626, 5006.8305], [5110.789, 5193.1725]], "Description": "right_lane", "ConfigAgentStatesGeometries": {"Type": "UniformVehicleDistribution", "LanePositions": [1]}, "ConfigBehaviorModels": {"Type": "SampleBehaviorType"}, "ConfigExecutionModels": {"Type": "FixedExecutionType"}, "ConfigDynamicModels": {"Type": "FixedDynamicType"}, "ConfigGoalDefinitions": {"Type": "FixedGoalTypes"}, "ConfigControlledAgents": {"Type": "RandomSingleAgent"}, "AgentParams": {} }] params = ParameterServer() params["Scenario"]["Generation"]["ConfigurableScenarioGeneration"]["SinksSources"] = sink_source_dict params["Scenario"]["Generation"]["ConfigurableScenarioGeneration"]["MapFilename"] = os.path.join(os.path.dirname(__file__),"data/city_highway_straight.xodr") scenario_generation = ConfigurableScenarioGeneration( num_scenarios=2, params=params) scenario_generation.dump_scenario_list("test.scenario") params.Save("default_params_behavior_type_sampling.json")
def test_configurable_scenario_generation_add_module_dir(self): sink_source_dict = { "SourceSink": [[1001.92, 1005.59], [883.064, 1009.07] ], "Description": "merging_deu_standard", "ConfigAgentStatesGeometries": {"Type": "UniformVehicleDistribution", "LanePositions": [0]}, "ConfigBehaviorModels": {"Type": "TestReaderFixedBehaviorType"}, "ConfigExecutionModels": {"Type": "FixedExecutionType"}, "ConfigDynamicModels": {"Type": "FixedDynamicType"}, "ConfigGoalDefinitions": {"Type": "FixedGoalTypes"}, "ConfigControlledAgents": {"Type": "RandomSingleAgent"}, "AgentParams" : {} } params = ParameterServer() params["Scenario"]["Generation"]["ConfigurableScenarioGeneration"]["SinksSources"] = [sink_source_dict] add_config_reader_module("bark.runtime.tests.test_config_reader_module") scenario_generation = ConfigurableScenarioGeneration(num_scenarios=2,params=params) scenario_generation.dump_scenario_list("test.scenario") scenario_loader = ScenarioGeneration() scenario_loader.load_scenario_list("test.scenario") self.assertEqual(len(scenario_loader._scenario_list), 2) self.assertEqual(len(scenario_loader._scenario_list[0]._agent_list), len(scenario_generation._scenario_list[0]._agent_list)) scenario = scenario_loader.get_scenario(idx=0) # test if window is reset scenario_generation2 = ConfigurableScenarioGeneration(num_scenarios=2,params=params) self.assertEqual(len(scenario_generation2._scenario_list), 2) params.Save("default_params_interaction_dataset.json")
def test_configurable_scenario_generation_interaction_merging_window(self): track_filenames = os.path.join(os.path.dirname(__file__), "data/*_dataset_dummy_track.csv") map_filename = os.path.join(os.path.dirname(__file__), "data/DR_DEU_Merging_MT_v01_shifted.xodr") sink_source_dict = { "SourceSink": [[1001.92, 1005.59], [883.064, 1009.07] ], "Description": "merging_deu_standard", "ConfigAgentStatesGeometries": {"Type": "InteractionDataWindowStatesGeometries", "TrackFilenames": track_filenames}, "ConfigBehaviorModels": {"Type": "InteractionDataBehaviors"}, "ConfigExecutionModels": {"Type": "FixedExecutionType"}, "ConfigDynamicModels": {"Type": "FixedDynamicType"}, "ConfigGoalDefinitions": {"Type": "FixedGoalTypes", "EnforceControlledGoal": False}, "ConfigControlledAgents": {"Type": "PositioningSingleAgent", "LanePosition" : 0}, "AgentParams" : {} } params = ParameterServer() params["Scenario"]["Generation"]["ConfigurableScenarioGeneration"]["SinksSources"] = [sink_source_dict] params["Scenario"]["Generation"]["ConfigurableScenarioGeneration"]["MapFilename"] = map_filename scenario_generation = ConfigurableScenarioGeneration(num_scenarios=2,params=params) scenario_generation.dump_scenario_list("test.scenario") scenario_loader = ScenarioGeneration() scenario_loader.load_scenario_list("test.scenario") self.assertEqual(len(scenario_loader._scenario_list), 2) self.assertEqual(len(scenario_loader._scenario_list[0]._agent_list), len(scenario_generation._scenario_list[0]._agent_list)) scenario = scenario_loader.get_scenario(idx=0) # test if window is reset scenario_generation2 = ConfigurableScenarioGeneration(num_scenarios=2,params=params) self.assertEqual(len(scenario_generation2._scenario_list), 2) params.Save("default_params_interaction_dataset.json")
def test_configurable_scenario_generation_default_params(self): params = ParameterServer() mapfile = os.path.join(os.path.dirname(__file__),"data/city_highway_straight.xodr") params["Scenario"]["Generation"]["ConfigurableScenarioGeneration"]["MapFilename"] = mapfile scenario_generation = ConfigurableScenarioGeneration( num_scenarios=2, params=params) scenario_generation.dump_scenario_list("test.scenario") scenario_loader = ScenarioGeneration() scenario_loader.load_scenario_list("test.scenario") self.assertEqual(len(scenario_loader._scenario_list), 2) self.assertEqual(len(scenario_loader._scenario_list[0]._agent_list), len( scenario_generation._scenario_list[0]._agent_list)) scenario = scenario_loader.get_scenario(idx=0) params.Save("default_params.json")