Automatic traffic scenario conversion interface between OpenSCENARIO and the traffic simulator SUMO. Currently, only the conversion from OpenSCENARIO to CommonROAD (osc2cr) is developed.
This repo refers to
The code is written in Python 3.10 and has been tested on Ubuntu 22.04.
If you want to use the SUMO conversion or to generate traffic using SUMO, please install SUMO:
sudo apt-get update
sudo apt-get install sumo sumo-tools sumo-doc
echo "export SUMO_HOME=/usr/share/sumo" >> ~/.bashrc
echo 'export PYTHONPATH="$SUMO_HOME/tools:$PYTHONPATH"' >> ~/.bashrc
If you use zsh, replace .bashrc
with .zshrc
.
The recommended way of installation if you only want to use the scenario designer (i.e., you do not want to work with the code directly) is to use the PyPI package:
pip install commonroad-scenario-designer
- Could not load the Qt platform plugin “xcb” in “” even though it was found: Error seems to be a missing package - either libxkbcommon-x11 or libxcb-xinerama0 (both can be installed by
sudo apt install [package_name]
). See for reference here
The GUI can either be activated via the command line via the following two options:
$ crdesigner
$ crdesigner gui
Note that you have to activate first the Python environment in which the CommonRoad Scenario Designer is installed.
We recommend using Anaconda to manage your environment so that even if you mess something up, you can always have a safe and clean restart. A guide for managing Python environments with Anaconda can be found here.
- First, clone the repository.
- After installing Anaconda, create a new environment with (>=3.9) and enter it:
$ conda create -n commonroad-py39 python=3.9 -y
$ conda activate commonroad-py39
- Then, install the dependencies with:
$ pip install commonroad-openscenario-converter
- Test case:
$ cd Openscenario2Commonroad/test
$ python OSC_Convert2_CR.py
The generated simple curve scenario "OpenSCENRAIO2SUMO/output/SimpleCurve/OSC_SimpleCurve_1_T-1.xml" could be opened via the CommonRoad Scenario Designer.
Open the generated .xml file using the crdesigner GUI
There are some redundant roads generated from Openscenario to Commonroad. They are able to be removed in this GUI to achieve a better and more reasonable conversion to SUMO later.
Fist way: using crdesigner GUI
- Advantage: easy to operate
- Shortcoming: no clear error message when encountering an error
Second way: using the script
$ cd Commonroad2SUMO/tutorials/conversion_examples
$ python example_commonroad_to_sumo.py
- Advantage: clear error message when encountering an error
- Shortcoming: complicate to operate