feat(phase-0): initialize project foundation, packaging, logging, configs, and tests

This commit is contained in:
Warehouse Twin Dev
2026-10-19 14:55:54 +05:30
commit 7ef65ce65d
42 changed files with 2607 additions and 0 deletions
+103
View File
@@ -0,0 +1,103 @@
# 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.
---
## 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 Limitations & Next Phase
- **Current Limitations**: Phase 0 provides the foundational architecture, configuration validation, logging, CLI, and test runner. Domain classes (`Robot`, `Task`, `WarehouseGraph`) will be instantiated in Phases 1 and 2.
- **Phase 1 Target**: Implement the warehouse topological graph in `warehouse_twin.domain.warehouse` and `warehouse_twin.routing.graph_builder`, populate Zones A, B, and C nodes, validate station accessibility, and export graph connectivity metrics.