- 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.
10 KiB
10 KiB
Implementation Details: Warehouse Robot Fleet Digital Twin
1. System Architecture & Module Responsibilities
The system is structured as a decoupled discrete-event simulation engine with an asynchronous 3D visualization and analytics pipeline.
warehouse-digital-twin/
├── config/ # Declarative simulation and physical facility definitions
├── docs/ # Architectural, API, and phase reports
├── logs/ # Structured rotating application, simulation, and error logs
├── omniverse/ # NVIDIA Omniverse Kit 110.4 assets and visualizer extensions
├── results/ # Trajectories, experiment logs, and KPI reports
├── scripts/ # Automated verification and test execution scripts
├── src/warehouse_twin/ # Python package implementation
│ ├── config/ # Config parsing, validation, and bundle models
│ ├── domain/ # (Phase 1-2) Typed entity models, states, and event schemas
│ ├── simulation/ # (Phase 3) SimPy event loop and order generation
│ ├── routing/ # (Phase 4) NetworkX spatial graph and time-space reservations
│ ├── fleet/ # (Phase 4-5) Dispatcher, battery controller, charging manager
│ ├── analytics/ # (Phase 6) KPI calculators, reports, and congestion heatmaps
│ ├── storage/ # (Phase 6) JSONL event streaming and experiment stores
│ ├── interfaces/ # (Phase 6-7) Output serialization and trajectory generation
│ ├── logging_config.py # Multi-target rotating file and console logger
│ ├── cli.py # Command-line interface
│ └── main.py # Execution entry point
└── tests/ # Pytest unit, integration, and scenario tests
2. Important Classes, Functions, and Data Models
2.1 Configuration Subsystem (warehouse_twin.config)
ConfigLoader:load_all() -> ConfigBundle: Reads, parses, and validates the 5 configuration files (warehouse.json,robots.json,inventory.json,simulation.json,dispatch_policies.json).- Validation routines:
validate_warehouse,validate_robots,validate_inventory,validate_simulation,validate_dispatch_policies. - Raises
ConfigurationErrorwith line, file, and field details upon syntax or semantic violations.
ConfigBundle: Frozen dataclass containing parsed dictionaries and verified directory path.
2.2 Logging Subsystem (warehouse_twin.logging_config)
setup_logging(...) -> Path:- Initializes root and simulation loggers with rotating file handlers.
- Generates
application.log(DEBUG+),simulation.log(dedicated simulation event format), anderrors.log(ERROR+). - Enforces
max_bytes(default 10 MB) andbackup_count(default 5) to protect low-disk environments.
get_logger(name: str) -> logging.Logger: Returns module-namespaced logger.get_simulation_logger() -> logging.Logger: Returns dedicated simulation event stream.
2.3 CLI Interface (warehouse_twin.cli)
check_environment() -> int: Tests Python version (>=3.10), checks disk space on/(warns if < 10 GB, fails if < 2 GB), checks core imports (simpy,networkx,pytest), verifies log directory writability, and detects Kit executable.validate_config(config_dir: Optional[str]) -> int: InvokesConfigLoaderand prints validation summaries.validate_graph(config_dir: Optional[str]) -> int: Builds thenetworkx.DiGraph, validates strong connectivity, tests robot class reachability, and prints a comprehensive topology report.export_graph(config_dir: Optional[str], output_path: Optional[str]) -> int: Builds and exports the serialized graph topology to JSON.
2.4 Warehouse Domain Subsystem (warehouse_twin.domain.warehouse)
Position3D: Immutable 3D Cartesian coordinates(x, y, z)in meters with Euclidean metric calculation (distance_to).WarehouseDimensions: Physical warehouse bounding box in meters (width=60m, depth=40m, height=8m).ZoneArea&ZoneDefinition: Rectangular bounds and physical constraints (aisle width, maximum speed limit) for Zones A, B, and C.Station&ChargingStation: Fixed operational stations (inbound docks, outbound dock, picking stations, production drop-off) and fast/heavy charging bays.StorageLocation: Inventory rack locations with zone and aisle bindings.WarehouseModel: Comprehensive physical facility model instantiated from configuration data.
2.5 Routing & Topological Graph Builder (warehouse_twin.routing.graph_builder)
WarehouseGraphBuilder:build_graph() -> nx.DiGraph: Constructs a directed navigation network with 540 nodes and 1,730 edges.- Coordinate hashing: Waypoint node IDs are derived from discretized coordinates
(round(x, 1), round(y, 1))to guarantee unified intersection nodes. - Edge weights: Euclidean distance, speed limit, traversal time (
dist / speed), andallowed_robot_types. - Zone B restrictions: Edge attributes enforce
allowed_robot_types = {"heavy_amr"}for Zone B aisles.
ConnectivityReport: Structured metrics detailing strong connectivity, reachable stations, chargers, racks, lane length, and robot type accessibility.WarehouseGraphError,DisconnectedGraphError,UnreachableStationError: Fail-fast exceptions raised upon topological violations.
3. Coordinate System and Measurement Units
The simulation and 3D visualizer strictly adopt standard industrial robotics conventions:
- Reference Frame: Right-Handed Cartesian coordinate system.
- Axes Orientation:
- X-axis: Facility Width (East) in meters.
- Y-axis: Facility Depth (North) in meters.
- Z-axis: Facility Height (Up) in meters. Ground floor plane is at
Z = 0.0 m.
- Orientation / Heading: Yaw angle
\thetameasured in degrees counter-clockwise from the positive X-axis (0^\circ = \text{East},90^\circ = \text{North}). - Kinematic Units:
- Linear velocity: meters per second (
\text{m/s}). - Linear acceleration: meters per second squared (
\text{m/s}^2). - Mass / payload: kilograms (
\text{kg}). - Energy: kilowatt-hours (
\text{kWh}). - Power: kilowatts (
\text{kW}). - Time: seconds (
\text{s}).
- Linear velocity: meters per second (
4. Hardware, OS, and Dependency Findings
| Component | Host Finding | Architectural Implication |
|---|---|---|
| Operating System | Ubuntu 24.04.3 LTS (Kernel 7.0.0-38) | Modern Linux with glibc 2.39; fully supported. |
| Python Version | Python 3.12.3 (/usr/bin/python3) |
Virtual environment uses Python 3.12, identical to Kit's embedded Python. |
| Primary Disk | /dev/nvme0n1p4 at 99% capacity (8.9 GB free) |
High Disk Constraint: Isaac Sim cannot be installed. Rotating logs strictly capped at 10 MB. Relocation to secondary drive supported. |
| GPU | NVIDIA GeForce RTX 5090 (32,607 MiB VRAM) | Ample VRAM for real-time 3D visualization and ray-traced Kit rendering. |
| NVIDIA Omniverse Kit | Kit 110.4.0 at kit-app-template |
Active app warehouse_twin.kit. Trajectory playback in Phase 7 will target Kit 110.4 extension APIs. |
| SimPy | Version 4.1.2 | Installed in .venv; supports microsecond discrete-event simulation. |
| NetworkX | Version 3.7 | Installed in .venv; supports spatial routing and shortest-path planning. |
| Pytest | Version 9.1.1 | Installed in .venv; test suite verified. |
5. Testing and Validation Strategy
The testing architecture adheres to the following principles:
- Headless Execution: All unit, integration, and scenario tests execute without display servers or GPU dependencies.
- Isolated Fixtures: Tests in
tests/conftest.pyuse temporary directories (tmp_path) for configuration and logging validation to prevent workspace side-effects. - Fail-Fast Boundary Tests: Explicit tests verify negative paths: malformed JSON, non-positive dimensions, missing zones, undefined robot types, and duplicate inventory item IDs.
- Phase Gate: Each phase must pass 100% of its test suite before advancing to the next phase.
6. Current Status & Next Phase
- Completed:
- Phase 0 (Environment and Foundation): Core architecture, rotating file logs, configuration loaders, environment verification.
- Phase 1 (Warehouse Model): Topological navigation graph, reachability validation, zone restrictions, graph JSON export.
- Phase 2 (Robot and Task Models): Robot state machine (
IDLEthroughCHARGING), legal transition tables, task priority & lifecycle models, inventory catalog with stock reservation & replenishment, telemetry events, OpenUSD robot fleet visualization. - Phase 3 (Discrete-Event Simulation Engine): SimPy master clock execution, multi-zone order arrival streams (Zone A Poisson, Zone B wide-aisle Gaussian, Zone C scheduled feed, auto-replenishment), priority-based fleet dispatcher with NetworkX shortest-path scoring, robot mission lifecycles (transit, pick, drop, recharge), telemetry streaming, and
run-simCLI command. 72 passing unit tests. - Phase 4 (Routing, Fleet Assignment & Traffic Management): NetworkX spatial shortest-path routing (
PathPlanner), time-space reservation grids (TimeSpaceReservationGrid) with head-on avoidance and1.0\text{s}headway buffers, cooperative traffic manager (TrafficManager) with priority-based right-of-way and deadlock bypass rerouting, trajectory export (results/trajectories/trajectory_sim.json), and OpenUSD scene with highway corridor overlays (omniverse/scenes/warehouse_phase4.usda). 95 passing unit tests.
- Phase 5 Target: Charging and Operational Constraints:
- Battery discharge curves based on payload weight, speed, and acceleration.
- Opportunity charging vs. mandatory low-battery return-to-base thresholds.
- Charging bay resource queues (SimPy
Resource) with reservation and queuing logic. - Production deadline constraints with late penalties and SLA monitoring.