Git Product home page Git Product logo

commonroad / commonroad-scenario-designer Goto Github PK

View Code? Open in Web Editor NEW
25.0 2.0 9.0 114.11 MB

Toolbox for Map Conversion and Scenario Creation for Autonomous Vehicles.

Home Page: https://commonroad.in.tum.de/tools/scenario-designer

License: GNU General Public License v3.0

Python 68.18% Jupyter Notebook 31.76% ANTLR 0.06%
autonomous-driving autonomous-vehicles commonroad gui lanelet2 motion-planning motion-planning-scenario opendrive openstreetmap osm

commonroad-scenario-designer's Introduction

CommonRoad Scenario Designer

PyPI pyversions
Linux
PyPI version fury.io PyPI download week PyPI download month
PyPI license

This toolbox provides map converters for OpenStreetMap (OSM), Lanelet / Lanelet2, OpenDRIVE, and SUMO to the CommonRoad (CR) format and for some formats vice versa.
Additionally, a graphical user interface (GUI) is included, which allows one to efficiently create and manipulate CommonRoad maps and scenarios.

Tool Path Functionality
OpenDRIVE => CR crdesigner/map_conversion/opendrive Conversion from OpenDRIVE to CommonRoad.
Lanelet/Lanelet2 <=> CR crdesigner/map_conversion/lanelet2 Conversion from Lanelet2 to CommonRoad
and from CommonRoad to Lanelet
OSM => CR crdesigner/map_conversion/osm2cr Conversion from OSM to CommonRoad.
SUMO <=> CR crdesigner/map_conversion/sumo_map Conversion from SUMO to CommonRoad and vice versa.
OpenDRIVE => Lanelet/Lanelet2 crdesigner/map_conversion/map_conversion_interface Conversion from OpenDRIVE to Lanelet2
Map Verification and Repairing crdesigner/verification_repairing Verification and Repairing of CommonRoad maps.
CR Scenario Designer GUI crdesigner/ui/gui Multi-functional GUI for map conversion and scenario creation/editing.

Prerequisites and Installation

We have tested the toolbox with Python 3.8, 3.9, and 3.10. The toolbox should work under Linux, macOS, and Windows. Below we present two ways of installing the CommonRoad Scenario Designer:

  • Only using the CommonRoad Scenario Designer, e.g.,the GUI or integrating the scenario designer APIs into your code
  • Developing code for the CommonRoad Scenario Designer

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

Development

First, clone the repository. The usage of Poetry is recommended. Poetry can be installed using:

curl -sSL https://install.python-poetry.org | python3 -

Create a new Python environment:

poetry shell
poetry install --with tests,docs,tutorials

We recommend to use PyCharm (Professional) as IDE.

Common Errors during installation

Ubuntu

  • 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

Usage

We provide different types of usage for the CommonRoad Scenario Designer. Subsequently, we present for each component the different usage methods.

GUI

GUI_Screenshot

The recommended aspect ratio is 16:9 with a scaling of 100%. Within the GUI, you can also execute the different converters. The GUI can either be activated via a Python API, command line, or executing a Python script.

Python Script

First you need to activate your python environment with the installed dependencies.
Afterward, you can start the CommonRoad Scenario Designer and the GUI will open:

$ python crdesigner/ui/gui/start_gui.py

Command Line

The GUI can be started from 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.
You can also execute a map conversion via the commandline interface, e.g.,
crdesigner --input-file /input/path/l2file.osm --output-file /output/path/crfile.xml lanelet2cr.
The output of crdesigner --help looks as follows:

Usage: crdesigner [OPTIONS] COMMAND [ARGS]...

  Toolbox for Map Conversion and Scenario Creation for Autonomous Vehicles

Options:
  --input-file PATH               Path to OpenDRIVE map
  --output-file PATH              Path where CommonRoad map should be stored
  --force-overwrite / --no-force-overwrite
                                  Overwrite existing CommonRoad file
                                  [default: force-overwrite]
  --author TEXT                   Your name
  --affiliation TEXT              Your affiliation, e.g., university, research
                                  institute, company
  --tags TEXT                     Tags for the created map
  --install-completion [bash|zsh|fish|powershell|pwsh]
                                  Install completion for the specified shell.
  --show-completion [bash|zsh|fish|powershell|pwsh]
                                  Show completion for the specified shell, to
                                  copy it or customize the installation.
  --help                          Show this message and exit.

Commands:
  crlanelet2
  crsumo
  gui
  lanelet2cr
  odrcr
  osmcr
  sumocr
  odrlanelet2`

Map Converters

You can execute the different converters either via command line, calling them within your Python program via an API, or the GUI.

API

The main APIs to execute the pure conversions are located under crdesigner/map_conversion/map_conversion_interface.py.
For many conversions we provide further APIs, e.g., for downloading a map from OSM.

GUI

The GUI provides a toolbox with which contains functionality to load maps given in formats other the CommonRoad format
and to convert CommonRoad maps to other formats or the other formats to the CommonRoad format.

Saving Video

Provides the functionality to save the animation of the scenario as a mp4 file.

For error: "MovieWriter ffmpeg unavailable; using Pillow instead." try to install ffmpeg. This should solve the problem.

sudo apt-install ffmpeg

Important information

When converting OSM maps, missing information such as the course of individual lanes is estimated during the process.
These estimations are imperfect (the OSM maps as well) and often it is advisable to edit the scenarios by hand via the GUI.

Tutorials

We also provide tutorials demonstrating how the different map converter APIs can be used.
The tutorials include a jupyter notebook and exemplary Python scripts for each conversion.

Documentation

To generate the documentation from source, first install the necessary dependencies with pip:

cd docs/source && sphinx-build -b html . ../../public

The documentation can be accessed by opening public/index.html.
The titles of module pages have to be set manually!
The full documentation of the API and introducing examples can also be found here.

Changelog

A detailed overview about the changes in each version is provided in the Changelog.

Bug and feature reporting

This release (v0.8.9) is still a BETA version.
In case you detect a bug or you want to suggest a new feature, please report it in our forum.
If you want to contribute to the toolbox, you can also post it in the forum or contact Sebastian Maierhofer.

Authors

Responsible: Sebastian Maierhofer, Sebastian Mair
Contribution (in alphabetic order by last name): Daniel Asch, Hamza Begic, Mohamed Bouhali, Florian Braunmiller, Tim Dang, Behtarin Ferdousi, Maximilian Fruehauf, Marcus Gabler, Fabian Hoeltke, Tom Irion, Aaron Kaefer, Anton Kluge, David Le, Gustaf Lindgren, Sarra Ben Mohamed, Benjamin Orthen, Luisa Ortner, Louis Pröbstle, Benedikt Reinhard, Maximilian Rieger, Til Stotz, Stefan Urban, Max Winklhofer

Credits

We gratefully acknowledge partial financial support by

  • DFG (German Research Fundation) Priority Program SPP 1835 Cooperative Interacting Automobiles
  • BMW Group within the Car@TUM project
  • Central Innovation Programme of the German Federal Government under grant no. ZF4086007BZ8

Citation

If you use our code for research, please consider to cite our papers:

@inproceedings{Maierhofer2023,
	author = {Maierhofer, Sebastian and  Ballnath, Yannick and  Althoff, Matthias},
	title = {Map Verification and Repairing Using Formalized Map Specifications},
	booktitle = {2023 IEEE International Conference on Intelligent Transportation Systems (ITSC)},
	year = {2023},
	pages = {},
	abstract = {Autonomous vehicles benefit from correct maps to participate in traffic safely, but often maps are not verified before their usage. 
                    We address this problem by providing an approach to verify and repair maps automatically based on a formalization of map specifications in higher-order logic. 
                    Unlike previous work, we provide a collection of map specifications. 
                    We can verify and repair all possible map parts, from geometric to semantic elements, e.g., adjacency relationships, lane types, road boundaries, traffic signs, and intersections. 
                    Due to the modular design of our approach, one can integrate additional logics. 
                    We compare ontologies, answer set programming, and satisfiability modulo theories with our higher-order logic verification algorithm. 
                    Our evaluation shows that our approach can efficiently verify and repair maps from several data sources and of different map sizes. 
                    We provide our tool as part of the CommonRoad Scenario Designer toolbox available at commonroad.in.tum.de.},
}
@inproceedings{Maierhofer2021,
	author = {Sebastian Maierhofer, Moritz Klischat, and Matthias Althoff},
	title = {CommonRoad Scenario Designer: An Open-Source Toolbox for Map Conversion and Scenario Creation for Autonomous Vehicles},
	booktitle = {Proc. of the IEEE Int. Conf. on Intelligent Transportation Systems },
	year = {2021},
	pages = {3176-3182},
	abstract = {Maps are essential for testing autonomous driving functions. Several map and scenario formats are 
                    available. However, they are usually not compatible with each other, limiting their usability.  
                    In this paper, we address this problem using our open-source toolbox that provides map converters  
                    from different formats to the well-known CommonRoad format. Our toolbox provides converters for 
                    OpenStreetMap, Lanelet/Lanelet2, OpenDRIVE, and SUMO. Additionally, a graphical user interface is 
                    included, which allows one to efficiently create and manipulate CommonRoad maps and scenarios. 
                    We demonstrate the functionality of the toolbox by creating CommonRoad maps and scenarios based on 
                    other map formats and manually-created map data.},
}

If you use the OpenDRIVE to CommonRoad conversion for your paper, please consider to additionally cite the corresponding paper:

@inproceedings{Althoff2018b,
	author = {Matthias Althoff and Stefan Urban and Markus Koschi},
	title = {Automatic Conversion of Road Networks from OpenDRIVE to Lanelets},
	booktitle = {Proc. of the IEEE International Conference on Service Operations and Logistics, and Informatics},
	year = {2018},
	pages = {157--162},
	abstract = {Detailed road maps are an important building block for autonomous driving. They accelerate creating a 
	            semantic environment model within the vehicle and serve as a backup solution when sensors are occluded 
	            or otherwise impaired. Due to the required detail of maps for autonomous driving and virtual test 
	            drives, creating such maps is quite labor-intensive. While some detailed maps for fairly large regions 
	            already exist, they are often in different formats and thus cannot be exchanged between companies and 
	            research institutions. To address this problem, we present the first publicly available converter from
	            the OpenDRIVE format to lanelets—both representations are among the most popular map formats. 
	            We demonstrate the capabilities of the converter by using publicly available maps.},
}

commonroad-scenario-designer's People

Contributors

abhijay-kemkar avatar adscib avatar ankaret avatar antonkluge avatar fabianh001 avatar florian-fi avatar florianbraunmiller avatar ga42vuz avatar geraldfw avatar ishita-a avatar jingtianweidizzf avatar jrester avatar loproe avatar luisa47o avatar mairbasti avatar marcug avatar matze99 avatar maxwinklh2908 avatar mo-kli avatar nielstron avatar niratheb avatar peter-kocsis avatar rasaford avatar rhosss avatar ryanzbt avatar smaierhofer avatar svpfla avatar tomirion avatar yosrnebli avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

commonroad-scenario-designer's Issues

matplotlib version mismatch maybe?

Hi,
WSL2 ubuntu on windows 10. Python 3.9. Matplotlib 3.9.1
installed using pip.
I am wondering if this is a matplotlib version mismatch issue...

Error ->

camlab@DESKTOP-3LSSKO5:~$ crdesigner gui

Traceback (most recent call last):
  File "/home/camlab/.pyenv/versions/3.9.19/bin/crdesigner", line 5, in <module>
    from crdesigner.ui.command_line import cli
  File "/home/camlab/.pyenv/versions/3.9.19/lib/python3.9/site-packages/crdesigner/ui/command_line.py", line 12, in <module>
    from crdesigner.common.file_reader import CRDesignerFileReader
  File "/home/camlab/.pyenv/versions/3.9.19/lib/python3.9/site-packages/crdesigner/common/file_reader.py", line 11, in <module>
    from crdesigner.verification_repairing.map_verification_repairing import (
  File "/home/camlab/.pyenv/versions/3.9.19/lib/python3.9/site-packages/crdesigner/verification_repairing/map_verification_repairing.py", line 15, in <module>
    from crdesigner.verification_repairing.drawing.invalid_states.invalid_states_drawer import (
  File "/home/camlab/.pyenv/versions/3.9.19/lib/python3.9/site-packages/crdesigner/verification_repairing/drawing/invalid_states/invalid_states_drawer.py", line 15, in <module>
    from commonroad.visualization.mp_renderer import MPRenderer
  File "/home/camlab/.pyenv/versions/3.9.19/lib/python3.9/site-packages/commonroad/visualization/mp_renderer.py", line 68, in <module>
    from commonroad.visualization.traffic_sign import draw_traffic_light_signs
  File "/home/camlab/.pyenv/versions/3.9.19/lib/python3.9/site-packages/commonroad/visualization/traffic_sign.py", line 8, in <module>
    from matplotlib.axes import Axes, mtext
ImportError: cannot import name 'mtext' from 'matplotlib.axes' (/home/camlab/.pyenv/versions/3.9.19/lib/python3.9/site-packages/matplotlib/axes/__init__.py)

Coordinate Conversion Error in OpenDrive -> Lanelet2

Hi,

I am trying to convert an example OpenDrive format to Lanelet2 format. Here is the file link.

The problem looks like in this entry in the CommonRoad forum. The GeoTransformation does not work correctly right now. I used to use this method in OSM -> Lanelet2 conversion.

What am I doing wrong? Is there any suitable branch in the repository?

This is the code that I am using:

import os
from lxml import etree
from crdesigner.common.config.lanelet2_config import lanelet2_config
from crdesigner.map_conversion.lanelet2.cr2lanelet import CR2LaneletConverter
from commonroad.scenario.scenario import Location, GeoTransformation
from crdesigner.map_conversion.map_conversion_interface import opendrive_to_commonroad
from pathlib import Path


input_path_str = "/home/ataparlar/temp_backup/crdesigner/import/opendrive_test_file_town.xodr"
input_path = Path(input_path_str)
output_lanelet2_path = "/home/ataparlar/projects/commonroad_project2/commonroad-scenario-designer/exports/opendrive_to_lanelet2_test.osm"
scenario = opendrive_to_commonroad(input_path)
georeference_string = "EPSG:3857"
location_geotransformation = GeoTransformation(georeference_string, 658761.0, 4542599.0, None, None)
scenario_location = Location(11, 41.0, 28.0, location_geotransformation, None)
scenario.location = scenario_location
if scenario:
    l2osm = CR2LaneletConverter(lanelet2_config)
    osm = l2osm(scenario)
    with open(output_lanelet2_path, "wb") as file_out:
        file_out.write(
            etree.tostring(
                osm, xml_declaration=True, encoding="UTF-8", pretty_print=True
        )
    )

Thank you for your supports

Ata Parlar

Lane change & speed limit attributes (lanelet2)

Hi,
I use CommonRoad tool for converting opendrive to Autoware's lanelet2 format.
I believe that CR currently does not provide a "lane_change" tag within the lanelet2 which is required for the AW system. Is this something that can be implemented?
Secondly, I have a speed limit specified in the opendrive file, which is not being converted to the lanelet2 format. Does CR convert the road speed limit?
Many thanks.

OpenDrive with Georeference in UTM Coordinates and offset

Dear Commonroad Team,

I'm trying to import an OpenDRIVE file that contains a Georeference in UTM with an offset. Below is an example.

<geoReference><![CDATA[+proj=utm +zone=32 +datum=WGS84 +units=m +no_defs +type=crs]]></geoReference>
<offset x="297133.4" y="5623440.5" z="0" hdg="0"/>

Unfortunately the conversion to CommonRoad and Lanelet does not work properly. The resulting lat and lon coordinates are: lat="-50.22711947744166" lon="-2.185895728757027".

Left hand traffic LHT opendrive conversion.

Hello,
My goal is to convert the LHT opendrive roadnetwork to the lanelet2 format (autoware compatible).
I'm using Python API for conversion.
Does CommonRoad support left hand traffic opendrive?
If yes, are there any specific configuration settings that need to be provided?

Many thanks for your help.

loss speed info when convert xodr to xml

loss speed info when convert xodr to xml (opendrive to commonroad)

in network.py no speed info

def convert_to_base_lanelet_network(lanelet_network: ConversionLaneletNetwork) -> LaneletNetwork:
"""Converts a ConversionLaneletNetwork to a LaneletNetwork.

:param lanelet_network: ConversionLaneletNetwork that should be converted to a LaneletNetwork.
:return: The converted LaneletNetwork.
"""
network = LaneletNetwork()
for inter in lanelet_network.intersections:
    network.add_intersection(inter)
for sign in lanelet_network.traffic_signs:
    network.add_traffic_sign(sign, set())
for light in lanelet_network.traffic_lights:
    network.add_traffic_light(light, set())
for la in lanelet_network.lanelets:
    network.add_lanelet(
        Lanelet(
            la.left_vertices,
            la.center_vertices,
            la.right_vertices,
            la.lanelet_id,
            la.predecessor,
            la.successor,
            la.adj_left,
            la.adj_left_same_direction,
            la.adj_right,
            la.adj_right_same_direction,
            la.line_marking_left_vertices,
            la.line_marking_right_vertices,
            la.stop_line,
            la.lanelet_type,
            la.user_one_way,
            la.user_bidirectional,
            la.traffic_signs,
            la.traffic_lights,
        )
    )
return network

Sumo to Lanelet2 Conversion Issue

Hi,
Our objective is to convert a SUMO map to Lanelet2 map, usually it will need to go through a process of sumo->opendrive->commonroad->lanelet2 map. However, after utilizing your pipeline, we noticed that the lane width in the resulting lanelet2 map is narrower than expected.

In an attempt to address this, we experimented with removing all longitude and latitude information from the original SUMO map. While this did improve the lane width in the final lanelet2 map, it led to inaccuracies in the overall scaling of the map. For instance, the radius of roundabouts in the lanelet2 map appeared significantly larger compared to the original SUMO map. Upon inspection, the lane width in the OpenDrive map appears to be correct.

We suspect that the issue may be related to the projection parameters, particularly because our required map is based in Michigan, USA. Despite our efforts to adjust the projection parameters to "NAD83" or set the UTM zone code to 17, the resulting map remains inaccurate. Now we don't know how to address this issue, and we are looking forward to your suggestion.

Many thanks for your help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.