feat(phase-0): initialize project foundation, packaging, logging, configs, and tests
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
# API and Data Contracts
|
||||
|
||||
This document formalizes the data interchange models between the simulation engine, event logging, trajectory output, and the Omniverse visualizer.
|
||||
|
||||
---
|
||||
|
||||
## 1. Domain Data Models
|
||||
|
||||
### 1.1 Robot Model (`Robot`)
|
||||
```json
|
||||
{
|
||||
"robot_id": "amr_light_01",
|
||||
"robot_type": "light_amr",
|
||||
"position": [2.0, 36.0, 0.0],
|
||||
"maximum_speed": 1.8,
|
||||
"payload_capacity": 150.0,
|
||||
"battery_level": 3.0,
|
||||
"battery_capacity": 3.0,
|
||||
"energy_consumption": {
|
||||
"idle_kw": 0.05,
|
||||
"moving_empty_kw": 0.35,
|
||||
"moving_loaded_kw": 0.65,
|
||||
"handling_kw": 0.15
|
||||
},
|
||||
"current_state": "IDLE",
|
||||
"current_task_id": null,
|
||||
"current_route": [],
|
||||
"accumulated_distance": 0.0,
|
||||
"busy_time": 0.0,
|
||||
"idle_time": 0.0,
|
||||
"charging_time": 0.0
|
||||
}
|
||||
```
|
||||
|
||||
### 1.2 Robot State Enumeration
|
||||
- `IDLE`: Stationed at node, awaiting assignment.
|
||||
- `DISPATCHED`: En route to pickup station or warehouse storage rack.
|
||||
- `PICKING`: Handling/loading cargo at source.
|
||||
- `LOADED_TRANSIT`: En route to dropoff destination with payload.
|
||||
- `DROPPING`: Unloading cargo at destination.
|
||||
- `TRANSIT_TO_CHARGE`: Traveling to assigned charging station.
|
||||
- `CHARGING`: Actively recharging at charging bay.
|
||||
- `MAINTENANCE` / `ERROR`: Out of service.
|
||||
|
||||
### 1.3 Task Model (`Task`)
|
||||
```json
|
||||
{
|
||||
"task_id": "task_ord_00101",
|
||||
"task_type": "ORDER_PICK",
|
||||
"source": "rack_a_01",
|
||||
"destination": "picking_station_a1",
|
||||
"priority": 1,
|
||||
"release_time": 124.5,
|
||||
"deadline": 424.5,
|
||||
"required_payload": 25.0,
|
||||
"status": "COMPLETED",
|
||||
"assigned_robot_id": "amr_light_01",
|
||||
"completion_time": 312.0
|
||||
}
|
||||
```
|
||||
|
||||
### 1.4 Task Types
|
||||
- `ORDER_PICK`: Fulfilling an outbound picking order (predominantly Zone A & B).
|
||||
- `REPLENISHMENT`: Inbound dock to storage rack restocking.
|
||||
- `PRODUCTION_LINE_FEED`: Time-critical material transfer to production line (Zone C).
|
||||
- `CHARGING`: Internal battery maintenance dispatch.
|
||||
|
||||
---
|
||||
|
||||
## 2. Simulation Event Record Schema
|
||||
|
||||
Events recorded in `logs/simulation.log` and exported to `results/experiments/events.jsonl`:
|
||||
|
||||
```json
|
||||
{
|
||||
"event_id": "evt_000984",
|
||||
"simulation_time": 128.5,
|
||||
"event_type": "TASK_DISPATCHED",
|
||||
"entity_id": "amr_light_01",
|
||||
"task_id": "task_ord_00101",
|
||||
"metadata": {
|
||||
"source": "rack_a_01",
|
||||
"destination": "picking_station_a1",
|
||||
"route_length_m": 24.0,
|
||||
"estimated_duration_s": 15.2,
|
||||
"battery_soc_pct": 94.2
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Trajectory Export Schema (For Omniverse USD Playback)
|
||||
|
||||
Saved under `results/trajectories/trajectory_<run_id>.json`:
|
||||
|
||||
```json
|
||||
{
|
||||
"metadata": {
|
||||
"simulation_run_id": "sim_20261019_144000",
|
||||
"time_step_seconds": 0.5,
|
||||
"coordinate_system": "right_handed_cartesian_meters_z_up",
|
||||
"total_duration_seconds": 3600.0
|
||||
},
|
||||
"robots": {
|
||||
"amr_light_01": [
|
||||
{
|
||||
"t": 0.0,
|
||||
"pos": [2.0, 36.0, 0.0],
|
||||
"yaw_deg": 0.0,
|
||||
"state": "IDLE"
|
||||
},
|
||||
{
|
||||
"t": 0.5,
|
||||
"pos": [2.0, 35.1, 0.0],
|
||||
"yaw_deg": 180.0,
|
||||
"state": "DISPATCHED"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,100 @@
|
||||
# Warehouse Robot Fleet Digital Twin: Architecture
|
||||
|
||||
## 1. Executive Overview
|
||||
|
||||
The Warehouse Robot Fleet Digital Twin is a modular, event-driven simulation and 3D visualization platform engineered to model, analyze, and optimize autonomous mobile robot (AMR) fleet operations in multi-zone industrial facilities.
|
||||
|
||||
The architecture strictly decouples:
|
||||
1. **Core Simulation Engine**: Discrete-event logic, fleet dispatching, path reservation, battery dynamics, and inventory state.
|
||||
2. **Data & Storage Layer**: Structured simulation event logs (JSONL/CSV), KPI aggregations, and trajectory records.
|
||||
3. **Visualization & Digital Twin Layer**: NVIDIA Omniverse Kit, OpenUSD scene hierarchy, and trajectory playback.
|
||||
4. **Analytics & Optimization Layer**: Reporting, congestion heatmaps, and scenario comparisons.
|
||||
|
||||
This decoupling guarantees that the simulation runs headlessly and deterministically without requiring a GPU, display server, NVIDIA Isaac Sim, or Omniverse Kit. Visualization is an asynchronous consumer of simulation outputs.
|
||||
|
||||
```
|
||||
+-----------------------------------------------------------------------------------+
|
||||
| CONFIG & INPUT LAYER |
|
||||
| config/warehouse.json config/robots.json config/inventory.json config/... |
|
||||
+-----------------------------------------------------------------------------------+
|
||||
|
|
||||
v
|
||||
+-----------------------------------------------------------------------------------+
|
||||
| DISCRETE-EVENT SIMULATION ENGINE |
|
||||
| +------------------------+ +------------------------+ +---------------------+ |
|
||||
| | SimPy Clock & | | NetworkX Routing | | Fleet Dispatch | |
|
||||
| | Event Loop | | & Time-Space Resv. | | & Battery Mgr | |
|
||||
| +------------------------+ +------------------------+ +---------------------+ |
|
||||
| +------------------------+ +------------------------+ +---------------------+ |
|
||||
| | Order & Replenish | | Zone A, B, C Logic | | AMR State Machine | |
|
||||
| | Generators | | & Capacity Checks | | Controllers | |
|
||||
| +------------------------+ +------------------------+ +---------------------+ |
|
||||
+-----------------------------------------------------------------------------------+
|
||||
|
|
||||
v
|
||||
+-----------------------------------------------------------------------------------+
|
||||
| DATA OUTPUTS & STORAGE INTERFACE |
|
||||
| logs/simulation.log results/trajectories/robot_paths.json |
|
||||
| results/experiments/events.jsonl results/reports/kpis.json |
|
||||
+-----------------------------------------------------------------------------------+
|
||||
| |
|
||||
v v
|
||||
+-----------------------------------------+ +-------------------------------------+
|
||||
| OMNIVERSE VISUALIZATION | | ANALYTICS & KPI |
|
||||
| Kit 110.4 + OpenUSD Playback | | Throughput, Robot Utilization, |
|
||||
| USD Prims / Live Kit Extension | | Aisle Congestion, Latency Heatmaps |
|
||||
+-----------------------------------------+ +-------------------------------------+
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. Decoupled Subsystems
|
||||
|
||||
### 2.1 Domain Layer (`warehouse_twin.domain`)
|
||||
Defines immutable data classes, domain models, and strict type-checked enums:
|
||||
- **Robot**: ID, type, physical specs, payload limits, battery state, kinematics, state machine.
|
||||
- **Task**: ID, category (order pick, restocking, production-feed), priority, release time, deadline, status.
|
||||
- **Inventory**: SKU ID, category (Zone A fast, Zone B heavy, Zone C production raw), quantity, lot size, min stock.
|
||||
- **Warehouse**: Dimensions, nodes, coordinate system, zone definitions, docks, charging bays.
|
||||
- **Events**: Canonical simulation events emitted to storage and logging.
|
||||
|
||||
### 2.2 Simulation Engine (`warehouse_twin.simulation`)
|
||||
Built on `SimPy`:
|
||||
- Event loop with microsecond-level discrete-event scheduling.
|
||||
- Separate simulation clock (`sim_time`) independent of host execution wall-clock time.
|
||||
- Deterministic random seed propagation (`random.Random` instances, no unseeded globals).
|
||||
- Order generators parameterized by zone throughput and peak demand windows.
|
||||
|
||||
### 2.3 Routing & Traffic Management (`warehouse_twin.routing`)
|
||||
- Graph representation of warehouse floor using `NetworkX`.
|
||||
- Spatio-temporal reservation table to prevent head-on collisions and deadlocks in narrow aisles.
|
||||
- Kinematic path travel times calculated from acceleration, top speed, and turning constraints.
|
||||
|
||||
### 2.4 Fleet Management (`warehouse_twin.fleet`)
|
||||
- Task dispatcher with pluggable policies (`priority_nearest_idle`, `balanced_utilization`).
|
||||
- Battery manager monitoring state of charge (SoC) and enforcing opportunity charging thresholds.
|
||||
- Safe preemption and task reassignment if an AMR encounters an unexpected delay or low battery.
|
||||
|
||||
### 2.5 Storage & Interfaces (`warehouse_twin.storage`, `warehouse_twin.interfaces`)
|
||||
- Streamed JSONL event logs.
|
||||
- Interpolated 3D trajectory generator producing time-indexed Cartesian coordinates `(x, y, z, yaw, state)`.
|
||||
|
||||
### 2.6 Omniverse USD Visualization (`omniverse/`)
|
||||
- Utilizes NVIDIA Omniverse Kit 110.4.
|
||||
- Reads exported trajectory JSON and updates USD prim transforms on each Kit update tick (`omni.kit.app.get_app().get_update_event_stream()`).
|
||||
- Clean teardown without dangling event subscriptions.
|
||||
|
||||
---
|
||||
|
||||
## 3. Coordinate System & Measurement Units
|
||||
|
||||
| Dimension | Unit | Description |
|
||||
| :--- | :--- | :--- |
|
||||
| **Coordinate System** | Right-Handed Cartesian | X = East (Width), Y = North (Depth), Z = Up (Height) |
|
||||
| **Distance** | Meters (m) | Standard SI units for all node coordinates and dimensions |
|
||||
| **Linear Velocity** | Meters per second (m/s) | Robot speed limits and travel rates |
|
||||
| **Acceleration** | Meters per second² (m/s²) | Ramp-up and braking kinematics |
|
||||
| **Mass / Payload** | Kilograms (kg) | Payload constraints and inventory weights |
|
||||
| **Energy / Battery** | Kilowatt-hours (kWh) | Battery pack capacity and residual energy |
|
||||
| **Power Rate** | Kilowatts (kW) | Consumption (idle, moving, lifting) and charging rate |
|
||||
| **Time** | Seconds (s) | Discrete-event simulation clock |
|
||||
@@ -0,0 +1,45 @@
|
||||
# Architecture Decision Records (ADRs)
|
||||
|
||||
## ADR-001: Separation of Discrete-Event Simulation from 3D Visualization
|
||||
- **Status**: Accepted
|
||||
- **Context**: Omniverse Kit and USD are powerful visualization engines, but coupling simulation logic directly into Kit extension update loops slows testing, complicates continuous integration, and ties discrete event timing to render frame rates.
|
||||
- **Decision**: Keep the discrete-event simulation engine in pure standard Python. The simulation will export time-indexed trajectories (JSON) and event logs. Omniverse Kit will consume these trajectories in Phase 7 as an asynchronous visualizer.
|
||||
- **Consequences**: Fast test execution (headless in < 1s), zero GPU requirement for algorithmic development, clear data interchange boundaries.
|
||||
|
||||
---
|
||||
|
||||
## ADR-002: Discrete-Event Engine with SimPy & NetworkX
|
||||
- **Status**: Accepted
|
||||
- **Context**: Need a lightweight, deterministic framework for managing asynchronous robot events (orders, traveling, picking, battery discharge, recharging).
|
||||
- **Decision**: Use `SimPy` for the event-scheduling loop and `NetworkX` for graph-based warehouse topology and shortest-path calculation.
|
||||
- **Consequences**: Highly deterministic runs via seeded random streams; no heavy external robotics simulator dependencies during core fleet logic development.
|
||||
|
||||
---
|
||||
|
||||
## ADR-003: Standalone Operation Without Isaac Sim Dependency
|
||||
- **Status**: Accepted
|
||||
- **Context**: Isaac Sim requires substantial disk space (~30-50+ GB) and the host root drive `/dev/nvme0n1p4` is constrained with only ~8.9 GB free.
|
||||
- **Decision**: Do not require Isaac Sim. Rely on discrete-event kinematics for robot movement. Ensure data models (coordinates, states, speeds) conform to standard robotics conventions so Isaac Sim can be integrated in the future without architectural redesign.
|
||||
- **Consequences**: Enables immediate development on the user's host without risking disk exhaustion.
|
||||
|
||||
---
|
||||
|
||||
## ADR-004: Low-Disk-Space Mitigation and Secondary Drive Relocation
|
||||
- **Status**: Accepted
|
||||
- **Context**: The root filesystem is at 99% capacity (~8.9 GB free). Simulation logs and trajectory files could exhaust space if unconstrained.
|
||||
- **Decision**:
|
||||
1. Enforce size-capped rotating log handlers (`RotatingFileHandler` with 10MB limits and 5 backups).
|
||||
2. Implement an optional `WAREHOUSE_TWIN_SECONDARY_DRIVE` environment variable. When set, all large outputs (`logs/`, `results/`) are redirected to the specified secondary path.
|
||||
3. Include disk space warnings in `check_environment.sh` and CLI `validate-env`.
|
||||
- **Consequences**: Prevents host crash due to accidental root drive fill-up.
|
||||
|
||||
---
|
||||
|
||||
## ADR-005: Structured Logging with Rotating Handlers
|
||||
- **Status**: Accepted
|
||||
- **Context**: Need separate logging streams for diagnostic debugging versus simulation event auditing, with automatic size limits.
|
||||
- **Decision**: Provide three dedicated streams:
|
||||
1. `application.log`: Component lifecycle, config loading, and diagnostic info.
|
||||
2. `simulation.log`: High-resolution simulation events with timestamp and entity tracking.
|
||||
3. `errors.log`: Error and critical level events with full stack traces.
|
||||
- **Consequences**: Clean separation of operational concerns, easy debugging, bounded disk usage.
|
||||
@@ -0,0 +1,76 @@
|
||||
# Installation and Setup Guide
|
||||
|
||||
## 1. Prerequisites
|
||||
|
||||
- **Operating System**: Ubuntu Linux 22.04 LTS or 24.04 LTS (Tested on Ubuntu 24.04.3 LTS).
|
||||
- **Python**: Version 3.10, 3.11, or 3.12 (Host has Python 3.12.3).
|
||||
- **GPU** (For 3D visualization only): NVIDIA RTX GPU with modern driver (Tested on NVIDIA RTX 5090 with driver 580.178.04).
|
||||
- **Disk Space**: At least 500 MB free for simulation, virtual environment, and initial outputs. (Host currently has ~8.9 GB free on `/dev/nvme0n1p4`).
|
||||
- **NVIDIA Isaac Sim**: **NOT required**. The simulation engine is completely standalone.
|
||||
|
||||
---
|
||||
|
||||
## 2. Setting Up the Virtual Environment
|
||||
|
||||
From the project root:
|
||||
|
||||
```bash
|
||||
cd /home/dmhai/warehouse-digital-twin
|
||||
|
||||
# Create virtual environment if not already present
|
||||
python3 -m venv .venv
|
||||
|
||||
# Activate virtual environment
|
||||
source .venv/bin/activate
|
||||
|
||||
# Upgrade pip and install package in editable mode
|
||||
pip install --upgrade pip
|
||||
pip install -e .
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Verifying the Setup
|
||||
|
||||
Run the automated environment check script:
|
||||
|
||||
```bash
|
||||
./scripts/check_environment.sh
|
||||
```
|
||||
|
||||
Or invoke the Python CLI directly:
|
||||
|
||||
```bash
|
||||
warehouse-twin validate-env
|
||||
warehouse-twin validate-config
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. Running the Automated Tests
|
||||
|
||||
Execute the unit test suite:
|
||||
|
||||
```bash
|
||||
./scripts/run_tests.sh
|
||||
```
|
||||
|
||||
Or using pytest with options:
|
||||
|
||||
```bash
|
||||
pytest tests/ -v
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. Storage Relocation (For Disk-Constrained Systems)
|
||||
|
||||
If your system drive `/` is low on disk space (e.g., < 2 GB), configure environment variables in `.env` or in your shell to redirect generated logs and simulation results to an external or secondary drive:
|
||||
|
||||
```bash
|
||||
export WAREHOUSE_TWIN_SECONDARY_DRIVE="/media/external/warehouse_data"
|
||||
```
|
||||
|
||||
When set, the simulation will automatically place logs and output results under:
|
||||
- `$WAREHOUSE_TWIN_SECONDARY_DRIVE/logs/`
|
||||
- `$WAREHOUSE_TWIN_SECONDARY_DRIVE/results/`
|
||||
@@ -0,0 +1,47 @@
|
||||
# Testing Strategy and Test Suites
|
||||
|
||||
## 1. Testing Philosophy
|
||||
|
||||
The test suite validates correctness, repeatability, schema integrity, and boundary conditions at each phase.
|
||||
|
||||
Core principles:
|
||||
- **Zero Isaac Sim / Omniverse dependency**: Unit and simulation tests run cleanly in headless environments without graphical displays or NVIDIA Kit runtime.
|
||||
- **Fast execution**: Unit tests execute in under 1 second to encourage continuous verification during development.
|
||||
- **Deterministic fixtures**: Temporary fixtures isolate filesystem effects and ensure tests do not pollute real logs or results.
|
||||
|
||||
---
|
||||
|
||||
## 2. Test Structure
|
||||
|
||||
```
|
||||
tests/
|
||||
├── __init__.py
|
||||
├── conftest.py # Shared fixtures (temp config, mock objects)
|
||||
├── unit/
|
||||
│ ├── __init__.py
|
||||
│ ├── test_environment.py # System dependencies, Python version, disk checks
|
||||
│ ├── test_logging.py # Log file creation, severity routing, log rotation
|
||||
│ └── test_config_loader.py # JSON schema checks, missing keys, validations
|
||||
├── integration/ # Multi-component integration tests (Phase 3+)
|
||||
├── scenarios/ # Scenario workloads: normal, peak, line outages (Phase 6+)
|
||||
└── fixtures/ # Static deterministic datasets
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Running Tests
|
||||
|
||||
### 3.1 All Tests
|
||||
```bash
|
||||
./scripts/run_tests.sh
|
||||
```
|
||||
|
||||
### 3.2 Specific Test File
|
||||
```bash
|
||||
.venv/bin/pytest tests/unit/test_config_loader.py -v
|
||||
```
|
||||
|
||||
### 3.3 With Coverage (when pytest-cov is installed)
|
||||
```bash
|
||||
.venv/bin/pytest tests/ --cov=warehouse_twin
|
||||
```
|
||||
@@ -0,0 +1,66 @@
|
||||
# User Guide: Warehouse Robot Fleet Digital Twin
|
||||
|
||||
## 1. Quick Start
|
||||
|
||||
Activate the project virtual environment before running commands:
|
||||
|
||||
```bash
|
||||
cd /home/dmhai/warehouse-digital-twin
|
||||
source .venv/bin/activate
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 2. Command-Line Reference
|
||||
|
||||
The main executable CLI is `warehouse-twin` (also accessible via `python -m warehouse_twin.main`).
|
||||
|
||||
### 2.1 Validate Environment
|
||||
Checks Python version, disk capacity, installed simulation libraries, log directory writability, and Omniverse Kit paths:
|
||||
|
||||
```bash
|
||||
warehouse-twin validate-env
|
||||
```
|
||||
|
||||
### 2.2 Validate Configuration Files
|
||||
Validates all 5 configuration files (`warehouse.json`, `robots.json`, `inventory.json`, `simulation.json`, `dispatch_policies.json`) against schema constraints:
|
||||
|
||||
```bash
|
||||
warehouse-twin validate-config
|
||||
```
|
||||
|
||||
Specify a custom configuration directory:
|
||||
|
||||
```bash
|
||||
warehouse-twin validate-config --config-dir /path/to/custom/config
|
||||
```
|
||||
|
||||
### 2.3 Check Version
|
||||
Display installed package version:
|
||||
|
||||
```bash
|
||||
warehouse-twin --version
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. Configuring the Simulation
|
||||
|
||||
All simulation behaviors are externalized in JSON configuration files located under `config/`:
|
||||
|
||||
| File | Purpose |
|
||||
| :--- | :--- |
|
||||
| `config/warehouse.json` | Warehouse dimensions, zones (Zone A, B, C), stations, docks, and charging bays. |
|
||||
| `config/robots.json` | Robot definitions (Light AMR, Heavy AMR), battery capacities, power consumption rates, initial fleet positions. |
|
||||
| `config/inventory.json` | Catalog of items across Fast-moving, Slow-moving, and Production-supply zones, initial stock, and replenishment parameters. |
|
||||
| `config/simulation.json` | Simulation duration, time resolution, random seed, and zone arrival rates. |
|
||||
| `config/dispatch_policies.json` | Pluggable dispatch algorithms, reservation rules, and charging trigger thresholds. |
|
||||
|
||||
---
|
||||
|
||||
## 4. Operational Logs
|
||||
|
||||
Logs are automatically rotated and organized into three streams under `logs/`:
|
||||
- `logs/application.log`: Application lifecycle, component configuration, and operational diagnostics.
|
||||
- `logs/simulation.log`: High-resolution simulation events (order arrival, dispatch, pick, transit, delivery).
|
||||
- `logs/errors.log`: Filtered log containing only ERROR and CRITICAL exceptions.
|
||||
@@ -0,0 +1,161 @@
|
||||
# Phase 0 Implementation Report: Environment and Foundation
|
||||
|
||||
## 1. Phase Objective
|
||||
Establish a clean, reproducible, and robust software foundation for the Warehouse Robot Fleet Digital Twin. This includes inspecting the host Ubuntu environment and Omniverse Kit installation, configuring the Python virtual environment and packaging, implementing structured and rotating logging, establishing configuration loading and schema validation, providing automated environment verification scripts, and delivering a unit test suite verifying the foundation.
|
||||
|
||||
---
|
||||
|
||||
## 2. Requirements
|
||||
- Inspect Ubuntu version, Python interpreter, available disk space, GPU details, and existing Omniverse Kit installation.
|
||||
- Establish project directory structure strictly conforming to the master implementation blueprint.
|
||||
- Implement standard Python packaging (`pyproject.toml`) with editable install support.
|
||||
- Implement structured rotating logging with dedicated handlers for application diagnostics, simulation events, and errors.
|
||||
- Implement configuration loading and validation for all 5 core configuration domains (`warehouse.json`, `robots.json`, `inventory.json`, `simulation.json`, `dispatch_policies.json`).
|
||||
- Provide an automated environment validation script (`scripts/check_environment.sh`) and CLI (`warehouse-twin validate-env`).
|
||||
- Implement unit tests covering environment checks, logging rotation, and configuration validation without requiring Isaac Sim or Omniverse Kit.
|
||||
|
||||
---
|
||||
|
||||
## 3. Design Decisions
|
||||
- **Decoupled Architecture**: Keep the discrete-event simulation engine in standard Python using `SimPy` and `NetworkX`, separate from Kit's rendering loop.
|
||||
- **Disk Space Safeguards**: Given the 99% used root partition (~8.9 GB free), set strict 10 MB caps on rotating logs, exclude all large logs and results from git via `.gitignore`, and add support for the `WAREHOUSE_TWIN_SECONDARY_DRIVE` environment variable.
|
||||
- **No Isaac Sim Dependency**: Develop the full fleet scheduling, kinematics, and routing models headlessly.
|
||||
- **Kit 110.4 Compatibility**: Inspected the running Kit application at `/home/dmhai/nvidia-omniverse/kit-app-template` (Kit version 110.4.0) to ensure the eventual Phase 7 extension and USD trajectories seamlessly match Kit's extension mechanisms.
|
||||
|
||||
---
|
||||
|
||||
## 4. Files Created or Modified
|
||||
|
||||
| File | Description |
|
||||
| :--- | :--- |
|
||||
| `pyproject.toml` | PEP 517/621 packaging metadata, dependencies, scripts, pytest configuration. |
|
||||
| `.gitignore` | Excludes venv, pycache, build artifacts, raw logs, and result files while preserving directories. |
|
||||
| `.env.example` | Environment variable template including secondary drive relocation and Kit paths. |
|
||||
| `config/warehouse.json` | 60x40m warehouse layout with Zones A, B, C, stations, and charging bays. |
|
||||
| `config/robots.json` | Robot definitions (Light AMR, Heavy AMR), battery capacities, power models, initial fleet. |
|
||||
| `config/inventory.json` | Item catalogs for Zones A, B, and C with stock levels, weights, and replenishment batches. |
|
||||
| `config/simulation.json` | Discrete-event parameters: 3600s duration, seed 42, arrival rates, peak multipliers. |
|
||||
| `config/dispatch_policies.json` | Dispatch policy settings, reservation window, and charging rules. |
|
||||
| `src/warehouse_twin/__init__.py` | Package root with version `0.1.0`. |
|
||||
| `src/warehouse_twin/logging_config.py` | Structured rotating logging with `application.log`, `simulation.log`, and `errors.log`. |
|
||||
| `src/warehouse_twin/config/loader.py` | `ConfigLoader` and schema validators for all configuration files. |
|
||||
| `src/warehouse_twin/config/__init__.py` | Exports `ConfigLoader`, `ConfigBundle`, and `ConfigurationError`. |
|
||||
| `src/warehouse_twin/cli.py` | Command-line interface with `validate-env` and `validate-config`. |
|
||||
| `src/warehouse_twin/main.py` | Main entry point for `python -m warehouse_twin.main`. |
|
||||
| `scripts/check_environment.sh` | Shell script verifying system, disk, GPU, Kit, and Python packages. |
|
||||
| `scripts/run_tests.sh` | Automated test runner script. |
|
||||
| `tests/__init__.py` | Tests root package init. |
|
||||
| `tests/conftest.py` | Pytest fixtures providing temporary test configs and paths. |
|
||||
| `tests/unit/__init__.py` | Unit tests package init. |
|
||||
| `tests/unit/test_environment.py` | Unit tests for Python version, package imports, and disk checks. |
|
||||
| `tests/unit/test_logging.py` | Unit tests for log creation, severity routing, and file rotation. |
|
||||
| `tests/unit/test_config_loader.py` | Unit tests for config loading, missing file errors, and validation checks. |
|
||||
| `docs/ARCHITECTURE.md` | Comprehensive system architecture specification. |
|
||||
| `docs/INSTALLATION.md` | Setup and environment guide. |
|
||||
| `docs/USER_GUIDE.md` | CLI instructions and configuration documentation. |
|
||||
| `docs/API_AND_DATA_CONTRACTS.md` | Data models and serialization schemas. |
|
||||
| `docs/TESTING.md` | Test strategy and execution guide. |
|
||||
| `docs/DECISIONS.md` | Architecture Decision Records (ADRs 001 - 005). |
|
||||
| `omniverse/README.md` | Kit 110.4 integration strategy and trajectory playback design. |
|
||||
| `README.md` | Master project documentation. |
|
||||
| `IMPLEMENTATION_DETAILS.md` | Engineering implementation details across all modules. |
|
||||
| `PROJECT_STATUS.md` | Phase tracking and task status. |
|
||||
| `CHANGELOG.md` | Version change history. |
|
||||
|
||||
---
|
||||
|
||||
## 5. Implementation Explanation
|
||||
|
||||
### Environment Inspection Findings
|
||||
- **Host OS**: Ubuntu 24.04.3 LTS (Kernel 7.0.0-38-generic).
|
||||
- **Python**: System Python 3.12.3 at `/usr/bin/python3`. Virtual environment at `/home/dmhai/warehouse-digital-twin/.venv`.
|
||||
- **Disk Space**: Primary NVMe drive `/dev/nvme0n1p4` mounted at `/` has 886 GB total, 832 GB used, and **8.9 GB free (99% full)**. No secondary drives are currently mounted.
|
||||
- **GPU**: NVIDIA GeForce RTX 5090 (32,607 MiB VRAM), Driver 580.178.04, CUDA 13.0.
|
||||
- **NVIDIA Omniverse Kit**: Located at `/home/dmhai/nvidia-omniverse/kit-app-template/_build/linux-x86_64/release/kit/kit` running Kit Version **110.4.0+feature.386251.187cf21b.gl** with app template `warehouse_twin.kit`.
|
||||
|
||||
### Logging Subsystem
|
||||
Configured using standard library `logging.handlers.RotatingFileHandler`. To prevent unbounded log growth on the disk-constrained drive, each log file defaults to a 10 MB limit with up to 5 backups. Handlers are segregated:
|
||||
- Console: INFO level.
|
||||
- `application.log`: DEBUG level, formatted with timestamp, level, module name, and line number.
|
||||
- `simulation.log`: High-frequency simulation events with format `%(asctime)s [SIM_EVENT] %(message)s`.
|
||||
- `errors.log`: Filtered strictly to ERROR and CRITICAL.
|
||||
|
||||
### Configuration Subsystem
|
||||
`ConfigLoader` parses the 5 project JSON files. It verifies spatial dimensions, coordinates, zone keys, robot attributes, fleet associations, inventory catalog records, and simulation execution limits. If any key is invalid or missing, it raises a specific `ConfigurationError` identifying the file, line, and attribute.
|
||||
|
||||
---
|
||||
|
||||
## 6. Commands Executed and Outcomes
|
||||
|
||||
1. **Environment inspection**:
|
||||
`df -h && lsb_release -a && python3 --version && nvidia-smi` -> Verified Ubuntu 24.04, Python 3.12.3, RTX 5090, 8.9 GB free.
|
||||
2. **Kit process inspection**:
|
||||
`ps aux | grep kit` -> Found active Kit 110.4 process using app `warehouse_twin.kit`.
|
||||
3. **Editable package installation**:
|
||||
`.venv/bin/pip install -e .` -> Successfully built and installed `warehouse-digital-twin-0.1.0`.
|
||||
4. **CLI verification**:
|
||||
`.venv/bin/warehouse-twin --version` -> Output: `warehouse-twin 0.1.0`.
|
||||
`.venv/bin/warehouse-twin validate-env` -> PASSED: 0 failures, 1 warning (low disk space).
|
||||
`.venv/bin/warehouse-twin validate-config` -> PASSED: all 5 config files valid.
|
||||
5. **Shell script execution**:
|
||||
`./scripts/check_environment.sh` -> Completed successfully with zero exit code.
|
||||
6. **Test execution**:
|
||||
`./scripts/run_tests.sh` -> 17 passed in 0.09s.
|
||||
|
||||
---
|
||||
|
||||
## 7. Tests and Their Results
|
||||
|
||||
```
|
||||
============================== 17 passed in 0.09s ==============================
|
||||
- tests/unit/test_config_loader.py: 9 passed
|
||||
* test_load_real_project_configurations
|
||||
* test_missing_config_file_raises_error
|
||||
* test_invalid_json_syntax_raises_error
|
||||
* test_missing_warehouse_zone_raises_error
|
||||
* test_invalid_warehouse_dimensions_raises_error
|
||||
* test_undefined_robot_type_raises_error
|
||||
* test_duplicate_item_id_in_inventory_raises_error
|
||||
* test_invalid_active_dispatch_policy_raises_error
|
||||
* test_config_dir_env_var_override
|
||||
- tests/unit/test_environment.py: 5 passed
|
||||
* test_package_metadata
|
||||
* test_python_version
|
||||
* test_required_dependencies_importable
|
||||
* test_check_environment_passes
|
||||
* test_check_environment_detects_low_disk
|
||||
- tests/unit/test_logging.py: 3 passed
|
||||
* test_logging_directory_creation
|
||||
* test_log_files_created_and_written
|
||||
* test_log_file_rotation
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 8. Expected Outputs
|
||||
- `logs/application.log`, `logs/simulation.log`, `logs/errors.log` created when logging is active.
|
||||
- CLI exit code 0 when environment and configs are healthy.
|
||||
- Fast unit test output completing in < 0.2s without requiring Isaac Sim or Kit.
|
||||
|
||||
---
|
||||
|
||||
## 9. Known Issues & Risks
|
||||
- **Primary Disk Space**: The `/` partition has only ~8.9 GB free (99% full). Mitigation is in place via rotating logs, gitignore, and the `WAREHOUSE_TWIN_SECONDARY_DRIVE` variable. Isaac Sim must NOT be installed.
|
||||
- **Kit 110.4 Python environment**: Kit runs an embedded Python 3.12 interpreter. Discrete event simulation runs cleanly in the project `.venv` (Python 3.12.3), which matches Kit's Python version.
|
||||
|
||||
---
|
||||
|
||||
## 10. Acceptance Criteria Checklist
|
||||
- [x] The Python package can be imported.
|
||||
- [x] Environment checks work.
|
||||
- [x] Logging creates and rotates files.
|
||||
- [x] Configuration loads successfully.
|
||||
- [x] Tests run without requiring Isaac Sim.
|
||||
- [x] Documentation reflects the actual environment.
|
||||
|
||||
---
|
||||
|
||||
## 11. Next-Phase Dependencies
|
||||
Phase 1 (Warehouse Model) depends on:
|
||||
- Validated `config/warehouse.json` (completed).
|
||||
- `NetworkX` graph builder to convert nodes, zones, and stations into a navigational graph with distance and restriction attributes.
|
||||
Reference in New Issue
Block a user