CommonRoad Scenario Factory
The CommonRoad Scenario Factory is a toolbox that combines many different tools from the whole CommonRoad ecosystem to efficiently process CommonRoad scenarios. Its current main use case is the generation of new CommonRoad scenarios with the traffic simulators OpenTrafficSim (OTS) and SUMO.
Quick Start
Installation
The CommonRoad Scenario Factory is available on PyPI and can be easily installed with pip:
$ pip install commonroad-scenario-factory
Additional Requirements
Most required dependencies are already included, but some have to be installed manually on your system:
- Java Runtime Environment: Required for running simulations with OpenTrafficSim (OTS).
- osmium: Required for extracting segments from pre-downloaded OSM maps.
SUMO and OTS are distributed as python packages and included as dependencies. Therefore, they do not need to be installed separately.
Example Usage
This example will setup a basic scenario generation pipeline with SUMO and output new scenarios to /tmp/scenario-factory:
from pathlib import Path
from scenario_factory.globetrotter import Coordinates, OsmApiMapProvider, RegionMetadata
from scenario_factory.pipelines import (
create_globetrotter_pipeline,
create_scenario_generation_pipeline,
)
from scenario_factory.pipeline_steps import (
pipeline_add_metadata_to_scenario,
pipeline_simulate_scenario_with_sumo,
pipeline_assign_tags_to_scenario,
pipeline_write_scenario_to_file,
)
from scenario_factory.scenario_config import ScenarioFactoryConfig
from scenario_factory.simulation import SimulationConfig, SimulationMode
radius = 0.1
seed = 5678
simulation_steps = 500
cr_scenario_time_steps = 50
coords_str = "48.2570465,11.6580003"
output_path = Path("/tmp/scenario-factory")
output_path.mkdir(exist_ok=True)
map_provider = OsmApiMapProvider()
simulation_config = SimulationConfig(
mode=SimulationMode.RANDOM_TRAFFIC_GENERATION,
simulation_steps=simulation_steps,
seed=seed,
)
scenario_config = ScenarioFactoryConfig(
seed=seed, cr_scenario_time_steps=cr_scenario_time_steps, source="example"
)
base_pipeline = (
create_globetrotter_pipeline(radius, map_provider)
.map(pipeline_add_metadata_to_scenario)
.map(pipeline_simulate_scenario_with_sumo(simulation_config))
)
scenario_generation_pipeline = create_scenario_generation_pipeline(
scenario_config.criterions, scenario_config.filters
)
pipeline = (
base_pipeline.chain(scenario_generation_pipeline)
.map(pipeline_assign_tags_to_scenario)
.map(pipeline_write_scenario_to_file(output_path))
)
coordinates = Coordinates.from_str(coords_str)
region = RegionMetadata.from_coordinates(coordinates)
print(f"Starting scenario generation for coordinates {coords_str}.")
result = pipeline.execute([region], num_threads=2, num_processes=2)
result.print_cum_time_per_step()
print(f"Generated {len(result.values)} scenario(s) at {output_path}.")
Documentation
The full documentation can be found at cps.pages.gitlab.lrz.de/commonroad/scenario-factory.
Metadata
Release files for commonroad-scenario-factory 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| commonroad_scenario_factory-2.1.0.tar.gz | 91.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| commonroad_scenario_factory-2.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 216.6 kB
Release files / commonroad_scenario_factory-2.1.0.tar.gz
| Download URL | commonroad_scenario_factory-2.1.0.tar.gz |
|---|---|
| Size | 91.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9ac044275eba8eaffb4e7c9c23660e99b60fbb468d4eac808ffd538d54e45928
|
|
BLAKE2b-256 checksum How to use checksums |
47602ed7dabef33026311895b33c98cdd05f9d2acc96b1126db52b834b0edf48
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.10.18 Linux/5.15.0-87-generic
|
Release files / commonroad_scenario_factory-2.1.0-py3-none-any.whl
| Download URL | commonroad_scenario_factory-2.1.0-py3-none-any.whl |
|---|---|
| Size | 125.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
334c073a9148a02a40806aa1e47293320559ccc27d26c06fb1424f2fca8f190a
|
|
BLAKE2b-256 checksum How to use checksums |
4e35e7f0729a81ab0318fba9e446046e20f957c8a887ef6c1373c1f5947ae151
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.10.18 Linux/5.15.0-87-generic
|