Rendering & Visualizing Policies

The rendering tool visualizes the driving environment in real-time or renders MP4 policy videos. It displays vehicle trajectories, safety guard interventions, and communication queries between vehicles.

  • Main Script: scripts/evaluation/render_request_dqn.py
  • Output Videos: Saved to docs/images/

1. Interactive Visualizer (Watch Live)

Run this from the project root to open a live Pygame window:

.venv/bin/python -m scripts.evaluation.render_request_dqn \
  --experiment 7 \
  --dqn-checkpoint checkpoints/experiment_7/best.pt \
  --mlpx-checkpoint checkpoints/experiment_5/MLPx/intent_stage_best.pt \
  --episodes 1 \
  --seed 120 \
  --duration 100 \
  --delay 0.15 \
  --safety-guard \
  --max-target-speed 30 \
  --lane-change-guard \
  --comfort-ttc 6 \
  --batched-planner
  • --delay 0.15: Pauses 0.15 seconds between steps for comfortable viewing.
  • --seed <N>: Sets the initial road and traffic seed.

2. Headless Video Recording (Save to MP4)

To record a policy run to an .mp4 file without opening a GUI window:

SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=dummy \
.venv/bin/python -m scripts.evaluation.render_request_dqn \
  --experiment 7 \
  --dqn-checkpoint checkpoints/experiment_7/best.pt \
  --mlpx-checkpoint checkpoints/experiment_5/MLPx/intent_stage_best.pt \
  --episodes 1 \
  --seed 120 \
  --duration 100 \
  --delay 0 \
  --safety-guard \
  --max-target-speed 30 \
  --lane-change-guard \
  --comfort-ttc 6 \
  --batched-planner \
  --video-fps 8 \
  --video "docs/images/dqn_experiment_7_policy.mp4"

All generic Experiment 1โ€“8 policy videos use seed 120 and a maximum duration of 100 decision steps so their behavior is visually comparable on the same initial road. Purpose-built cut-in demonstrations retain their selected challenge seeds because they illustrate specific hidden-intent events.

Shared seed-120 video set

ExperimentOutcomeStepsRewardRequestsVideo
Experiment 1Crashed6 / 1004.7733Watch
Experiment 2Crashed10 / 1008.5324Watch
Experiment 3Crashed6 / 1004.7494Watch
Experiment 4Drove to end100 / 10087.14574Watch
Experiment 5Drove to end100 / 10087.14563Watch
Experiment 6Drove to end100 / 10090.66152Watch
Experiment 7Drove to end100 / 10090.66169Watch
Experiment 8Drove to end100 / 10090.83682Watch

3. Rendering Cut-In Challenge Scenarios

To render the matched-intent cut-in scenario where neighboring vehicles attempt an aggressive merge:

SDL_VIDEODRIVER=dummy .venv/bin/python -m scripts.evaluation.render_request_dqn \
  --experiment 7 \
  --scenario paired-intent \
  --hidden-mode merge \
  --seed 1300051 \
  --safety-guard \
  --max-target-speed 30 \
  --lane-change-guard \
  --video-fps 2 \
  --video "docs/images/cut_in_demo.mp4"

What the Visualizer Shows

Vehicle Colors

  • ๐ŸŸฉ Green: Ego vehicle (controlled by MLPx World Model + Safety Guard)
  • ๐ŸŸง Orange: Aggressive vehicle
  • ๐ŸŸฆ Blue: Defensive vehicle
  • ๐ŸŸจ Yellow: Standard IDM background vehicle
  • ๐ŸŸฅ Red: Any vehicle involved in a collision

Communication Overlays

  • Yellow Circle & Label: Highlights the specific neighboring vehicle that the ego car queried for intent at that timestep.
  • Top HUD Panel: Shows the ego's current speed, chosen driving action, the queried vehicle ID, and its received intent message (target_lane, target_speed, acceleration).