Skip to content

Replace random vehicle spawning with deterministic Berlin ring route - #1

Merged
hlibstrochkovskyi merged 2 commits into
mainfrom
copilot/add-berlin-ring-route
Nov 19, 2025
Merged

Replace random vehicle spawning with deterministic Berlin ring route#1
hlibstrochkovskyi merged 2 commits into
mainfrom
copilot/add-berlin-ring-route

Conversation

Copilot AI commented Nov 19, 2025

Copy link
Copy Markdown
Contributor

Replaces random vehicle scatter with a fixed Berlin S-Bahn Ringbahn pattern to enable visual validation of the data pipeline.

Changes

  • routes.rs: New module with berlin_ring_route() returning 15 waypoints forming a ring around central Berlin using real Ringbahn coordinates
  • main.rs: Modified spawn_vehicles() to distribute all 5,000 vehicles evenly along the shared route with ±0.0001° jitter, uniform 0.0008 speed, and sequential waypoint assignment
  • movement.rs: Tightened WAYPOINT_THRESHOLD from 0.0005 to 0.0002 for precise route following

Result

All vehicles now form a visible ring and move in a train pattern, creating a deterministic visual signature through the entire pipeline (Simulator → Kafka → Ingest → Redis → WebSocket → React).

// Before: Random scatter with individual square routes
let start_pos = Vec2::new(
    CENTER.x + rng.gen_range(-SPREAD..SPREAD),
    CENTER.y + rng.gen_range(-SPREAD..SPREAD),
);

// After: Distributed along shared Berlin ring
let waypoint_index = i % num_waypoints;
let base_pos = waypoints[waypoint_index];
let start_pos = base_pos + Vec2::new(rng.gen_range(-0.0001..0.0001), ...);

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Visual Validation Feature: Berlin Ring Route

Objective

Replace the current vehicle spawning logic with a deterministic Berlin ring route pattern for visual pipeline validation.

Changes Required

  1. Create crates/traffic-sim/src/routes.rs:

    • Add a function berlin_ring_route() that returns a Vec of Vec2 waypoints
    • Use real S-Bahn Ringbahn coordinates around central Berlin (approximately 15 waypoints forming a ring)
    • Coordinates should form a recognizable circular pattern around Berlin center
  2. Update crates/traffic-sim/src/main.rs:

    • Add mod routes; declaration at the top with other modules
    • Add use routes::berlin_ring_route; import
    • Replace the spawn_grid_vehicles function with spawn_vehicles function that:
      • Takes the Berlin ring route waypoints
      • Distributes all vehicles evenly along the route (using modulo to cycle through waypoints)
      • Adds small random offset (±0.0001°) to each vehicle to avoid perfect overlap
      • Sets all vehicles to similar speed (0.0008) for clear visualization
      • Uses the shared ring route for all vehicles
      • Each vehicle's current_waypoint should be set to the next waypoint in sequence
    • Update the call in main() from spawn_grid_vehicles(&mut world, 3000) to spawn_vehicles(&mut world, 5000)
  3. Update crates/traffic-sim/src/systems/movement.rs:

    • Change WAYPOINT_THRESHOLD from 0.0005 to 0.0002 for tighter route following

Expected Result

  • All 5,000 vehicles forming a clear visible ring around central Berlin
  • Vehicles moving in a "train" pattern around the circle
  • Ring aligns with real Berlin streets (S-Bahn Ringbahn approximation)
  • No random scatter - deterministic, reproducible pattern

Implementation Details

The Berlin ring route should include waypoints like:

  • Westkreuz: 13.3884, 52.5244
  • Südkreuz area: 13.3650, 52.4750
  • Ostkreuz area: 13.5030, 52.4650
  • Prenzlauer Berg: 13.5050, 52.5400
  • Wedding: 13.4500, 52.5650
  • And approximately 10 more points forming a complete ring

This creates a visual sanity check for the entire data pipeline (Rust Simulator → Kafka → Ingest → Redis → WebSocket → React).

This pull request was created as a result of the following prompt from Copilot chat.

Visual Validation Feature: Berlin Ring Route

Objective

Replace the current vehicle spawning logic with a deterministic Berlin ring route pattern for visual pipeline validation.

Changes Required

  1. Create crates/traffic-sim/src/routes.rs:

    • Add a function berlin_ring_route() that returns a Vec of Vec2 waypoints
    • Use real S-Bahn Ringbahn coordinates around central Berlin (approximately 15 waypoints forming a ring)
    • Coordinates should form a recognizable circular pattern around Berlin center
  2. Update crates/traffic-sim/src/main.rs:

    • Add mod routes; declaration at the top with other modules
    • Add use routes::berlin_ring_route; import
    • Replace the spawn_grid_vehicles function with spawn_vehicles function that:
      • Takes the Berlin ring route waypoints
      • Distributes all vehicles evenly along the route (using modulo to cycle through waypoints)
      • Adds small random offset (±0.0001°) to each vehicle to avoid perfect overlap
      • Sets all vehicles to similar speed (0.0008) for clear visualization
      • Uses the shared ring route for all vehicles
      • Each vehicle's current_waypoint should be set to the next waypoint in sequence
    • Update the call in main() from spawn_grid_vehicles(&mut world, 3000) to spawn_vehicles(&mut world, 5000)
  3. Update crates/traffic-sim/src/systems/movement.rs:

    • Change WAYPOINT_THRESHOLD from 0.0005 to 0.0002 for tighter route following

Expected Result

  • All 5,000 vehicles forming a clear visible ring around central Berlin
  • Vehicles moving in a "train" pattern around the circle
  • Ring aligns with real Berlin streets (S-Bahn Ringbahn approximation)
  • No random scatter - deterministic, reproducible pattern

Implementation Details

The Berlin ring route should include waypoints like:

  • Westkreuz: 13.3884, 52.5244
  • Südkreuz area: 13.3650, 52.4750
  • Ostkreuz area: 13.5030, 52.4650
  • Prenzlauer Berg: 13.5050, 52.5400
  • Wedding: 13.4500, 52.5650
  • And approximately 10 more points forming a complete ring

This creates a visual sanity check for the entire data pipeline (Rust Simulator → Kafka → Ingest → Redis → WebSocket → React).


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: hlibstrochkovskyi <80542566+hlibstrochkovskyi@users.noreply.github.com>
Copilot AI changed the title [WIP] Add deterministic Berlin ring route for visual validation Replace random vehicle spawning with deterministic Berlin ring route Nov 19, 2025
@hlibstrochkovskyi
hlibstrochkovskyi marked this pull request as ready for review November 19, 2025 12:48
@hlibstrochkovskyi
hlibstrochkovskyi merged commit ca99a35 into main Nov 19, 2025
1 check failed
@hlibstrochkovskyi
hlibstrochkovskyi deleted the copilot/add-berlin-ring-route branch November 19, 2025 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants