Files
Warehouse-Digital-Twin-and-…/docs/phases/phase_2_robot_and_task_models.md
T

8.9 KiB
Raw Blame History

Phase 2 Implementation Report: Robot and Task Models

1. Phase Name and Objective

Phase 2: Robot and Task Models

The objective of Phase 2 is to design, implement, test, and document the core discrete entities of the warehouse digital twin:

  1. Autonomous Mobile Robots (AMRs) with kinematic parameters, state machines, battery charge/discharge energy models, and zone access constraints.
  2. Warehouse operational tasks (Inbound Transport, Outbound Picking, Production Feed, Replenishment, Charging) with priority levels, lifecycle state machines, execution time tracking, and SLA deadline monitoring.
  3. Inventory items, categories, SKU definitions, and storage rack allocations, supporting reservation, consumption, and automatic replenishment triggers.
  4. Structured simulation event definitions for event-driven logging and telemetry streaming.
  5. 3D OpenUSD scene export (warehouse_phase2.usda) integrating the active AMR fleet with realistic geometry and status indicator domes positioned on charging bays.

2. Deliverables Completed

Deliverable Status Description
src/warehouse_twin/domain/robot.py Complete RobotState enum, RobotTypeSpec, Robot model, legal transition lookup LEGAL_ROBOT_TRANSITIONS, validate_task_compatibility(), assign_task(), energy consumption and charging calculation.
src/warehouse_twin/domain/task.py Complete TaskType and TaskStatus enums, LEGAL_TASK_TRANSITIONS, Task model with turnaround, waiting, execution time, and SLA deadline overdue checks.
src/warehouse_twin/domain/inventory.py Complete InventoryItem and InventoryCatalog loading all 13 items from config/inventory.json, stock reservation, consumption, and replenishment threshold logic.
src/warehouse_twin/domain/events.py Complete SimulationEventType enum and SimulationEvent dataclass with ISO8601 timestamps and JSONL serialization.
src/warehouse_twin/interfaces/usd_generator.py Complete Enhanced WarehouseUSDGenerator.from_config_bundle to generate 3D OpenUSD primitives for the AMR fleet (pearl white for light AMRs, industrial amber for heavy AMRs, with cyan/green status domes).
tests/unit/test_robot_model.py Complete 14 unit tests validating AMR kinematics, full state cycles, illegal state transitions, payload capacity rejections, zone restrictions, and energy dynamics.
tests/unit/test_task_model.py Complete 9 unit tests validating task lifecycle transitions, cancellation, preemption, illegal state jumps, and SLA deadline overdue tracking.
tests/unit/test_inventory_model.py Complete 4 unit tests verifying stock reservation lifecycle, insufficient stock errors, replenishment triggers, and full catalog loading.
tests/unit/test_events_model.py Complete Unit test validating telemetry event serialization and JSONL formatting.
tests/unit/test_warehouse_graph.py Complete Added test_export_usda_with_robots verifying AMR fleet prim generation.
omniverse/scenes/warehouse_phase2.usda Complete Exported OpenUSD scene containing the complete facility, zones, racks, stations, and AMR fleet ready for NVIDIA Omniverse Kit.

3. Configuration Parameters Used

  • config/robots.json:
    • light_amr: Max speed 1.5\text{ m/s}, acceleration 0.8\text{ m/s}^2, turning rate 90^\circ/\text{s}, payload capacity 150\text{ kg}, battery capacity 2.5\text{ kWh}, power consumption (1.2\text{ kW} moving, 0.15\text{ kW} idle, 0.3\text{ kW} loaded), allowed zones ["zone_a", "zone_c"].
    • heavy_amr: Max speed 1.0\text{ m/s}, acceleration 0.5\text{ m/s}^2, turning rate 60^\circ/\text{s}, payload capacity 1200\text{ kg}, battery capacity 6.0\text{ kWh}, power consumption (2.5\text{ kW} moving, 0.25\text{ kW} idle, 0.8\text{ kW} loaded), allowed zones ["zone_a", "zone_b", "zone_c"].
    • Fleet: 4 AMRs (amr_light_01, amr_light_02, amr_heavy_01, amr_heavy_02) initialized at charging bays 1–4.
  • config/inventory.json:
    • 13 distinct SKUs across 3 categories (fast moving, slow moving / heavy, raw materials).
  • config/simulation.json:
    • Duration 3,600s, random seed 42, warm-up 300s, dispatch interval 5.0s, low-battery threshold 20%, charge-complete threshold 95%.

4. Architecture and Design Decisions

  1. Explicit Discrete State Machine Transitions:
    • LEGAL_ROBOT_TRANSITIONS and LEGAL_TASK_TRANSITIONS enforce strict operational lifecycles.
    • Any disallowed jump (e.g., IDLE -> DROPPING or COMPLETED -> IN_PROGRESS) raises InvalidStateTransitionError.
  2. Pre-Assignment Compatibility Checks:
    • Robot.validate_task_compatibility(task) checks both payload capacity and spatial accessibility. If a light_amr is assigned a 650\text{ kg} engine transmission or a task located in zone_b, an IncompatibleRobotTaskError is raised before dispatch.
  3. State of Charge (SoC) and Linear Energy Dynamics:
    • Robot battery consumption scales with operational mode (kw * hours) and charges at the rate of the station (10\text{ kW} DC fast-charging). Battery percent is clamped safely between 0.0\% and 100.0\%.
  4. Decoupled Event Streaming Model:
    • SimulationEvent encapsulates structured event telemetry with ISO8601 formatting and JSONL serialization, enabling zero-overhead disk streaming without memory buildup.
  5. OpenUSD Composition Architecture:
    • Generated OpenUSD .usda files use Z-up, 1.0m units, standard transforms (xformOp:translate, xformOp:rotateZ, xformOp:scale), and display colors compatible with Omniverse Kit 110.4.

5. Code Structure and Module Descriptions

src/warehouse_twin/
├── domain/
│   ├── __init__.py           # Re-exports all domain models
│   ├── events.py             # SimulationEventType and SimulationEvent telemetry
│   ├── inventory.py          # InventoryItem and InventoryCatalog
│   ├── robot.py              # RobotState, RobotTypeSpec, Robot model, legal transitions
│   ├── task.py               # TaskType, TaskStatus, Task model, legal transitions
│   └── warehouse.py          # Spatial layout, ZoneArea, Station, StorageLocation
└── interfaces/
    └── usd_generator.py      # WarehouseUSDGenerator with AMR fleet rendering

6. Integration Points with Previous Phases

  • Phase 0 (Foundation): Consumes configuration bundles loaded by ConfigLoader (ConfigBundle.robots, ConfigBundle.inventory, ConfigBundle.simulation). Utilizes rotating file logging (application.log, simulation.log).
  • Phase 1 (Warehouse Model): Coordinates robot positions with warehouse coordinate spaces (Position3D) and validates zone compatibility against zone definitions established in WarehouseModel.

7. Verification and Testing Results

  • Unit Test Suite: 56 passing tests across 8 test suites in 0.24 seconds.
    tests/unit/test_config_loader.py    9 passed
    tests/unit/test_environment.py      5 passed
    tests/unit/test_events_model.py     1 passed
    tests/unit/test_inventory_model.py  4 passed
    tests/unit/test_logging.py          3 passed
    tests/unit/test_robot_model.py     14 passed
    tests/unit/test_task_model.py       9 passed
    tests/unit/test_warehouse_graph.py 11 passed
    ============================== 56 passed in 0.24s ==============================
    
  • CLI Validation:
    • warehouse-twin validate-config: PASSED (5/5 configs valid).
    • warehouse-twin validate-graph: PASSED (540 nodes, 1730 edges, strongly connected).
    • warehouse-twin export-usd: PASSED (exported omniverse/scenes/warehouse_phase2.usda).

8. Known Limitations and Assumptions

  • Kinematics in Phase 2 use simplified acceleration and average traversal speed formulas. Multi-agent collision avoidance (RVO2/ORCA) and dynamic path conflict resolution are slated for Phase 4.
  • Charging rate is modeled as constant current up to capacity; non-linear battery degradation curves are not implemented.

9. Instructions for Running and Validating

Run the Test Suite

./.venv/bin/pytest tests/

Validate Config and Export Phase 2 USD Scene

./.venv/bin/warehouse-twin validate-config
./.venv/bin/warehouse-twin export-usd --output omniverse/scenes/warehouse_phase2.usda

10. Next Phase Dependencies and Handoff

  • Phase 3 (Discrete-Event Simulation) will consume:
    • Robot instances and RobotState transitions to drive SimPy simulation processes.
    • Task queueing, generation processes, and SLA timeout timers.
    • InventoryCatalog for replenishment triggers when picking tasks decrement inventory below reorder thresholds.
    • Event telemetry generator for discrete logging.

11. Artifacts and Output Files

  • omniverse/scenes/warehouse_phase2.usda: OpenUSD 3D stage with facility and 4 AMRs.
  • results/reports/warehouse_graph.json: Serialized topological navigation graph.
  • logs/application.log: Application logging output.