Compiling OpenSCENARIO 2.1 for Scenario-Based Testing in CARLA

Thoshitha Gamage, Lasanthi Gamage · 2026

Read Compiling OpenSCENARIO 2.1 for Scenario-Based Testing in CARLA by Thoshitha Gamage, Lasanthi Gamage (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2604-16452.txt.

Introduction

Gamage and Gamage build a compiler that turns OpenSCENARIO 2.1 driving scenes into runnable behavior in the CARLA simulator. A multi-pass pipeline parses the scene language, checks its meaning, and builds fixed behavior trees, mapping the standard domain directly to CARLA procedures through a custom registry. That design removes the need for outside logic solvers. A demo with a multi-actor cut-in and evasive move shows it handling actions at once, changing math terms and signals sent at odd times, setting a base for large, repeatable scene testing.

Catalog record

CREATORThoshitha Gamage, Lasanthi Gamage
YEAR2026
COLLECTIONPAPERS
FORMATTXT
FILE SIZE33530
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2604.16452

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Compiling OpenSCENARIO 2.1 for Scenario-Based Testing in CARLA Thoshitha Gamage, Lasanthi Gamage Abstract While the ASAM OpenSCENARIO 2.1 Domain-Specific Language (DSL) enables declarative, intent-driven authoring for Scenario-Based Testing (SBT), its integration into open-source simulators like CARLA remains limited by legacy parsers. We propose a multi-pass modern compiler architecture that translates the OpenSCENARIO 2.1 DSL directly into executable CARLA behaviors. The pipeline features an ANTLR4 frontend for Abstract Syntax Tree (AST) generation, a semantic middle-end, and a runtime backend that synthesizes deterministic py_trees behavior trees. Mapping the standardized domain ontology directly to CARLA’s procedural API via a custom method registry eliminates the need for external logic solvers. A demonstrative multi-actor cut-in and evasive maneuver, selected from a wider suite of validated scenarios, confirms the compiler’s ability to process concurrent actions, dynamic mathematical expressions, and asynchronous signaling. This framework establishes a functional baseline for reproducible, large-scale SBT, paving the way for future C++ optimizations to mitigate current Python-based computational overhead. 1 Introduction The transition toward highly automated and autonomous vehicles necessitates a paradigm shift in verification and validation methodologies. Relying on traditional, distance-based field tests to uncover safety-critical edge cases is economically infeasible and statistically insufficient 10 . Consequently, the industry has widely adopted Scenario-Based Testing (SBT), a paradigm that accelerates evaluation by systematically isolating and simulating complex traffic interactions within high-fidelity virtual simulation environments like CARLA 7 . SBT demands a standardized, machine-readable language capable of describing these interactions with both precision and flexibility. Historically, the industry relied on ASAM’s (Association for Standardization of Automation and Measuring Systems) de facto standard for interoperability: ASAM OpenSCENARIO XML 1.x 1 . While this XML schema is optimized for defining predictable trajectory playback, it forces a trade-off between expressive flexibility and maintainability as scenario complexity grows. To address this, ASAM bifurcated the standard by releasing ASAM OpenSCENARIO Domain Specific Language (DSL) standard. The first version (v2.0) was released in July 2020 and a more mature and a comprehensive version (v2.1) was released in March 2024 2 1 1 1 Since finalizing OpenSCENARIO v2.1 standard, ASAM continues to refine the DSL, currently fielding public reviews for the 2.2.0 release candidate as of early 2026. However, v2.1 remains the foundational finalized library supported by this architecture. . The DSL standard introduces a human-readable, declarative syntax that enables intent-driven scenario authoring. It allows researchers to express complex maneuvers as reusable, parameterized logic across abstract, logical, and concrete layers, significantly reducing boilerplate. Table 1 provides a comparison between these two standards to highlight this point. Table 1: Comparison of OpenSCENARIO v1.3 (XML) and v2.1 (DSL) Feature OSC 1.3 (XML) OSC 2.1 (DSL) Format Schema-based (XML) Text-based DSL (EBNF) Hierarchy Storyboard \rightarrow Act \rightarrow Maneuver \rightarrow Event \rightarrow Action Declarative, intent-driven structure Logic Trigger-based conditions Full expressions, conditions, and logic Parameterization Parameters and catalogs Native variables and reusable abstractions Modularity Limited reuse via catalogs High modularity and composability Behavior Modeling Explicit action definitions Actions + Modifiers + Conditions separation Semantic Validation Syntax (XSD) only Supports ontology-based semantic validation Readability Verbose ( \sim 150–300 lines) Concise ( \sim 20–50 lines) Integration Widely supported in tools Requires DSL parser/compiler, limited support Execution Model Event-driven storyboard execution Intent-driven, composable execution model Extensibility Limited High (DSL + custom constructs) Integrating the OpenSCENARIO DSL into established open-source engines, nonetheless, has revealed a substantial implementation gap. Widely used orchestration frameworks, such as ScenarioRunner 6 , which operate on top of simulation engines like CARLA, historically provided only partial support. Furthermore, most existing implementations lack a robust compiler for the finalized OpenSCENARIO v2.1 specification. Within these frameworks, the legacy interpreters utilize brittle parsing architectures that trigger syntax errors when attempting to ingest the bifurcated, finalized standard libraries (types.osc and domain.osc). The net result is the inability to leverage the full expressive power of the finalized DSL for research and industrial-grade scenario validation. This paper addresses this bottleneck by presenting a fully compliant OpenSCENARIO v2.1 compiler architecture integrated directly with the CARLA/ScenarioRunner environment. Our work utilizes ANTLR4 13 to implement an EBNF-driven compiler. This multi-stage system generates an Abstract Syntax Tree (AST) that ensures type safety and semantic validity, ultimately mapping domain modifiers to CARLA’s atomic behaviors through deterministic Behavior Trees (py_trees). The following sections detail a three-stage compiler architecture and outline the simulation ontology features supported by the implementation. Furthermore, a complete scenario file is provided to demonstrate a functional example of these features in practice. 2 Related Work Figure 1 : The 3-stage OSC2 Execution Pipeline mapping DSL definitions to CARLA behaviors. The OpenSCENARIO DSL formalization joins an expanding body of research into domain-specific languages for autonomous driving. It complements existing frameworks like the probabilistic Scenic 8 , the map-centric GeoScenario 14 , and testing-focused DSLs such as Paracosm 12 . These approaches offer complementary strengths, including stochastic scenario generation, high-fidelity geographic modeling, and parameterized test case design. However, they are typically developed as standalone frameworks and often lack standardized semantics, limiting interoperability across tools and simulation platforms. In contrast, the OpenSCENARIO DSL aim to unify scenario representation through a declarative DSL that integrates spatial , temporal , and behavioral semantics within a single framework. The OpenSCENARIO v2.1 standardizes many of these concepts, introducing composition operators for orchestrating complex multi-actor interactions and enabling the specification of Key Performance Indicators (KPIs) directly within scenario definitions 2 . Furthermore, it is designed to interoperate with complementary standards in the ASAM OpenX ecosystem, such as OpenDRIVE and OpenLABEL, and can be integrated with simulation ontologies to support semantic reasoning about physical feasibility and domain-specific constraints. Parsing OpenSCENARIO DSL grammar into an Abstract Syntax Tree (AST) relies heavily on modern ANTLR4-based lexical analyzers, most notably the community-driven py-osc2 framework 11 . Once parsed, translating this declarative logic into continuous simulation execution is a critical bottleneck. RoadLogic 3 proposes translating the OpenSCENARIO DSL into a symbolic automaton representation, utilizing Answer Set Programming (ASP) to solve high-level planning constraints before passing them to a motion planner. While logically rigorous, this approach introduces the computational overhead of an external logic solver. Similarly, the Yase framework 4 explores a multi-stage compiler architecture that maps an AST to a behavior tree, but functions primarily as an agnostic middle-end integrated into the openPASS ecosystem. Other recent frameworks, such as VIVAS 9 and BeSimulator 16 , have demonstrated the viability of utilizing py_trees for managing complex agent perception and action states dynamically in simulators like CARLA. In contrast to architectures requiring intermediate external solvers, our approach directly compiles generated AST into execution-ready py_trees natively within CARLA, allowing for real-time, tick-by-tick simulation by mapping the domain.osc actions to CARLA’s localized Python API. Recent literature also highlights the use of Large Language Models (LLMs) to automatically generate DSL scripts from natural language. Frameworks such as Text2Scenario 5 utilize models like GPT-4 to parse scenario descriptions and output OpenSCENARIO DSL scripts intended for simulators like CARLA. Similarly, platforms like Chat2Scenario 17 and top-down generation pipelines such as LeGEND 15 demonstrate the capability of LLMs to transform unstructured traffic data, crash reports, and abstract functional scenarios into formal logical parameters. However, these generative approaches focus entirely on the frontend creation of the scenario text, fundamentally assuming a functioning backend compiler exists to execute the output script. Our architecture provides the

Read the complete text