Metadata-Version: 2.3
Name: commonroad-ots
Version: 2025.1
Summary: Coupling CommonRoad and OpenTrafficSim.
License: BSD-3-Clause
Author: Christoph Thees
Author-email: christoph.thees@tum.de
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: JPype1 (>=1.5.0,<2.0.0)
Requires-Dist: commonroad-io (>=2023.4)
Requires-Dist: dtaidistance (>=2.3.11,<3.0.0)
Requires-Dist: matplot2tikz (>=0.3.3,<0.4.0)
Requires-Dist: matplotlib (>=3.7.0,<4.0.0)
Requires-Dist: networkx (>=3.2.1,<4.0.0)
Requires-Dist: numpy (>=1.26.1) ; python_version < "3.13"
Requires-Dist: numpy (>=2.1.0) ; python_version >= "3.13"
Requires-Dist: opentrafficsim (==1.7.5)
Requires-Dist: pandas (>=2.2.1,<3.0.0)
Requires-Dist: pyperclip (>=1.8.2,<2.0.0)
Requires-Dist: scipy (>=1.12.0,<2.0.0)
Requires-Dist: shapely (>=2.0.3,<3.0.0)
Description-Content-Type: text/markdown

# CommonRoad - OpenTrafficSim Interface

[![PyPI pyversions](https://img.shields.io/pypi/pyversions/commonroad-ots.svg)](https://pypi.python.org/pypi/commonroad-ots/)
[![PyPI version fury.io](https://badge.fury.io/py/commonroad-ots.svg)](https://pypi.python.org/pypi/commonroad-ots/)
[![PyPI download week](https://img.shields.io/pypi/dw/commonroad-ots.svg?label=PyPI%20downloads)](https://pypi.python.org/pypi/commonroad-ots/)
[![PyPI download month](https://img.shields.io/pypi/dm/commonroad-ots.svg?label=PyPI%20downloads)](https://pypi.python.org/pypi/commonroad-ots/)
[![PyPI license](https://img.shields.io/pypi/l/commonroad-ots.svg)](https://pypi.python.org/pypi/commonroad-ots/)


Interface between [CommonRoad](commonroad.in.tum.de) and the traffic simulator [OpenTrafficSim (OTS)](opentrafficsim.org).

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.

## Quick Start

### Installation

The interface is available on PyPI and can easily be installed:

```bash
$ pip install commonroad-ots
```

Additionally, a working java installation is required to execute OTS. For Ubuntu you can use:
```bash
$ apt-get update && apt-get install -y default-jdk
```

OTS itself is distributed as a [python package](https://pypi.org/project/opentrafficsim/) and included as a dependency of this package. Therefore, no separate installation is necessary.


### Example Usage

The following example shows how to resimulate a given CommonRoad scenario:

```python
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()
```

## Documentation

The full documentation of the API and introductory examples can be found at [cps.pages.gitlab.lrz.de/commonroad/cr-ots-interface](https://cps.pages.gitlab.lrz.de/commonroad/cr-ots-interface).

