How mareklorenz/scenario-modification-framework works
This is an LLM-assisted CommonRoad driving-scenario analysis and modification framework. An engineer supplies a scenario XML and precomputed ego trajectory; the main workflow derives scenario layers and safety metrics, uses LLM prompts to identify a critical obstacle and interval, requests an adversarial trajectory update, then writes an updated scenario and records results. Supporting branches include ego-trajectory preprocessing, MTL safety analysis, and simulation/evaluation. Edges reflect README workflow statements and source references; unsampled implementation details are not asserted.
Main entry points: main.py Workflow Orchestrator · llm_utils.py LLM Client · modify_scenario.py Trajectory Modification · L4_converter.py Obstacle MTL
Components 27
Scenario Workflow
- Workflow Orchestrator
main.py - CommonRoad Scenario
data/scenarios - Ego Trajectory
data/ego_trajectories - Updated Scenario
data/outputs
Scenario Analysis
- Scenario Layers
preprocessing/layermodel.py - XML Conversion
preprocessing/xml2json.py - Road MTL
mtl_converter/L1_converter.py - Obstacle MTL
mtl_converter/L4_converter.py - Ego MTL
mtl_converter/L7_converter.py - Safety Metrics
mtl_converter/safety_metrics.py - TTC Metrics
mtl_converter/L4_safety_metrics.py - Lanelet Geometry
mtl_converter/utils.py - Obstacle Selection
llm_templates/critical_obstacles.py - Interval Selection
llm_templates/critical_interval.py - Result Schemas
generation_types/generation.py
Scenario Modification
- Trajectory Modification
scenario_modification/modify_scenario.py - LLM Client
llm_templates/llm_utils.py - Scenario Writer
scenario_modification/update_xml.py
Trajectory and Evaluation
- Trajectory Extraction
preprocessing/extract_trajectories.py - Trajectory Visualization
preprocessing/plot.py - Ego Preparation
generate_ego_trajectory.py - Result Analysis
output_analysis.py - Scenario Simulation
scripts/simulation/run_simulation.py
Other components
- Scenario Engineer
- OpenAI API
- Gemini API
- Local Ollama
Connections 35
- Scenario Engineer → Workflow Orchestrator: runs
README.md - Scenario Engineer → CommonRoad Scenario: provides
README.md - Scenario Engineer → Ego Trajectory: provides
README.md - Workflow Orchestrator → CommonRoad Scenario: reads
README.md - Workflow Orchestrator → Ego Trajectory: reads
README.md - Workflow Orchestrator → Scenario Layers: uses
main.py - Workflow Orchestrator → XML Conversion: uses
main.py - Workflow Orchestrator → Road MTL: converts
main.py - Workflow Orchestrator → Obstacle MTL: converts
main.py - Workflow Orchestrator → Ego MTL: converts
main.py - Workflow Orchestrator → Safety Metrics: calculates
main.py - Obstacle MTL → TTC Metrics: uses
mtl_converter/L4_converter.py - Obstacle MTL → Lanelet Geometry: checks lanelets
mtl_converter/L4_converter.py - Scenario Writer → Lanelet Geometry: checks lanelets
scenario_modification/update_xml.py - Workflow Orchestrator → Obstacle Selection: requests selection
main.py - Workflow Orchestrator → Interval Selection: requests interval
main.py - Interval Selection → Result Schemas: parses result
llm_templates/critical_interval.py - Interval Selection → LLM Client: calls
llm_templates/critical_interval.py - Obstacle Selection → LLM Client: calls
llm_templates/critical_obstacles.py - Workflow Orchestrator → Trajectory Modification: requests update
main.py - Trajectory Modification → LLM Client: requests trajectory
scenario_modification/modify_scenario.py - Trajectory Modification → Road MTL: gets lanelets
scenario_modification/modify_scenario.py - Trajectory Modification → Result Schemas: uses results
scenario_modification/modify_scenario.py - LLM Client → OpenAI API: sends requests
llm_templates/llm_utils.py - LLM Client → Gemini API: sends requests
llm_templates/llm_utils.py - LLM Client → Local Ollama: sends requests
llm_templates/llm_utils.py - Workflow Orchestrator → Scenario Writer: writes scenario
main.py - Scenario Writer → CommonRoad Scenario: reads source
scenario_modification/update_xml.py - Workflow Orchestrator → Updated Scenario: saves result
README.md - Workflow Orchestrator → Result Analysis: records results
main.py - Workflow Orchestrator → Trajectory Extraction: extracts trajectories
main.py - Trajectory Extraction → Trajectory Visualization: uses geometry
preprocessing/extract_trajectories.py - Ego Preparation → Trajectory Extraction: prepares input
generate_ego_trajectory.py - Ego Preparation → Trajectory Visualization: visualizes
generate_ego_trajectory.py - Scenario Engineer → Scenario Simulation: runs batch
README.md