cohydra.mobility_input.sumo

SUMO co-simulation.

Classes

RPCServer

SUMOMobilityInput

SUMOMobilityInput is an interface to the SUMO simulation environment.


class cohydra.mobility_input.sumo.RPCServer(connection_details)[source]

Bases: object

run()[source]
class cohydra.mobility_input.sumo.SUMOMobilityInput(name='SUMO External Simulation', steps=1000, sumo_host='localhost', sumo_port=8813, sumo_cmd='sumo', config_path=None, step_length=1, rpc_server=None)[source]

Bases: cohydra.mobility_input.mobility_input.MobilityInput

SUMOMobilityInput is an interface to the SUMO simulation environment.

This mobility input supports two modes:

  • Remote Mode: In this mode the testbed connects to an external already running SUMO instance.
    You configure the host and port where the SUMO server is running via the sumo_host and sumo_port argument.
  • Local Mode: In this mode the testbed starts a locally installed version of SUMO.
    You configure the simulation via the sumo_cmd and config_path argument. If SUMO is not installed globally you need to set the SUMO_HOME environment variable.
    Warning: This does not work when using cohydra in the prebuilt docker containers. For instructions on how to use cohydra without Docker, please refer to Local Installation Without Docker and Install SUMO On Simulation Host.
Parameters
  • name (str) – The name of the MobilityInput.

  • steps (int) – The number of steps to run the SUMO simulation.

  • sumo_host (str) – The host on which the SUMO simulation is running.

  • sumo_port (int) – The TraCI port.

  • sumo_cmd (str) – The command to start sumo when using the local mode (default: sumo).

  • config_path (str) – The path to the simulation configuration (.cfg).

  • steplength (float) – The length of each simulation step in seconds (default: 1). It only has effect in the local mode.

  • rpc_server (tuple) – Starts a rpc server if value is not None. The tuple needs two elements: (ip, port).

sumo_host = None

The host on which the SUMO simulation is running.

When running on a devcontainer, this is probably localhost.

sumo_port = None

The TraCI port.

Can be specified on the server with the --remote-port option.

sumo_cmd = None

The command to start sumo locally

config_path = None

The path to the simulation scenario configuration.

steps = None

The number of steps to simulate.

step_length = None

The length of every simulation step

step_counter = None

The number of steps to simulate in SUMO.

rpc_server = None

The connection details of the RPC server

prepare(simulation)[source]

Connect to SUMO server.

start()[source]

Start a thread stepping through the sumo simulation.

add_node_to_mapping(node, sumo_vehicle_id, obj_type='vehicle')[source]
destroy()[source]

Stop SUMO.

Inheritance Diagramm

Inheritance diagram of cohydra.mobility_input.sumo