Tutorial: Conversion of single OpenSCENARIO file to the CommonRoad format

This tutorial demonstrates how to use the converter to translate single OpenSCENARIO format to the CommonRoad scenarios.

Please make sure that you have correctly installed the package by following the README.md

In [ ]:
%matplotlib inline
%load_ext autoreload
%autoreload 2

import sys
sys.path.append("../")

import warnings
warnings.filterwarnings('ignore')
warnings.simplefilter('ignore')

from osc_cr_converter.utility.configuration import ConverterParams
from osc_cr_converter.converter.osc2cr import Osc2CrConverter

# ==== specify openscenario
scenario_path = '../scenarios/from_esmini/xosc/'
openscenario = 'pedestrian_collision.xosc'

# ==== build configuration
config = ConverterParams.load('../configurations/' + openscenario.replace('.xosc', '.yaml'))

# ==== initialize the converter
converter = Osc2CrConverter(config)

Conversion & Visualization

In [2]:
# ==== run conversion
scenario = converter.run_conversion(scenario_path + openscenario)
* Converting the OpenSCENARIO file: pedestrian_collision.xosc
*	 Map conversion takes 2.23 s
*	 Esmini simulation takes 0.02 s
*	 Other conversion tasks take 0.37 s
* pedestrian_collision is successfully converted 🏆!
# ===========  Conversion Statistics  =========== #
# Nr of obstacles: 2
# Scenario duration: 9.27 s
# the ego vehicle is kept 
# The ending cause SCENARIO_FINISHED_BY_SIMULATOR
# ============================================== #
In [3]:
# ==== plot converted results
from osc_cr_converter.utility.visualization import visualize_scenario
visualize_scenario(scenario, config)