File size: 12,593 Bytes
700dd75 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 | # VLA Inference
This guide covers running a trained Isaac-GR00T VLA policy on the Unitree G1 robot
using the Sonic whole-body control stack.
## Overview
The inference pipeline consists of:
1. **Isaac-GR00T PolicyServer** β loads the VLA model and serves actions over ZMQ
2. **VLA inference client** (`run_vla_inference.py`) β reads camera + robot state,
queries the PolicyServer, and publishes actions to the C++ control loop
3. **C++ deploy** (`gear_sonic_deploy`) β executes whole-body control on the robot
4. **Camera server** β provides camera images over ZMQ (runs as a systemd service)
5. **Data exporter** (optional) β records episodes during inference
```
ββββββββββββββββββββββββ
β Isaac-GR00T β
β PolicyServer β
β (GPU machine) β
ββββββββ¬ββββββββββββββββ
β ZMQ REQ/REP
βΌ
βββββββββββββββββββββββ ZMQ TCP ββββββββββββββββββββββββ
β VLA Inference β ββββββββββββ β Camera Server β
β (run_vla_inference)β β (on robot) β
ββββββ¬ββββββββββββ¬βββββ ββββββββββββββββββββββββ
β β
β ZMQ PUB β ZMQ SUB
β (actions) β (state)
βΌ βΌ
βββββββββββββββββββββββ
β C++ Deploy β
β (gear_sonic_deploy)β
βββββββββββββββββββββββ
```
## Prerequisites
### 1. Isaac-GR00T PolicyServer
The PolicyServer runs on a machine with a GPU. It loads your finetuned VLA model
and serves inference over ZMQ.
Install [Isaac-GR00T](https://github.com/NVIDIA/Isaac-GR00T) and start the server:
```bash
# On the GPU machine (from the Isaac-GR00T repo)
uv run python gr00t/eval/run_gr00t_server.py \
--model-path /path/to/your/finetuned_model \
--embodiment-tag UNITREE_G1_SONIC \
--device cuda:0 \
--port 5550
```
### 2. Inference Environment
On the inference machine (can be the same as the PolicyServer or a separate PC):
```bash
bash install_scripts/install_inference.sh
```
This creates `.venv_inference` with the Isaac-GR00T PolicyClient and all
inference dependencies.
### 3. Camera Server
The camera server should be running as a systemd service on the robot.
See [Data Collection](data_collection.md) for camera server setup.
### 4. C++ Deploy
The `gear_sonic_deploy` binary must be built. See the main README.
### SONIC v1.1 Checkpoint
Use the `sonic_v1_1/` checkpoint when the VLA policy was trained against
the robot-heading-normalized SONIC controller. It uses a 10-frame SMPL/wrist
reference horizon and was trained with wrist-pose augmentation. It is not the
low-latency checkpoint.
```bash
python download_from_hf.py --sonic-v1-1
```
Launch the matching C++ controller:
```bash
cd gear_sonic_deploy
./deploy.sh \
--cp policy/sonic_v1_1/model \
--obs-config policy/sonic_v1_1/observation_config.yaml \
--input-type zmq_manager \
real
```
Or pass the same model pair to the Python launcher:
```bash
python gear_sonic/scripts/launch_inference.py \
--deploy-checkpoint policy/sonic_v1_1/model \
--deploy-obs-config policy/sonic_v1_1/observation_config.yaml \
--camera-host 192.168.123.164 \
--prompt "pick up the cup"
```
### Low-Latency Teleoperation Checkpoint
The `low_latency/` checkpoint is configured for responsive whole-body
teleoperation. Its SMPL encoder uses 4 future reference frames at 50 Hz
(approximately 80 ms of reference lookahead), compared with 10 frames
(approximately 200 ms) in the default release. This is reference lookahead,
not total end-to-end system latency.
Download the deployment files from Hugging Face:
```bash
python download_from_hf.py --low-latency
```
Then launch `gear_sonic_deploy` with the low-latency model prefix and matching
observation config:
**C++ deploy:**
```bash
cd gear_sonic_deploy
./deploy.sh \
--cp policy/low_latency/model \
--obs-config policy/low_latency/observation_config.yaml \
--input-type zmq_manager \
real
```
For simulation, replace `real` with `sim`. The `--cp` value is a model prefix:
`deploy.sh` appends `_encoder.onnx` and `_decoder.onnx` internally.
**Python launcher:**
```bash
python gear_sonic/scripts/launch_inference.py \
--deploy-checkpoint policy/low_latency/model \
--deploy-obs-config policy/low_latency/observation_config.yaml \
--camera-host 192.168.123.164 \
--prompt "pick up the cup"
```
The Python launcher starts the same C++ deploy command in a tmux pane, then runs
the Python VLA inference client, keyboard publisher, and optional data exporter.
## Action Space
The Sonic embodiment (`unitree_g1_sonic`) uses a 78-dimensional action
space: 64-dim motion token + 7-dim left hand joints + 7-dim right hand joints.
## Quick Start β tmux Launcher
The easiest way to run inference is with the all-in-one tmux launcher:
```bash
# Real robot
python gear_sonic/scripts/launch_inference.py \
--prompt "pick up the apple" \
--camera-host 192.168.123.164
# Simulation
python gear_sonic/scripts/launch_inference.py --sim \
--prompt "pick up the apple"
# Without data recording
python gear_sonic/scripts/launch_inference.py \
--no-data-exporter \
--prompt "pick up the apple"
```
The launcher creates a tmux session with four panes:
| Pane | Component | Description |
|------|-----------|-------------|
| 0 (top-left) | C++ Deploy | Whole-body controller |
| 1 (bottom-left) | Keyboard Publisher | Type keyboard commands here |
| 2 (top-right) | VLA Inference | Policy client + action loop |
| 3 (bottom-right) | Data Exporter | Records episodes (optional) |
### Keyboard Controls
Type these keys in the **Keyboard Publisher** pane (pane 1):
| Key | Action |
|-----|--------|
| `k` | Start / stop the C++ control loop |
| `i` | Blend smoothly to initial pose and switch to POSE mode |
| `p` | Pause / resume policy inference |
| `[` | Toggle left hand open/closed (initial pose) |
| `]` | Toggle right hand open/closed (initial pose) |
| `t <text>` | Change the inference prompt (e.g., `t pick up the cup`) |
| `c` | Start recording an episode (data exporter) |
| `s` | Stop recording β success (data exporter) |
| `f` | Stop recording β failure / discard (data exporter) |
### Typical Workflow
1. Wait for all panes to initialize
2. Click on **pane 0** (C++ Deploy) and press Enter to confirm deployment
3. Switch to **pane 1** (Keyboard Publisher)
4. Press `k` to start the C++ control loop (starts in PLANNER mode)
5. Press `i` to blend to the initial pose (switches to POSE mode)
> The robot smoothly interpolates to the initial pose over 1 second. If your
> task starts from a different pose than the default, see
> [Customizing the Initial Pose](#customizing-the-initial-pose) below.
6. Press `p` to unpause the inference loop
7. The robot will begin executing VLA-predicted actions
8. Press `p` to pause, `k` to stop the control loop when done
## Manual Setup (Without tmux)
If you prefer to run each component in separate terminals:
### Terminal 1 β Isaac-GR00T PolicyServer (GPU machine)
```bash
# From the Isaac-GR00T repo
uv run python gr00t/eval/run_gr00t_server.py \
--model-path /path/to/your/finetuned_model \
--embodiment-tag UNITREE_G1_SONIC \
--device cuda:0 \
--port 5550
```
### Terminal 2 β C++ Deploy
```bash
cd gear_sonic_deploy
./deploy.sh --input-type zmq_manager real
```
Low-latency variant:
```bash
python gear_sonic/scripts/launch_inference.py \
--deploy-checkpoint policy/low_latency/model \
--deploy-obs-config policy/low_latency/observation_config.yaml \
--camera-host 192.168.123.164 \
--prompt "pick up the apple"
```
Manual C++ deploy equivalent:
```bash
cd gear_sonic_deploy
./deploy.sh \
--cp policy/low_latency/model \
--obs-config policy/low_latency/observation_config.yaml \
--input-type zmq_manager \
real
```
### Terminal 3 β VLA Inference
```bash
source .venv_inference/bin/activate
python gear_sonic/scripts/run_vla_inference.py \
--host <policy_server_ip> \
--port 5550 \
--embodiment-tag unitree_g1_sonic \
--prompt "pick up the apple" \
--camera-host 192.168.123.164
```
### Terminal 4 β Data Exporter (optional)
```bash
source .venv_data_collection/bin/activate
python gear_sonic/scripts/run_data_exporter.py \
--task-prompt "pick up the apple" \
--camera-host 192.168.123.164
```
## Configuration Reference
### VLA Inference (`run_vla_inference.py`)
| Flag | Default | Description |
|------|---------|-------------|
| `--host` | `localhost` | PolicyServer host |
| `--port` | `5550` | PolicyServer port |
| `--embodiment-tag` | `unitree_g1_sonic` | Embodiment tag |
| `--prompt` | `demo` | Language prompt |
| `--action-publish-rate` | `50` | Action publish rate (Hz) |
| `--action-horizon` | `40` | Actions per inference chunk |
| `--rate` | `2.5` | Inference rate (Hz) |
| `--camera-host` | `localhost` | Camera server host |
| `--camera-port` | `5555` | Camera server port |
| `--initial-pose-blend-duration` | `1.0` | Seconds to blend to initial pose (0 = instant snap) |
| `--verbose-timing` | `false` | Always print loop timing |
### tmux Launcher (`launch_inference.py`)
The launcher exposes all the above flags plus deploy and data exporter options.
Run `python gear_sonic/scripts/launch_inference.py --help` for the full list.
## Remote PolicyServer
When running the PolicyServer on a separate GPU machine:
```bash
# On the inference machine, point to the remote server
python gear_sonic/scripts/launch_inference.py \
--policy-host <gpu_machine_ip> \
--policy-port 5550 \
--camera-host 192.168.123.164 \
--prompt "pick up the apple"
```
Make sure port 5550 (or your chosen port) is accessible between the two machines.
## Latency Compensation
The inference loop automatically compensates for network and compute latency.
When a new action chunk arrives, the system calculates how many actions in the
chunk are already "stale" based on the time elapsed since inference started,
and skips to the appropriate action index. This is controlled by `--action-publish-rate`
and `--action-horizon`.
## Customizing the Initial Pose
When you press `i`, the inference client blends the robot smoothly from its
current configuration to a predefined **initial pose** encoded as a 64-dim
latent motion token. This pose should match the starting configuration your
demonstrations typically begin from.
### When to Change the Initial Pose
You should update the initial motion token if:
- Your collected demonstrations start from a pose far from the default
(e.g., arms raised, holding an object, or a different standing stance)
- You switch to a different SONIC checkpoint (each checkpoint has its own
latent space β the same token produces different poses across checkpoints)
- The robot is snapping to a dangerous or unstable configuration on `i` press
### Where to Change It
Edit `gear_sonic/utils/inference/initial_poses.py`:
```python
LATENT_INITIAL_MOTION_TOKEN = np.array(
[
# Replace with your 64-dim token
...
],
dtype=np.float32,
)
```
### How to Find a Good Token
1. **From data collection:** Look at the first action frame of a good demonstration
episode. The `action.motion_token` column in the parquet file at `frame_index=0`
gives you the latent token for that pose.
2. **From the C++ deploy:** Put the robot in the desired starting pose via teleop,
then read the most recent latent token published on the ZMQ action channel.
### Blend Duration
The blend duration controls how quickly the robot transitions to the initial pose:
```bash
# Default: 1 second smooth blend
python gear_sonic/scripts/run_vla_inference.py --initial-pose-blend-duration 1.0
# Faster blend (0.5 seconds)
python gear_sonic/scripts/run_vla_inference.py --initial-pose-blend-duration 0.5
# Instant snap (no interpolation, legacy behavior)
python gear_sonic/scripts/run_vla_inference.py --initial-pose-blend-duration 0
```
```{warning}
Setting `--initial-pose-blend-duration` too low (or to 0) can cause jerky motion,
especially if the robot's current pose is far from the initial pose. The default
1-second blend is safe for most configurations.
```
|