Maps

This module includes the interface for map conversions.

Scenario Wrapper

ScenarioWrapper class

class maps.sumo_scenario.ScenarioWrapper[source]
initialize(scenario_name, sumo_cfg_file, cr_map_file, ego_start_time=None)[source]

Initializes the ScenarioWrapper.

Parameters:
  • scenario_name (str) – the name of the scenario
  • sumo_cfg_file (str) – the .sumocfg file
  • cr_map_file (str) – the commonroad map file
  • ego_start_time (Optional[int]) – the start time of the ego vehicle
Return type:

None

classmethod init_from_scenario(scenario_name, ego_start_time=None)[source]

Initializes the ScenarioWrapper according to the given scenario_name/ego_start_time and returns the ScenarioWrapper.

Parameters:
  • cls
  • scenario_name (str) – name of the scenario usef for the initialization.
  • ego_start_time (Optional[int]) – the start time of the ego vehicle.
Return type:

ScenarioWrapper

classmethod recreate_route_file(sumo_cfg_file, dt, n_vehicles_max, n_ego_vehicles, ego_ids=[], ego_start_time=0, departure_time_ego=0, departure_interval_vehicles=<commonroad.common.util.Interval object>, veh_per_second=None)[source]

Creates new .rou.xml file and returns ScenarioWrapper. Assumes .cr.xml, .net.xml and .sumo.cfg file have already been created in scenario folder.

Parameters:
  • sumo_cfg_file
  • n_vehicles_max (int) –
  • n_ego_vehicles (int) –
  • ego_ids (List[int]) –
  • ego_start_time (int) –
  • departure_interval_vehicles (Interval) –
Return type:

ScenarioWrapper

classmethod full_conversion_from_net(net_file, dt, n_vehicles_max, n_ego_vehicles, ego_ids=[], ego_start_time=0, departure_time_ego=0, departure_interval_vehicles=<commonroad.common.util.Interval object>, veh_per_second=None, scenario_folder=None)[source]

Convert net file to CommonRoad xml and generate specific ego vehicle either by using generated vehicles and/or by initial states.

Parameters:
  • net_file (str) – path of .net.xml file
  • dt (float) – length of time step
  • n_vehicles_max (int) – max number of vehicles
  • n_ego_vehicles (int) – total number of ego vehicles that are generated
  • ego_ids (List[int]) – if specified, vehicle with given id from .rou file is marked as ego_vehicle
  • ego_start_time (int) – the starting time of ego vehicles
  • departure_time_ego (int) – interval of departure times for ego vehicles
  • departure_interval_vehicles (Interval) – interval of departure times for vehicles
  • veh_per_second – number of vehicle departures per second
  • scenario_folder (Optional[str]) – folder that contains all scenario folders. If not given, use commonroad-sumo-interface/scenarios/scenario_name
Return type:

ScenarioWrapper

generate_cfg_file(scenario_name, output_folder)[source]

Generates the configuration file according to the scenario name to the specified output folder.

Parameters:
  • scenario_name (str) – name of the scenario used for the cfg file generation.
  • output_folder (str) – the generated cfg file will be saved here
Return type:

str

Returns:

the path of the generated cfg file.

print_lanelet_net(with_lane_id=True, with_succ_pred=False, with_adj=False, with_speed=False)[source]

Prints the lanelet net.

Parameters:
  • with_lane_id – if true, shows the lane id.
  • with_succ_pred – if true, shows the successors and precessors.
  • with_adj – if true, show the adjacent lanelets.
  • with_speed – if true, shows the speed limit of the lanelt.
Return type:

None

Helper functions

maps.util.convert_net_to_cr(net_file, out_folder=None, verbose=False)[source]

Converts .net file to CommonRoad xml using netconvert and OpenDRIVE 2 Lanelet Converter.

Parameters:
  • net_file (str) – path of .net.xml file
  • out_folder (Optional[str]) – path of output folder for CommonRoad scenario.
Return type:

str

Returns:

commonroad map file

maps.util.find_ego_ids_by_departure_time(rou_file, n_ego_vehicles, departure_time_ego, ego_ids)[source]

Returns ids of vehicles from route file which match desired departure time as close as possible.

Parameters:
  • rou_file (str) – path of route file
  • n_ego_vehicles (int) – number of ego vehicles
  • departure_time_ego (int) – desired departure time ego vehicle
  • ego_ids (list) – if desired ids of ego_vehicle known, specify here
Return type:

list

maps.util.get_scenario_name_from_netfile(filepath)[source]

Returns the scenario name specified in the net file.

Parameters:filepath (str) – the path of the net file
Return type:str
maps.util.generate_rou_file(net_file, dt, n_vehicles_max, departure_time, n_ego_vehicles, departure_time_ego, ego_ids=None, veh_per_second=None, out_folder=None)[source]

Creates route & trips files using randomTrips generator.

Parameters:
  • net_file (str) – path of .net.xml file
  • dt (float) – length of the time step
  • n_vehicles_max (int) – max. number of vehicles in route file
  • departure_time (Interval) – Interval of departure times for vehicles
  • n_ego_vehicles (int) – number of ego vehicles
  • departure_time_ego (int) – desired departure time ego vehicle
  • ego_ids (Optional[List[int]]) – if desired ids of ego_vehicle known, specify here
  • veh_per_second (Optional[float]) – number of vehicle departures per second
  • out_folder (Optional[str]) – output folder of route file (same as net_file if None)
Return type:

str

Returns:

path of route file

maps.util.write_ego_ids_to_rou_file(rou_file, ego_ids)[source]

Writes ids of ego vehicles to the route file.

Parameters:
  • rou_file (str) – the route file
  • ego_ids (List[int]) – a list of ego vehicle ids
Return type:

None