This package implements the interface between the framework for motion planning of automated vehicles [CommonRoad_io](https://pypi.org/project/commonroad-io/) and the traffic simulator [SUMO](https://sumo.dlr.de). The interface is presented in detail in our [paper](https://mediatum.ub.tum.de/doc/1486856/344641.pdf)[1] and a documentation of the API can be found [here](https://commonroad.in.tum.de/static/docs/commonroad-sumo-interface/index.html).
This package implements the interface between the framework for motion planning of automated vehicles [CommonRoad_io](https://commonroad.in.tum.de/commonroad-io) and the traffic simulator [SUMO](https://sumo.dlr.de). The interface is presented in detail in our [paper](https://mediatum.ub.tum.de/doc/1486856/344641.pdf)[1].
# Prerequisites
The package is written in Python 3.7 and tested on Linux.
Install required packages:
```bash
cd sumo-interface
pip install-r requirements.txt
sudo apt-get install ffmpeg
```
And add the absolute path of `commonroad-sumo-interface` to your Python interpreter.
## Install SUMO
Clone a customized version of SUMO for smooth lane changes from https://github.com/octavdragoi/sumo and check out branch `smooth-lane-change`.
For installation we recommend building with (tested with Ubuntu 18.04):
For an example see: `example_files/minimal_example.py`
<!-- This is now in crmapconverter -->
<!-- ## Create .rou.xml files
.rou.xml files specify all vehicles for the simulation. An introduction can be found here: https://sumo.dlr.de/wiki/Tutorials/quick_start#Traffic_demand.
To use the interface for planning with ego vehicles, the vehicle ID in the .rou.xml file needs to start with the prefix `egoVehicle`.
A simple script to create .rou.xml files using https://sumo.dlr.de/wiki/Tools/Trip is implemented in the function
`ScenarioWrapper.recreate_route_file()`. See `example_scripts/create_scenario_files.py` for an example. -->
## Configure SUMO and sumo-interface
To use smooth lane changes, add
```xml
<processing>
<time-to-teleportvalue="-1"/>
<lanechange-outputvalue="output_lanechange.txt"/>
<lanechange.durationvalue="10"/>
<lanechange.smooth-changevalue="1"/>
</processing>
```
to the `.sumo.cfg` file of the scenario (activated by default for scenarios generated by the class `ScenarioWrapper`).
Further options for the interface can be found in the sumo-interface config file `config/default.py`.
## Minimal example for using the interface:
The file `example_scripts/minimal_example.py` gives an example how the interface can be integrated into an existing trajectory planner.
## Documentation
Please refer to [commonroad.in.tum.de/sumo-interface](https://commonroad.in.tum.de/sumo-interface) for the documentation and tutorials.
To run interactive scenarios, denoted by the suffix ```I```, from the CommonRoad database,
please use the script from the corresponding repository [gitlab.lrz.de/tum-cps/commonroad-interactive-scenarios](https://gitlab.lrz.de/tum-cps/commonroad-interactive-scenarios).
[1] _Moritz Klischat, Octav Dragoi, Mostafa Eissa, and Matthias Althoff, Coupling SUMO with a Motion Planning Framework for Automated Vehicles, SUMO 2019: Simulating Connected Urban Mobility_