main
History Download
Drew Owens Add native Isaac Lab 3.0 + Newton MJWarp 16384-env port, 3-engine sim2sim validation, and full-RoM electronics clearanc… f3db101

Microgoose RL & Dual-Engine Sim-to-Real Stack (rl/)

This directory implements the 7-stage reinforcement learning and dual-engine sim-to-sim validation pipeline for the 15-DoF Microgoose biped (14 locomotion joints plus 1 articulated beak_pitch joint) following the 61-float observation and 14-float residual position action contract (50 Hz control, 0.002 s physics step, decimation = 10, action_scale = 0.25 rad) defined in design/mechanical-interface.json.

Directory Layout

  • build_mjcf.py: Generates the CAD-exact assets/microgoose.xml (MuJoCo 4.0.1 MJCF with 60 group-0 STL CAD mesh geoms, 0 visible primitives, [0.000, 284.000] mm standing Z bounds, 0.5502 kg total mass) and assets/microgoose.urdf + assets/obj/*.obj & materials.mtl (44 per-link/per-material Wavefront OBJ+MTL CAD meshes for MIT/TRI Drake 1.58.0 RenderEngineVtk) using exact inverse forward-kinematics transforms T_world_B(q_cad)^(-1).
  • bam/: Multi-mass pendulum identification (fit_xl330.py), coupled XL330 + LMR33640 electromechanical bus-droop and 2-node stator/case thermal solver (xl330_electromech.py), and fitted parameters (xl330_bam_params.json).
  • isaaclab_microgoose/: Native Isaac Lab 3.0 + Newton (MuJoCo-Warp) + Rhoban BAM m6 asset and task package (robots/microgoose.py, contrib/microgoose/flat_env_cfg.py, contrib/microgoose/rough_env_cfg.py, contrib/microgoose/agents/rsl_rl_ppo_cfg.py, contrib/microgoose/mdp/symmetry.py, and install_into_isaaclab.sh) registering IsaacContrib-Velocity-Flat-MicroGoose ([1, 64] -> [1, 15], 79-float critic, 16,384-env GPU training).
  • policies/isaaclab_newton_microgoose_short.onnx: Self-contained opset-18 ONNX walking policy exported from the 16,384-environment Isaac Lab 3.0 + Newton validation run and cross-checked in CPU MuJoCo + BAM and MIT/TRI Drake (validation/sim2sim_isaaclab_mujoco_drake.py).
  • microgoose_mj_env.py: Vectorizable 50 Hz MuJoCo 4.0.1 + BAM XL330 environment with full domain randomization (+-20% link mass, [0.40, 1.30] sole friction, 0.002..0.012 rad gear backlash, 0..8 ms UART delay, 6.0..8.4 V 2S battery OCV, +-8.5 deg slopes, and external planar pushes).
  • drake_env.py: Independent MIT/TRI Drake 1.58.0 MultibodyPlant (Featherstone articulated-body tree + discrete SAP convex contact solver) paired with the identical XL330 BAM + LMR33640 Spine bus model.
  • getup_controller.py: Closed-loop FallRecoveryController testing both current-budgeted (<= 3.75 rad/s slew cap holding 5V_BUS = 5.00 V) and uncapped (28 rad/s simultaneous snap proving 11.88 A demand and 2.50 V LMR33640 foldback brownout) knockdown recovery.
  • sim2sim_dual_engine.py: Runs all 6 locomotion and fall/get-up scenarios deterministically in both MuJoCo 4.0.1 and MIT/TRI Drake 1.58.0, saving validation/raw/dual_engine_trajectories.npz and validation/sim2sim_cross_engine_report.json.
  • train_ppo_cuda.py: Multi-worker MuJoCo + CUDA PyTorch PPO trainer ([256, 128, 64] ELU Actor-Critic with running EmpiricalNormalization).
  • export_onnx.py: Exports opset-17 checkpoints/policy.onnx with baked (obs - mean) / std normalization (obs: float32 [1, 61], actions: float32 [1, 14]).
  • infer_policy.py: Standalone CPU onnxruntime + CAD-exact MuJoCo evaluator rendering docs/videos/microgoose-walk-sim2sim.mp4 (1280x720 @ 30 fps), docs/videos/microgoose-walk-poster.jpg, and docs/rl/sim2sim_walk_strip.png.
  • arena/: Standardized 32-rollout multi-command benchmark (eval_arena.py) writing arena/arena_scorecard.json.

Commands

Run from the repository root using python3:

PY="LD_LIBRARY_PATH=/usr/lib/wsl/lib PYTHONPATH=rl python3"

# 1. Fit BAM XL330 actuator model
eval $PY rl/bam/fit_xl330.py

# 2. Build CAD-exact MJCF (60 STL meshes) and URDF (44 OBJ+MTL meshes)
eval $PY rl/build_mjcf.py

# 3. Export self-contained policy.onnx and verify PyTorch parity
eval $PY rl/export_onnx.py

# 4. Render CAD-exact 10 s CPU ONNX sim-to-sim video, poster, and 6-frame walk strip
MUJOCO_GL=egl eval $PY rl/infer_policy.py

# 5. Execute 6-scenario dual-engine cross-check (MuJoCo 4.0.1 vs MIT/TRI Drake 1.58.0)
eval $PY rl/sim2sim_dual_engine.py

# 6. Render CAD vs MuJoCo vs Drake visual parity & dual-engine visual figures
MUJOCO_GL=egl eval $PY validation/render_cad_vs_sim_parity.py