feat(phase-4): implement spatial routing, time-space reservations, and traffic manager

- Implemented PathPlanner using NetworkX Dijkstra/A* with dynamic edge congestion weights and robot capability enforcement.
- Implemented TimeSpaceReservationGrid with head-on collision avoidance on bidirectional corridors and 1.0s following headway buffers.
- Implemented TrafficManager with multi-AMR right-of-way arbitration (task priority, loaded over empty) and deadlock timeout dynamic rerouting.
- Integrated waypoint traversal into SimPy simulation engine with real-time trajectory recording and export.
- Generated omniverse/scenes/warehouse_phase4.usda with navigation corridor overlays.
- Expanded test suite to 95 unit tests with 100% pass rate.
This commit is contained in:
2026-10-21 10:59:11 +05:30
parent 3d9fb6be66
commit 56806079a9
20 changed files with 3225 additions and 104 deletions
+58 -39
View File
@@ -1,7 +1,7 @@
# Project Status: Warehouse Robot Fleet Digital Twin
**Last Updated**: October 19, 2026
**Current Phase**: **Phase 3: Discrete-Event Simulation Engine (COMPLETED)**
**Last Updated**: October 21, 2026
**Current Phase**: **Phase 4: Routing and Fleet Assignment (COMPLETED)**
**Status**: Ready for User Review and Approval
---
@@ -13,9 +13,9 @@
| **Phase 0** | **Environment and project foundation** | **COMPLETED** | **17 passed** |
| **Phase 1** | **Warehouse model** | **COMPLETED** | **26 passed** |
| **Phase 2** | **Robot and task models** | **COMPLETED** | **56 passed** |
| **Phase 3** | **Discrete-event simulation** | **COMPLETED** | **72 passed (100%)** |
| Phase 4 | Routing and fleet assignment | Planned (Next) | - |
| Phase 5 | Charging and operational constraints | Planned | - |
| **Phase 3** | **Discrete-event simulation** | **COMPLETED** | **72 passed** |
| **Phase 4** | **Routing and fleet assignment** | **COMPLETED** | **95 passed (100%)** |
| Phase 5 | Charging and operational constraints | Planned (Next) | - |
| Phase 6 | Analytics and experiment framework | Planned | - |
| Phase 7 | Omniverse USD visualization | Planned | - |
| Phase 8 | Operational dashboard | Planned | - |
@@ -23,40 +23,49 @@
---
## 2. Completed Tasks (Phase 3)
## 2. Completed Tasks (Phase 4)
- [x] Modified Zone B (slow-moving specialized inventory) with **wider aisles ($4.0\text{m}$ width)**:
- Updated `config/warehouse.json` with `aisle_width: 4.0`.
- Configured `WarehouseGraphBuilder` with $4.0\text{m}$ column spacing across Zone B ($x \in [32.0, 36.0, 40.0, 44.0]$).
- Added unit test `test_slow_moving_zone_b_has_wider_aisles` verifying $4.0\text{m}$ vs $2.0\text{m}$ aisle spacing.
- [x] Implemented multi-zone order generator (`src/warehouse_twin/simulation/order_generator.py`):
- Zone A: Poisson process (`expovariate`) for fast-moving components.
- Zone B: Gaussian distribution (`gauss`) for heavy parts, targeting Zone B's wider aisles.
- Zone C: Deterministic scheduled batch deliveries feeding production line dropoff.
- Automated stock replenishment order generation when inventory dips below minimum threshold.
- [x] Implemented fleet dispatcher (`src/warehouse_twin/simulation/dispatcher.py`):
- Priority task queue sorting by `(priority, deadline, release_time)`.
- AMR payload compatibility filtering and Zone B heavy AMR restriction enforcement.
- Minimum battery headroom ($20\%$) filtering.
- NetworkX shortest-path distance calculation for nearest idle robot allocation.
- [x] Implemented SimPy discrete-event simulation engine (`src/warehouse_twin/simulation/sim_engine.py`):
- Master clock coordinator and discrete process manager.
- Full AMR mission lifecycle: empty transit, picking, stock reservation, loaded transit, dropoff.
- Battery discharge and automated fast-recharging at charging bays.
- Real-time telemetry streaming to `logs/simulation_events.jsonl`.
- Comprehensive KPI metrics collection (throughput, turnaround time, wait time, utilization, energy).
- [x] Added `run-sim` CLI subcommand to `src/warehouse_twin/cli.py`.
- [x] Expanded test suite to **72 unit tests** (100% pass rate in 0.37s).
- [x] Created `docs/phases/phase_3_simulation_engine.md`.
- [x] Implemented NetworkX shortest path planning module (`src/warehouse_twin/routing/path_planner.py`):
- Dijkstra and A* path calculation with distance and traversal time scoring.
- Robot capability and class restrictions (Zone B 4.0m wide aisles restricted to Heavy AMRs).
- Dynamic edge cost calculation incorporating congestion penalties.
- Fail-fast unreachable destination diagnostics (`NoPathFoundError`).
- Unit test suite: 9 passed in `tests/unit/test_path_planner.py`.
- [x] Implemented Time-Space Reservation Grid (`src/warehouse_twin/routing/reservations.py`):
- Temporal reservation of nodes and physical aisle edge segments.
- Head-on collision elimination on shared bidirectional aisles.
- Rear-end / following headway buffer enforcement ($1.0\text{s}$).
- Intersection exclusive zone protection.
- Earliest safe departure search and expired slot cleanup.
- Unit test suite: 7 passed in `tests/unit/test_reservations.py`.
- [x] Implemented Multi-Robot Traffic Manager (`src/warehouse_twin/routing/traffic_manager.py`):
- Priority-aware right-of-way arbitration (Production Feed > Replenishment > Picking).
- Loaded vs. empty yielding rules (`loaded_yields_to_empty: false`).
- Cooperative waypoint waiting on corridor contention (`YIELD_WAIT`).
- Deadlock timeout detection and dynamic bypass rerouting (`REPLAN`).
- Unit test suite: 7 passed in `tests/unit/test_traffic_manager.py`.
- [x] Integrated spatial routing into `SimulationEnvironment` (`src/warehouse_twin/simulation/sim_engine.py`):
- Waypoint-by-waypoint path traversal process replacing instantaneous transit timeouts.
- Telemetry streaming with path lengths, waypoint counts, and yield events.
- Trajectory recording: 3,326 time-stamped points across fleet.
- JSON trajectory export (`results/trajectories/trajectory_sim.json`).
- Unit test suite: 1 passed in `tests/unit/test_trajectory_export.py`.
- [x] Enhanced OpenUSD scene export (`omniverse/scenes/warehouse_phase4.usda`):
- Includes topological navigation highways (cyan/blue) and Zone B wide aisles (amber).
- [x] Updated CLI entry point:
- Added `--output-trajectories` option to `run-sim`.
- Added Phase 4 traffic KPI reporting (conflicts, yields, wait times, reroutes, deadlocks).
- [x] Test Suite: Expanded to **95 passed unit tests (100% pass rate in 0.73s)**.
- [x] Documentation: Created `docs/phases/phase_4_routing_and_fleet_assignment.md`.
---
## 3. Test & Validation Summary
- **Total Unit Tests Executed**: 72
- **Passed**: 72
- **Total Unit Tests Executed**: 95
- **Passed**: 95
- **Failed**: 0
- **Execution Time**: ~0.37 seconds
- **Execution Time**: ~0.73 seconds
- **Test Suites**:
- `test_environment.py`: 5 passed
- `test_logging.py`: 3 passed
@@ -68,20 +77,30 @@
- `test_events_model.py`: 1 passed
- `test_order_generator.py`: 6 passed
- `test_dispatcher.py`: 4 passed
- `test_path_planner.py`: 9 passed
- `test_reservations.py`: 7 passed
- `test_traffic_manager.py`: 7 passed
- `test_sim_engine.py`: 5 passed
- `test_trajectory_export.py`: 1 passed
---
## 4. Benchmark Performance (1-Hour Simulation Run)
- **Simulated Duration**: 3,600.0s (1.00 hour)
- **Wall-clock Execution Time**: ~0.45s
- **Wall-clock Execution Time**: ~1.48s
- **Tasks Created**: 86
- **Tasks Completed**: 84
- **Throughput**: 84.00 tasks/hr
- **Average Turnaround Time**: 96.3s
- **Average Waiting Time**: 31.9s
- **Average Execution Time**: 64.4s
- **Tasks Completed**: 85
- **Throughput**: 85.00 tasks/hr
- **Average Turnaround Time**: 91.2s
- **Average Waiting Time**: 29.9s
- **Average Execution Time**: 61.3s
- **On-Time Delivery Rate**: 100.0%
- **Fleet Utilization**: 53.2%
- **Fleet Utilization**: 50.9%
- **Replenishment Triggers**: 1
- **Traffic Conflicts Detected**: 36
- **Yield Waits Executed**: 36
- **Total Yield Wait Time**: 56.0s (avg 1.55s per yield)
- **Deadlocks Prevented**: 0 (zero deadlocks occurred)
- **Head-on Collisions**: 0 (100% collision-free)
- **Trajectory Points Recorded**: 3,326