def create_single_scenario(self): scenario = Scenario(map_file_name=self.map_file_name, json_params=self.params.convert_to_dict()) world = scenario.get_world_state() agent_list = [] for idx, source in enumerate(self.others_source): connecting_center_line, s_start, s_end, _, lane_id_end = \ self.center_line_between_source_and_sink( world.map, source, self.others_sink[idx]) goal_polygon = Polygon2d([0, 0, 0], [ Point2d(-1, -1), Point2d(-1, 1), Point2d(1, 1), Point2d(1, -1) ]) goal_polygon = goal_polygon.translate( Point2d(self.ego_goal[0], self.ego_goal[1])) goal_definition = GoalDefinition(goal_polygon) agent_list.extend( self.place_agents_along_linestring(world, connecting_center_line, s_start, s_end, \ self.agent_params, goal_definition) ) description = self.params.convert_to_dict() description["ScenarioGenerator"] = "UniformVehicleDistribution" scenario.agent_list = agent_list num_agents = len(scenario.agent_list) scenario.eval_agent_ids = [ scenario.agent_list[math.floor(num_agents / 2)].id ] # only one agent is ego in the middle of all other agents return scenario
def create_single_scenario(self): scenario = Scenario(map_file_name=self.map_file_name, json_params=self.params.convert_to_dict()) world = scenario.get_world_state() agent_list = [] for idx, source in enumerate(self.others_source): connecting_center_line, s_start, s_end, _, lane_id_end = \ self.center_line_between_source_and_sink( world.map, source, self.others_sink[idx]) agent_list.extend( self.place_agents_along_linestring(world, connecting_center_line, s_start, s_end, \ self.agent_params, lane_id_end) ) description = self.params.convert_to_dict() description["ScenarioGenerator"] = "UniformVehicleDistribution" scenario.agent_list = agent_list return scenario