Skip to content

About

Closed-loop sim-to-real learning for the Unitree GO2 quadruped (Isaac Lab + ROS 2)

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

go2-phoenix

Closed-loop sim-to-real learning for the Unitree GO2 quadruped.

CI  Python  License: MIT  Robot


The Phoenix loop trains a locomotion policy in simulation, deploys it to the real robot, captures the failures that happen on hardware, replays those failures in simulation under a randomized physics sweep, and fine-tunes the policy on that failure-seeded distribution. The improved policy goes back to the robot. That is the designed loop; it has not yet run on real hardware failure data (see Project status). Every stage is a concrete Python module with its own CLI, configuration, and (where possible) unit tests.

Phoenix architecture

Demo

A 25-second cut: a policy trained on 8,192 simulated GO2s in Isaac Lab, then the same policy on the real robot, on a free floor: it holds the stand, walks forward and makes a partial turn. Getting up from lying flat and sitting down are scripted joint motions, not the learned policy, which was trained from near the standing pose. The turn panel shows the gap still open: in simulation the policy reaches 87% of a commanded turn, on the real robot 20% (17 of 86 degrees).

Watch the Phoenix demo on YouTube

Project status

Update 2026-10-07: first live stands and first walking commands on the GO2. A newer walking policy (trained in Isaac Lab, on a development branch that is not yet published) passed every live stand gate on the robot at zero command: 2 s, 5 s and three 10 s windows of policy control, body tilt under 0.09 rad, no safety-layer interventions. Each live start was a scripted stand-up from the folded pose; the policy took over once the robot was standing. It then executed its first walking commands on a free floor (no gantry or rope). It walks, but it under-tracks: about 60 % of the commanded forward distance and about 20 % of the commanded turn, against 89 % and 76 % for the same policy and command profile replayed in MuJoCo.

The cause is measured, not guessed: unmodeled joint friction. An active probe on the hung robot (feet off the ground, one joint ramped slowly each way until it breaks away) measured static friction of 0.24-0.35 N m at the hips, 0.17-0.34 N m at the thighs and 0.42-0.96 N m at the calves; the training simulator modelled none. Replaying the walk profiles in MuJoCo with the measured values drops tracking to 66 % / 34-47 %, and about 1.25-1.5x the measured values (friction rising under load is the leading, untested explanation) matches the robot. Floor friction and control latency do not reproduce the gap in simulation. Next: retrain with joint-friction randomization around the measured values. The paragraphs below describe the earlier stand-v3 track.

The locomotion policy is trained and verified in simulation. The sim-to-real deploy stack (ONNX export, the ROS 2 policy node, the fail-closed safety layer) has run end-to-end on the real GO2; that live run surfaced a per-step slew-rate saturation (about 33% at cmd_vel = 0) that no on-robot stand has yet cleared. The earlier single-cause attribution of that saturation (see EVIDENCE.md) is superseded: three mismatches were live in the 2026-04-21 run (a deploy-only per-step rate limiter, all four hip joints set to 0.0 in the deploy config while training used +0.1 left / -0.1 right, and base_lin_vel fed to the policy as zeros). Which of the three dominates is pending an ablation (scripts/deploy_ablation.py on the feat/causal-viability-replication branch; see its superseded-results record).

Status as of 2026-08: on-robot locomotion validation (Gate 7) is open and awaiting a lab session. Two things must be re-proven in that one session: that the corrected, normalization-carrying ONNX export behaves as the sim eval predicts, and that per-step slew saturation drops under the 5% gate for a 10 s stand. Note also that the adaptation loop, despite the title, has not yet closed once on real failure data: the replay and fine-tune path is wired and unit-tested, but it has not yet been run on any hardware-captured failure Parquet.

EVIDENCE.md is the verified / inferred / not-validated ledger for every claim below.

Stage State Detail
Simulation training (PPO, layered-YAML env) Done rsl_rl, ~10 shell entry points
Locomotion policy trained and sim-verified Done stand-v3-h25 sim eval: 32/32 success (sim only). Its slew figures (3.30% nominal / 2.91% under full DR, against a <5% gate) are superseded: they use a legacy raw-action-delta metric that the feat/causal-viability-replication branch has since replaced with deploy-equivalent clip activation, so they are not comparable to the 33% hardware figure (why)
ONNX export and torch / onnxruntime parity gate Re-verification owed verify_deploy, max drift 3.8e-06 on the stand-v2 export (2026-04-17) and 4.77e-06 on the stand-v3-h25 export (2026-06-20), both against a 1e-4 tolerance. A 2026-05-21 audit found every pre-audit export silently dropped observation normalization, so all checkpoints must be re-exported and re-parity-checked before the Gate 7 retry (EVIDENCE.md)
ROS 2 deploy stack and fail-closed safety layer Done 3 bridges, policy node, shared slew cap
Deploy stack ran end-to-end on the GO2 Done live on the Jetson 2026-04; surfaced the 33% slew saturation, no stand passed
Failure detector and Parquet trajectory logging Done rule-based attitude / collapse / slip
Replay and failure-curriculum fine-tune Wired wired and unit-tested; not yet run on real hardware failure data
Live on-robot stand (Gate 7) Done (newer policy) 2026-10-06: a newer walking policy at zero command passed 2 s, 5 s and 3 x 10 s live stands. The stand-v3-h25 policy itself was not re-run; its 2026-04-21 saturation cause is still pending the ablation
Live velocity tracking (Gate 8) In progress 2026-10-07: first walking commands, on a free floor; under-tracks (about 60 % forward, 20 % yaw); cause measured as joint friction (see above)
Posture-offset fix (floating-base DR or floor test) ⬜ Planned decision follows the Gate 7 retry

Full milestone trail: docs/changelog.md.

Why this repo exists

Most open-source quadruped RL projects stop at "trained in sim, deployed once." Phoenix is explicitly about the loop after the first deployment: reproducing real failures in sim, using them as training seeds, and shipping a better policy. (That loop is designed and wired but has not yet run on real failure data.) The full pipeline is driven by YAML configs and ~10 shell entry points.

Quick start

# Install Isaac Lab 3.0+ (https://isaac-sim.github.io/IsaacLab/).
export ISAACLAB_PATH=/path/to/IsaacLab

# Train a baseline policy (~4h on an NVIDIA (Blackwell) consumer GPU at 4096 envs)
./scripts/train.sh configs/train/ppo.yaml

# Export to ONNX, bench it, and print the Jetson bringup steps
./scripts/deploy.sh checkpoints/phoenix-base/latest.pt

# Once a failure has been recorded on the real robot, replay it in sim
# (placeholder path: no hardware-captured failure has been replayed yet)
./scripts/replay.sh data/failures/<recorded_failure>.parquet

# Fine-tune with the failure curriculum
./scripts/adapt.sh configs/train/adaptation.yaml

For a full layout map, see docs/structure.md.

Two Python contexts, one filesystem

Phoenix runs in two Python environments that never share a process. Data crosses the boundary as files (*.onnx, *.parquet, *.mp4); no module imports torch and rclpy.

Context Where Optional extra
Isaac Lab Python $ISAACLAB_PATH/isaaclab.sh -p pip install -e ".[sim]"
System Python + ROS 2 /opt/ros/humble + venv pip install -e ".[real]"

Tests

pip install -e ".[dev]"
pytest tests -m "not sim and not ros"

236 unit tests pass torch-free and ROS-free by construction (5 more exercise the torch path when torch is installed; 4 are marked sim/ros and deselected here; re-measured 2026-09-30 with the CI command in a clean Python 3.10 venv: 236 passed, 5 skipped, 4 deselected). They cover the config loader, observation builder, failure detector, trajectory logger, Parquet round-trip, Halton variation sampler, curriculum scheduler, per-env variation translation, the fail-closed estop / sensor-freshness predicates, the projected-gravity helper, the verify_deploy parity gate, the ONNX-export observation-normalizer reconstruction, the reset_bridge quat/pose conversion, the lowcmd bridge config builder, the sweep runner, and the lab-day harness.

Isaac Lab and ROS 2 paths run manually on the hardware:

pytest tests -m sim    # requires Isaac Lab + GPU
pytest tests -m ros    # requires a running ROS 2 environment

Safety semantics on the deploy path

The real-robot side fails closed by default. ros2_policy_node and lowcmd_bridge_node both treat a stale /phoenix/estop heartbeat as an asserted estop, not as "OK to keep going." Every gate is a pure function in src/phoenix/sim2real/safety.py and is unit-tested in tests/test_safety.py.

  • Startup is locked. The policy node refuses to publish until it has received a fresh /phoenix/estop heartbeat with data == False AND fresh /imu/data AND fresh /joint_states. During cold startup with any precondition unmet, the node stays silent; the bridge's own fail-closed watchdog holds the motors with conservative hold_kp / hold_kd gains.
  • Past the grace window, an unmet precondition latches the abort with a specific reason (estop_publisher_missing, estop_heartbeat_stale, external_estop, sensor_missing, sensor_stale); the node publishes the safe default stand pose.
  • Slew-rate cap is shared. Both sides call per_step_clip_array(target, current, MAX_DELTA_PER_STEP_RAD) with the constant living in safety.py.
  • Wireless / joystick deadman: stale input or released button publishes estop=True within one tick.

The relevant knobs live under safety: in configs/sim2real/deploy.yaml. Defaults are deliberate and tighter than the upstream Unitree examples.

Configuration model

YAML files under configs/ support a Hydra-style defaults: chain:

# configs/env/slippery.yaml
defaults:
  - base
domain_randomization:
  friction_range: [0.05, 0.4]   # overrides base

All configs are serialized into each run's log directory as train.yaml / env.yaml, so a rollout is fully reproducible from the artifact alone.

Known limitations

  • Failure-curriculum adaptation. The reset_bridge is wired (env-origin-relative poses, xyzw to wxyz quat conversion, configurable seed-row and opt-in velocity write) and unit-tested. adaptation.yaml still ships with failure_sample_fraction: 0.0 until enough hardware-captured parquets exist to validate against. The opt-in velocity write passes body-frame velocities into Isaac Lab's world-frame write_root_velocity_to_sim unrotated; for a failure seeded at a non-trivial orientation the injected velocity points the wrong way. It is off by default; a proper fix rotates by the base quaternion first.
  • Replay variation application is local-only. The pure-Python variation translation in replay/apply_variations.py is unit-tested in CI; the Isaac Sim hand-off in replay/reconstruct.py is sim-only.
  • rsl_rl 3.0 iter-0 logging artifact. Fine-tune from a trained baseline uses init_at_random_ep_len=False; without it, runner.learn reports an iter-0 "mean reward near 0" even with a byte-exact warm-start. Cosmetic only, the warm-start itself is correct.

Citation

See CITATION.cff.

License

MIT. See LICENSE.

About

Closed-loop sim-to-real learning for the Unitree GO2 quadruped (Isaac Lab + ROS 2)

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages