A Rust library for parsing, validating, and manipulating OpenSCENARIO files.
- Parse and serialize
.xoscfiles (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
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.
[dependencies]
openscenario-rs = "0.3.0"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(())
}cargo run --bin scenario_analyzer -- scenario.xosc
cargo run --bin xosc-validate -- scenario.xosctypes/— OpenSCENARIO data typesparser/— XML parsing and serializationcatalog/— catalog loading and reference resolutionexpression/— expression evaluationbuilder/— programmatic scenario construction (feature-gated)
cargo test
cargo test --features builderCheck existing patterns before adding new types. Add tests. Verify XML round-trip behavior.
The Rust source code is licensed under the GNU General Public License v3.0.
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.
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.
This package is developed as part of the SYNERGIES project.
Funded by the European Union. Views and opinions expressed are however those of the author(s) only and do not necessarily reflect those of the European Union or European Climate, Infrastructure and Environment Executive Agency (CINEA). Neither the European Union nor the granting authority can be held responsible for them.