sumo_docker

This module provides an interface to a dockerized Sumo simulation and handles all docker-related operations. The communication with the Sumo simulation works via an RPC interface that is implemented in sumocr.sumo_docker.rpc.sumo_client.SumoRPCClient.

SumoInterface class

class sumocr.sumo_docker.interface.docker_interface.SumoInterface(use_docker=True)[source]

Class for setting up a simulation with a dockerized Sumo installation.

start_simulator()[source]

Starting SUMO in docker container and return a client for connecting with it. :rtype: SumoRPCClient :return: SumoRPCClient which can communicate with SUMO

stop_simulator()[source]

Stop the sumo simulation and stop the docker container. :rtype: None :return: None

check_docker_health()[source]

Checks the health of the docker container :rtype: bool :return: True if the container is up and running

SumoRPCClient class

class sumocr.sumo_docker.rpc.sumo_client.SumoRPCClient(address)[source]

RPC client between CommonRoad and SUMO. This class mirrors all public functions and attributes from the class SumoSimulation.

class RequestTypes(value)[source]

An enumeration.

class RequestProvider(channel, module)[source]

Class responsible for providing gRPC requests

create_request_method(method_name)[source]

Creating RPC request by a method name The gRPC methods are unary-unary, therefore the call is wrapped so that the request arguments and the reply is placed into tuples. :param method_name: The name of the method which call is requested by the gRPC server

create_client_streaming_method(method_name)[source]

Creating RPC request by a method name The gRPC methods are unary-unary, therefore the call is wrapped so that the request arguments and the reply is placed into tuples. :param method_name: The name of the method which call is requested by the gRPC server

create_server_streaming_method(method_name)[source]

Creating RPC request by a method name The gRPC methods are unary-unary, therefore the call is wrapped so that the request arguments and the reply is placed into tuples. :param method_name: The name of the method which call is requested by the gRPC server

stop_server()[source]

Disconnect from the server :rtype: bool :return: True if the server has been successfully stopped

static get_trusted_credentials()[source]

Get SSL credentails for secure communication

Return type

ChannelCredentials

check_connection(num_of_retries=3, timeout=2.0)[source]

Check the connection to the gRPC server :type num_of_retries: int :param num_of_retries: The number of retries to connect :type timeout: float :param timeout: The value of the timeout for a single trial in seconds :rtype: bool :return: True if the connection is established

ping()[source]

Check whether the server is alive

generate_sumo_scenario(scenario_name, scenario_path)[source]

Send one commonroad scenario to the server, and request to generate it to the required formats :type scenario_name: str :param scenario_name: The name of the scenario to be sent :type scenario_path: str :param scenario_path: The absolute path where the scenario can be found

Return type

AbstractScenarioWrapper

send_sumo_scenario(scenario_name, scenario_folder)[source]

Send previously generated scenario files to the server :type scenario_name: str :param scenario_name: The name of the scenario which will be sent :type scenario_folder: str :param scenario_folder: The absolute path to the folder containing the files to be sent

download_converted_scenarios(scenario_name, output_directory)[source]

Download generated scneario files from the server :type scenario_name: str :param scenario_name: The name of the scenario to be downloaded :type output_directory: str :param output_directory: Absolute path to the directory where the downloaded scenario should be placed

reset_simulation()[source]

Resets SumoSimulation.

property current_time_step: int
Return type

int

Returns

current time step of interface

property ego_vehicles: Dict[int, sumocr.interface.ego_vehicle.EgoVehicle]
Return type

Dict[int, EgoVehicle]

Returns

the ego vehicles of the current simulation.

property dt
Returns

dt of the simulation

property planning_problem_set
Returns

planning_problem_set of the simulation

property dummy_ego_simulation
Returns

planning_problem_set of the simulation

property obstacle_states
Returns

obstacle_states of the simulation

property simulationdomain
Returns

simulationdomain of the simulation

property vehicledomain
Returns

vehicledomain of the simulation

property routedomain
Returns

routedomain of the simulation

property ids_sumo2cr
Returns

ids_sumo2cr of the simulation

property ids_cr2sumo
Returns

ids_cr2sumo of the simulation

property obstacle_shapes
Returns

obstacle_shapes of the simulation

property obstacle_types
Returns

obstacle_types of the simulation

property scenarios
Returns

example_scenarios of the simulation

property conf
Returns

example_scenarios of the simulation

property lateral_position_buffer
Returns

example_scenarios of the simulation

initialize(conf, scenario_wrapper, planning_problem_set=None)[source]

Reads scenario files, starts traci simulation, initializes vehicles, conducts pre-simulation.

Parameters
  • conf (DefaultConfig) – configuration object. If None, use default configuration.

  • scenario_wrapper (AbstractScenarioWrapper) – handles all files required for simulation.

  • start_logging – if logging was initialized before, set Falseconf

Return type

None

init_ego_vehicles_from_planning_problem(planning_problem_set)[source]

Initializes the ego vehicles according to planning problem set.

Parameters

planning_problem_set (PlanningProblemSet) – The planning problem set which defines the ego vehicles.

Return type

None

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

Plots commonroad road network without vehicles or obstacles.

Parameters
  • with_lane_id – if set to true, the lane id will also be printed.

  • with_succ_pred – if set to true, the successor and predecessor lanelets will be printed.

  • with_adj – if set to true, adjacant lanelets will be printed.

  • with_speed – if set to true, the speed limit will be printed.

commonroad_scenario_at_time_step(time_step, add_ego=False, start_0=True)[source]

Creates and returns a commonroad scenario at the given time_step. Initial time_step=0 for all obstacles. :type time_step: int :param time_step: the scenario will be created according this time step. :param add_ego: whether to add ego vehicles to the scenario. :param start_0: if set to true, initial time step of vehicles is 0, otherwise, the current time step

Return type

Scenario

commonroad_scenarios_all_time_steps(lanelet_network=None)[source]

Creates and returns a commonroad scenario with all the dynamic obstacles. :type lanelet_network: Optional[LaneletNetwork] :param lanelet_network: :rtype: Scenario :return: list of cr example_scenarios, list of cr example_scenarios with ego, list of planning problem sets)

simulate_step()[source]

Executes next simulation step (consisting of delta_steps sub-steps with dt_sumo=dt/delta_steps) in SUMO

Return type

None

get_ego_obstacles(time_step=None)[source]

Get list of ego vehicles converted to Dynamic obstacles :type time_step: Optional[int] :param time_step: initial time step, if None, get complete driven trajectory :rtype: List[DynamicObstacle] :return:

stop()[source]

Exits SUMO Simulation

Return type

None

check_lanelets_future_change(current_state, planned_traj)[source]

Checks the lanelet changes of the ego vehicle in the future time_window.

Parameters
  • lanelet_network – object of the lanelet network

  • time_window – the time of the window to check the lanelet change

  • traj_index – index of the planner output corresponding to the current time step

Return type

Tuple[str, int]

Returns

lc_status, lc_duration: lc_status is the status of the lanelet change in the next time_window; lc_duration is the unit of time steps (using sumo dt)