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

150 lines
7.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Phase 7: NVIDIA Omniverse USD 3D Visualization and Trajectory Playback
## 1. Executive Summary & Objectives
Phase 7 delivers the complete 3D visualization and simulation playback layer for the Warehouse Robot Fleet Digital Twin using **OpenUSD** and **NVIDIA Omniverse Kit 110.4**.
The primary design principle is **clean architectural decoupling**:
- The discrete-event simulation engine remains 100% headless, fast, and pure Python (zero heavy graphics or Isaac Sim dependencies during simulation runs).
- Simulation runs export standardized, time-stamped trajectory recordings (`results/trajectories/trajectory_*.json`).
- Visualization operates in two complementary modes:
1. **Natively Animated OpenUSD (`warehouse_phase7_animated.usda`)**: Time-sampled kinematic tracks (`xformOp:translate.timeSamples`, `xformOp:rotateXYZ.timeSamples`, `primvars:displayColor.timeSamples`, and `visibility.timeSamples`) that can be opened and scrubbed in Omniverse Kit's timeline or any standard USD tool (usdview, Blender, Unreal Engine) with zero extension dependencies.
2. **Interactive Omniverse Kit Extension (`omni.warehouse.twin.visualizer`)**: An interactive UI window within Kit that provides live trajectory playback controls (Play, Pause, Reset, Seek, Speed Multipliers $0.5\times$ to $10.0\times$), real-time stage prim transform updates, state beacon color indicators, and a live fleet operational HUD.
---
## 2. Host Environment & Kit 110.4 Integration
Inspection of the host system verified:
- **Kit Executable**: `/home/dmhai/Desktop/nvidia-omniverse/kit-app-template/_build/linux-x86_64/release/kit/kit`
- **Application Target**: `warehouse_twin.kit` launched via:
```bash
/home/dmhai/Desktop/nvidia-omniverse/kit-app-template/_build/linux-x86_64/release/warehouse_twin.kit.sh
```
- **Kit Kernel Version**: `110.4.0+feature.386251.187cf21b.gl`
- **Extension Symlink**: Automatically linked to `_build/linux-x86_64/release/exts/omni.warehouse.twin.visualizer` for immediate runtime discovery.
---
## 3. Architecture & Delivered Modules
```
warehouse-digital-twin/
├── src/warehouse_twin/
│ ├── interfaces/
│ │ └── usd_generator.py # Static OpenUSD facility & fleet scene generator
│ └── visualization/
│ ├── __init__.py # Visualization module exports
│ ├── trajectory_player.py # Continuous spatial interpolation & playback engine
│ └── animated_usd.py # Time-sampled OpenUSD stage generator
├── omniverse/
│ ├── scenes/
│ │ ├── warehouse_phase7.usda # Static facility stage with AMR fleet
│ │ └── warehouse_phase7_animated.usda # Dynamic time-sampled stage with playback tracks
│ └── extensions/
│ └── omni.warehouse.twin.visualizer/ # Omniverse Kit 110.4 extension
│ ├── config/extension.toml
│ ├── omni/warehouse/twin/visualizer/
│ │ ├── __init__.py
│ │ └── extension.py # UI window & update loop prim transform driver
│ └── docs/
│ ├── README.md
│ └── CHANGELOG.md
└── tests/unit/
├── test_trajectory_player.py # 4 passed tests
├── test_animated_usd.py # 2 passed tests
└── test_kit_extension.py # 2 passed tests
```
---
## 4. Continuous Spatial Interpolation (`trajectory_player.py`)
The `TrajectoryPlayer` provides continuous queries at any arbitrary simulation timestamp $t \in [t_{\text{start}}, t_{\text{end}}]$:
1. **Binary Search Lookup**: $O(\log N)$ bisect lookup locating consecutive waypoints $(t_1, \mathbf{p}_1)$ and $(t_2, \mathbf{p}_2)$.
2. **Normalized Progress**:
$$\alpha = \frac{t - t_1}{t_2 - t_1}, \quad \alpha \in [0.0, 1.0]$$
3. **Cartesian Translation**:
$$\mathbf{p}(t) = (1 - \alpha)\mathbf{p}_1 + \alpha \mathbf{p}_2$$
4. **Shortest-Arc Angular Interpolation (Yaw)**:
$$\Delta \theta = (\theta_2 - \theta_1 + 180^\circ) \pmod{360^\circ} - 180^\circ$$
$$\theta(t) = \theta_1 + \alpha \Delta \theta$$
*Eliminates unnatural full-revolution spins across the $180^\circ \leftrightarrow -180^\circ$ boundary.*
5. **Continuous Battery & Discrete Payload**:
- Linear battery interpolation: $\text{SoC}(t) = \text{SoC}_1 + \alpha(\text{SoC}_2 - \text{SoC}_1)$.
- Midpoint state transition for carried payload attachment and LED beacon colors.
---
## 5. Visual State Indicators & Prim Structure
Each AMR on the USD stage (`/World/Robots/{robot_id}`) features synchronized visual cues:
| Robot Component | USD Prim Path | Visual Representation | Dynamic Behavior |
| :--- | :--- | :--- | :--- |
| **Chassis** | `/World/Robots/{id}/Chassis` | Light AMR: Pearl White (agile)<br>Heavy AMR: Industrial Amber (rugged) | Translates and rotates along trajectory |
| **Status Beacon** | `/World/Robots/{id}/StatusDome` | High-visibility status dome on top of chassis | Changes RGB color based on state:<br>- **Cyan** `(0.15, 0.75, 0.95)`: `IDLE`<br>- **Blue** `(0.30, 0.60, 1.00)`: `DISPATCHED`<br>- **Green** `(0.20, 0.90, 0.35)`: `PICKING` / `DROPPING`<br>- **Gold** `(0.95, 0.75, 0.10)`: `LOADED_TRANSIT`<br>- **Orange** `(0.95, 0.50, 0.15)`: `TRANSIT_TO_CHARGE`<br>- **Neon Red** `(1.00, 0.30, 0.10)`: `CHARGING` |
| **Battery LED** | `/World/Robots/{id}/BatteryLED` | Rear indicator bar | **Green** (>50%) $\rightarrow$ **Amber** (20–50%) $\rightarrow$ **Red** (<20%) |
| **Carried Cargo** | `/World/Robots/{id}/Payload` | Pallet carton box on chassis | Visibility toggles: `"inherited"` when loaded, `"invisible"` when empty |
---
## 6. How to View in Omniverse Kit
### Option A: Native OpenUSD Timeline Playback (No Extension Needed)
1. Launch Omniverse Kit:
```bash
/home/dmhai/Desktop/nvidia-omniverse/kit-app-template/_build/linux-x86_64/release/warehouse_twin.kit.sh
```
2. Open the animated scene:
- In the Kit menu: `File -> Open`
- Select `/home/dmhai/warehouse-digital-twin/omniverse/scenes/warehouse_phase7_animated.usda`
3. Click **Play** (or press `Spacebar`) on the bottom timeline toolbar.
4. Scrub the timeline slider backwards or forwards to inspect robot movements, pick/drop actions, and charging sessions.
### Option B: Interactive Trajectory Playback Extension
1. Open the static facility scene: `omniverse/scenes/warehouse_phase7.usda`.
2. The `omni.warehouse.twin.visualizer` window opens automatically.
3. Verify the trajectory path (`results/trajectories/trajectory_default.json`) and click **Load**.
4. Use the playback controls:
- **Play / Pause / Reset**
- **Speed Multipliers**: $0.5\times, 1.0\times, 2.0\times, 5.0\times, 10.0\times$
- **Time Scrubber**: Real-time slider with `HH:MM:SS` display
- **Fleet HUD**: Live status matrix tracking every robot's position, battery %, and carried payload.
---
## 7. CLI Usage
```bash
# 1. Export static 3D facility scene
warehouse-twin export-usd --output omniverse/scenes/warehouse_phase7.usda
# 2. Run simulation and export trajectory
warehouse-twin run-sim --duration 600 --output-trajectories results/trajectories/trajectory_default.json
# 3. Export time-sampled animated USD stage
warehouse-twin export-usd \
--trajectory results/trajectories/trajectory_default.json \
--output omniverse/scenes/warehouse_phase7_animated.usda \
--step-seconds 1.0
# 4. Preview and validate trajectory kinematics in terminal
warehouse-twin play-trajectory results/trajectories/trajectory_default.json --step 30
```
---
## 8. Test & Validation Summary
```
============================= 137 passed in 1.01s ==============================
```
- **Total Tests**: 137 passed (100% pass rate).
- **Phase 7 Test Suites Added**:
- `tests/unit/test_trajectory_player.py`: 4 passed
- `tests/unit/test_animated_usd.py`: 2 passed
- `tests/unit/test_kit_extension.py`: 2 passed
- **Teardown Safety**: Extension properly unregisters all update subscriptions and releases event callbacks on shutdown without dangling references.