openscenario-rs 0.3.1

Rust library for parsing and manipulating OpenSCENARIO files
Documentation

openscenario-rs

A Rust library for parsing, validating, and manipulating OpenSCENARIO files.

Crates.io Documentation License

Features

  • Parse and serialize .xosc files (scenarios, catalogs, parameter variations)
  • Type-safe data model covering actions, conditions, entities, and distributions
  • Parameter resolution with mathematical expression support (${param + 1})
  • Catalog loading and reference resolution
  • Optional builder API for programmatic scenario construction (--features builder)
  • CLI tools: xosc-validate, scenario_analyzer

Status

Core parsing and serialization is functional. Actions and conditions have broad but not complete coverage — see the implementation table in docs/user_guide.md for details.

Quick Start

[dependencies]
openscenario-rs = "0.3.0"

Parsing

use openscenario_rs::{parse_file, OpenScenarioDocumentType};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let scenario = parse_file("scenario.xosc")?;

    println!("Author: {:?}", scenario.file_header.author);

    match scenario.document_type() {
        OpenScenarioDocumentType::Scenario => {
            if let Some(entities) = &scenario.entities {
                for entity in &entities.scenario_objects {
                    println!("Entity: {:?}", entity.name);
                }
            }
        }
        OpenScenarioDocumentType::Catalog => println!("Catalog file"),
        OpenScenarioDocumentType::ParameterVariation => println!("Parameter variation file"),
        _ => {}
    }

    Ok(())
}

Analysis Tools

cargo run --bin scenario_analyzer -- scenario.xosc
cargo run --bin xosc-validate -- scenario.xosc

Modules

  • types/ — OpenSCENARIO data types
  • parser/ — XML parsing and serialization
  • catalog/ — catalog loading and reference resolution
  • expression/ — expression evaluation
  • builder/ — programmatic scenario construction (feature-gated)

Testing

cargo test
cargo test --features builder

Documentation

Contributing

Check existing patterns before adding new types. Add tests. Verify XML round-trip behavior.

License & Attribution

The Rust source code is licensed under the GNU General Public License v3.0.

ASAM OpenSCENARIO Schema

Schema/OpenSCENARIO.xsd is published by ASAM e.V. and redistributed unchanged for validation purposes under the ASAM license terms. See Schema/NOTICE for details.

ALKS Test Scenarios

tests/data/alks_scenario.xosc originates from openMSL/sl-3-1-osc-alks-scenarios (© BMW Group), licensed under MPL 2.0. See tests/data/NOTICE for details.