/OpenSCENARIO2SUMO_unuse

Automatic traffic scenario conversion interface between OpenSCENARIO and the traffic simulator SUMO

Primary LanguagePython

OpenSCENARIO2SUMO

Automatic traffic scenario conversion interface between OpenSCENARIO and the traffic simulator SUMO. Currently, only the conversion from OpenSCENARIO to CommonROAD (osc2cr) is developed.

Code Reference

This repo refers to

  1. Commonroad Scenario Designer
  2. CommonROAD-OpenSCENARIO Converter

Requirements

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.

Using the CommonRoad Scenario Designer

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

Common Errors during installation

  • 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

GUI Usage

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.

Openscenario to Commonroad Converter

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.

pics/src2cr.png

Open Commonroad file with crdesigner GUI

Open the generated .xml file using the crdesigner GUI

pics/openfileGUI.png

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. pics/circle.png

Commonroad to SUMO conversion

Fist way: using crdesigner GUI

pics/coversion2SUMO.png

  • 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

pics/sumo.png

Paper Reference

  1. CommonRoad Scenario Designer: An Open-Source Toolbox for Map Conversion and Scenario Creation for Autonomous Vehicles
  2. Automatic Traffic Scenario Conversion from OpenSCENARIO to CommonRoad