Interface between CommonRoad and the traffic simulator OpenTrafficSim (OTS).
It allows you to simulate CommonRoad scenarios with different abstraction levels (i.e. resimulation, delay, demand, infrastructure, random) in OTS and get the results as CommonRoad scenarios.
The interface is available on PyPI and can easily be installed:
$ pip install commonroad-otsAdditionally, a working java installation is required to execute OTS. For Ubuntu you can use:
$ apt-get update && apt-get install -y default-jdkOTS itself is distributed as a python package and included as a dependency of this package. Therefore, no separate installation is necessary.
The following example shows how to resimulate a given CommonRoad scenario:
from pathlib import Path
from commonroad.common.file_reader import CommonRoadFileReader
from commonroad_ots.conversion.main import Conversion
from commonroad_ots.abstractions.abstraction_level import AbstractionLevel
from commonroad_ots.abstractions.simulation_execution import SimulationExecutor
# Load recorded scenario
scenario_path = Path("/path/to/commonroad/scenario.xml")
scenario_rec, _ = CommonRoadFileReader(scenario_path).open()
# Setup and execute simulation
executor = SimulationExecutor(scenario_rec, AbstractionLevel.RESIMULATION, False, dict(), 1234, False, False)
scenario_new, _, _, _, _ = executor.execute()The full documentation of the API and introductory examples can be found at cps.pages.gitlab.lrz.de/commonroad/cr-ots-interface.