OSC2 Language Overview
OpenSCENARIO 2 (OSC2) is a scenario description language defined by the ASAM standard, used to describe traffic scenarios and test cases in autonomous driving simulations.
Scenario File Structure
A typical OSC2 scenario file consists of import declarations, type definitions, entity declarations, and scenario definitions.
Basic Concepts
- Physical Quantities: OSC2 has a built-in complete physical quantity system supporting speed, distance, time, angle, and other physical quantities with units
- Entities: Participants in the scenario, such as vehicles, pedestrians, etc.
- Actions: Actions performed by entities, such as accelerating, changing lanes, etc.
- Events: Sequences of events that occur in the scenario
Complete Example
import std.base
scenario highway_merge:
do serial:
ego: vehicle with:
speed: 72 km/h
position: lane at(1, 0, 0) of Highway_1
merge: vehicle with:
speed: 54 km/h
position: lane at(0, 0, 0) of Ramp_1
parallel:
ego.drive(duration: 10s)
merge.change_lane(to: Highway_1, at: 5s)