Files
Warehouse-Digital-Twin-and-…/IMPLEMENTATION_DETAILS.md
T

9.1 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 ConfigurationError with 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), and errors.log (ERROR+).
    • Enforces max_bytes (default 10 MB) and backup_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: Invokes ConfigLoader and prints validation summaries.
  • validate_graph(config_dir: Optional[str]) -> int: Builds the networkx.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), and allowed_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 \theta measured 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}).

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.py use 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): 540-node topological navigation graph, reachability validation, zone restrictions, graph JSON export.
    • Phase 2 (Robot and Task Models): Robot state machine (IDLE through CHARGING), legal transition tables, task priority & lifecycle models, inventory catalog with stock reservation & replenishment, telemetry events, and OpenUSD robot fleet visualization. 56 passing unit tests.
  • Phase 3 Target: Implement Discrete-Event Simulation Engine (warehouse_twin.simulation):
    • SimPy simulation environment managing clock time.
    • Dynamic order arrival processes for Zone A (Poisson), Zone B (Normal), and Zone C (Deterministic batch).
    • Task queueing and priority dispatcher assigning compatible AMRs.
    • Full simulation lifecycle execution with KPI collection.