Пример #1
0
 def initialize_params(self, params):
     super().initialize_params(params)
     params_temp = \
         self._params["Scenario"]["Generation"]["InteractionDatasetScenarioGeneration"]
     self._map_file_name = params_temp["MapFilename",
                                       "Path to the open drive map",
                                       os.path.expanduser('~') + "/bark-simulator/interaction_dataset_fortiss_internal/DR_DEU_Merging_MT/map/DR_DEU_Merging_MT_v01_shifted.xodr"]
     self._track_file_name = params_temp["TrackFilename",
                                         "Path to track file (csv)",
                                         os.path.expanduser('~') + "/bark-simulator/interaction_dataset_fortiss_internal/DR_DEU_Merging_MT/tracks/vehicle_tracks_013.csv"]
     self._track_ids = params_temp["TrackIds",
                                   "IDs of the vehicle tracks to import.",
                                   [1]]
     self._xy_offset = params_temp["XYOffset",
                                   "offset in x and y direction.", [0, 0]]
     self._start_time = params_temp["StartTs",
                                    "Timestamp when to start the scenario (ms)", 0]
     self._end_time = params_temp["EndTs",
                                  "Timestamp when to end the scenario (ms)", None]
     self._ego_track_id = params_temp["EgoTrackId", "TrackID of ego", -1]
     self._behavior_models = params_temp["BehaviorModel",
                                         "Overwrite static trajectory with prediction model", {}]
     self._use_rectangle_shape = params_temp["RectangleShape",
                                             "Use Rectangle vehicle shape", True]
     
     self._interaction_ds_reader = InteractionDatasetReader()
Пример #2
0
    def test_agent_from_trackfile_centered(self):

        map_filename = os.path.join(
            os.path.dirname(__file__),
            "../tests/data/DR_DEU_Merging_MT_v01_centered.xodr")
        track_filename = os.path.join(
            os.path.dirname(__file__),
            "../tests/data/interaction_dataset_dummy_track.csv")

        agent_track_info = AgentTrackInfo(track_filename,
                                          track_id=1,
                                          start_offset=500,
                                          end_offset=1000)

        params = ParameterServer()
        params_id = params["Scenario"]["Generation"]["InteractionDataset"]
        params_id["MapFilename", "", map_filename]
        params_id["TrackFilename", "", track_filename]
        params_id["BehaviorModel", "", {}]

        track_params = ParameterServer()
        track_params["execution_model"] = 'ExecutionModelInterpolate'
        track_params["dynamic_model"] = 'SingleTrackModel'
        track_params["map_interface"] = None  # world.map
        track_params["behavior_model"] = None

        scenario_info = ScenarioTrackInfo(map_filename,
                                          track_filename,
                                          agent_track_info,
                                          xy_offset=[-900, -900])
        ds_reader = InteractionDatasetReader()
        agent = ds_reader.AgentFromTrackfile(track_params, params,
                                             scenario_info,
                                             agent_track_info.GetTrackId())
 def __init__(self, params=None, num_scenarios=None, random_seed=None):
     self.interaction_ds_reader = InteractionDatasetReader()
     super().__init__(params, num_scenarios, random_seed)
     self.initialize_params(params)
class InteractionDatasetScenarioGeneration(ScenarioGeneration):
    def __init__(self, params=None, num_scenarios=None, random_seed=None):
        self.interaction_ds_reader = InteractionDatasetReader()
        super().__init__(params, num_scenarios, random_seed)
        self.initialize_params(params)

    def initialize_params(self, params):
        super().initialize_params(params)
        params_temp = \
            self._params["Scenario"]["Generation"]["InteractionDatasetScenarioGeneration"]
        self._map_file_name = params_temp[
            "MapFilename", "Path to the open drive map",
            os.path.expanduser('~') +
            "/bark-simulator/interaction_dataset_fortiss_internal/DR_DEU_Merging_MT/map/DR_DEU_Merging_MT_v01_shifted.xodr"]
        self._track_file_name = params_temp[
            "TrackFilename", "Path to track file (csv)",
            os.path.expanduser('~') +
            "/bark-simulator/interaction_dataset_fortiss_internal/DR_DEU_Merging_MT/tracks/vehicle_tracks_013.csv"]
        self._track_ids = params_temp["TrackIds",
                                      "IDs of the vehicle tracks to import.",
                                      [1]]
        self._start_time = params_temp[
            "StartTs", "Timestamp when to start the scenario (ms)", 0]
        self._end_time = params_temp["EndTs",
                                     "Timestamp when to end the scenario (ms)",
                                     None]
        self._ego_track_id = params_temp["EgoTrackId", "TrackID of ego", -1]
        self._behavior_models = params_temp[
            "BehaviorModel",
            "Overwrite static trajectory with prediction model", {}]

    # TODO: remove code duplication with configurable scenario generation
    def create_scenarios(self, params, num_scenarios):
        """ 
            see baseclass
        """

        if num_scenarios != 1:
            raise ValueError("Replay supports only 1 scenario")

        scenario_track_info = self.__fill_scenario_track_info__()
        scenario_list = [self.__create_single_scenario__(scenario_track_info)]

        return scenario_list

    def __fill_scenario_track_info__(self):
        if self._ego_track_id == -1:
            raise ValueError("No ego id has been defined")

        ego_track_info = AgentTrackInfo(filename=self._track_file_name,
                                        track_id=self._ego_track_id,
                                        start_offset=self._start_time,
                                        end_offset=self._end_time)
        scenario_track_info = ScenarioTrackInfo(
            map_filename=self._map_file_name,
            track_filename=self._track_file_name,
            ego_track_info=ego_track_info)
        for track_id in self._track_ids:
            new_agent = AgentTrackInfo(filename=self._track_file_name,
                                       track_id=track_id,
                                       start_offset=self._start_time,
                                       end_offset=self._end_time)
            scenario_track_info.AddTrackInfoOtherAgent(new_agent)

        return scenario_track_info

    def __create_single_scenario__(self, scenario_track_info):
        scenario_track_info.TimeSanityCheck()

        scenario = Scenario(map_file_name=self._map_file_name,
                            json_params=self._params.ConvertToDict())
        world = scenario.GetWorldState()
        agent_list = []
        track_params = ParameterServer()
        track_params["execution_model"] = 'ExecutionModelInterpolate'
        track_params["dynamic_model"] = 'SingleTrackModel'
        track_params["map_interface"] = world.map

        for id_other in scenario_track_info.GetOtherTrackInfos().keys():
            if str(id_other) in self._behavior_models:
                track_params["behavior_model"] = self._behavior_models[str(
                    id_other)]
            else:
                track_params["behavior_model"] = None
            agent = self.interaction_ds_reader.AgentFromTrackfile(
                track_params, self._params, scenario_track_info, id_other)
            agent_list.append(agent)

        id_ego = scenario_track_info.GetEgoTrackInfo().GetTrackId()
        if str(id_ego) in self._behavior_models:
            track_params["behavior_model"] = self._behavior_models[str(id_ego)]
        else:
            track_params["behavior_model"] = None
        agent = self.interaction_ds_reader.AgentFromTrackfile(
            track_params, self._params, scenario_track_info, id_ego)
        agent_list.append(agent)

        scenario._agent_list = agent_list  # must contain all agents!
        scenario._eval_agent_ids = [
            scenario_track_info.GetEgoTrackInfo().GetTrackId()
        ]

        return scenario