162 lines
9.8 KiB
Markdown
162 lines
9.8 KiB
Markdown
# 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.
|