inspect_scenario_files.py
Tested 2026-11-30 · Python 3.15.2 · standard library only
# Show what each file in a RoadData.AI scenario holds: the OpenDRIVE roads and the OpenSCENARIO road users.
# usage: python inspect_scenario_files.py roaddata-scenario-starter/sc_3ebeafb59c
import sys, xml.etree.ElementTree as ET
from collections import Counter
folder = sys.argv[1]
odr = ET.parse(f"{folder}/map.xodr").getroot()
h = odr.find("header")
print(f"map.xodr OpenDRIVE {h.get('revMajor')}.{h.get('revMinor')}: {len(odr.findall('road'))} roads, {len(odr.findall('junction'))} junctions")
for road in odr.findall("road")[:3]:
lanes = [l for l in road.findall(".//lane") if l.get("id") != "0"] # lane 0 is the reference line, not a lane
print(f" road {road.get('id')}: {float(road.get('length')):.1f} m, lanes: {len(lanes)}")
osc = ET.parse(f"{folder}/scenario.xosc").getroot()
h = osc.find("FileHeader")
print(f"scenario.xosc OpenSCENARIO {h.get('revMajor')}.{h.get('revMinor')}, map: {osc.find('.//RoadNetwork/LogicFile').get('filepath')}")
kinds = Counter()
for obj in osc.findall(".//Entities/ScenarioObject"):
e = next(iter(obj)) # Vehicle or Pedestrian
kinds[e.get("vehicleCategory") or e.get("pedestrianCategory") or e.tag] += 1
print(" road users:", ", ".join(f"{k} {n}" for k, n in kinds.items()))python inspect_scenario_files.py roaddata-scenario-starter/sc_3ebeafb59c
What it printed when we ran it
map.xodr OpenDRIVE 1.5: 69 roads, 12 junctions
road 270: 159.6 m, lanes: 1
road 271: 146.1 m, lanes: 1
road 272: 67.6 m, lanes: 2
scenario.xosc OpenSCENARIO 1.2, map: map.xodr
road users: car 1, bicycle 5, pedestrian 5, motorbike 1, truck 1