--- id: simulation title: "Simulation Environments" status: established source_sections: "reference/sources/github-unitree-mujoco.md, reference/sources/github-unitree-rl-gym.md, reference/sources/github-unitree-rl-lab.md, reference/sources/github-unitree-sim-isaaclab.md, reference/sources/github-mujoco-menagerie-g1.md" related_topics: [ros2-integration, learning-and-ai, locomotion-control] key_equations: [] key_terms: [sim_to_real, domain_id] images: [] examples: [] open_questions: - "Optimal domain randomization parameters for G1 sim-to-real" - "MJX vs standard MuJoCo performance for G1 training" - "PyBullet G1 model quality and community support" --- # Simulation Environments Simulation tools, robot models, and sim-to-real transfer for the G1. ## 1. Available Simulators | Simulator | Repository / Source | Status | Model Format | G1 Configs | Tier | |------------------|--------------------------------------------------|--------------|-------------|--------------------------------------|------| | MuJoCo (Unitree) | unitreerobotics/unitree_mujoco | Official | MJCF | G1 (all variants) | T0 | | MuJoCo Menagerie | google-deepmind/mujoco_menagerie/unitree_g1 | Official | MJCF | G1 29-DOF, G1 with hands | T0 | | Isaac Lab | unitreerobotics/unitree_sim_isaaclab | Official | USD/URDF | G1-29dof-gripper, G1-29dof-dex3, G1-23dof | T0 | | Isaac Gym (legged) | unitreerobotics/unitree_rl_gym | Official | URDF | G1 | T0 | | Isaac Lab (RL) | unitreerobotics/unitree_rl_lab | Official | USD/URDF | G1-29dof | T0 | | Gazebo | unitreerobotics/unitree_ros | Limited | URDF | G1 (no high-level walking) | T1 | | PyBullet | Community | Community | URDF | G1 (community models) | T2 | | Unity ML-Agents | RizziGama/unitree-g1-rl-unity | Community | URDF | G1 (PPO/SAC training) | T2 | ## 2. Robot Models ### MuJoCo Menagerie (Recommended for MuJoCo) - **Repository:** https://github.com/google-deepmind/mujoco_menagerie/tree/main/unitree_g1 - **Key files:** - `g1.xml` — Main 29-DOF model - `g1_with_hands.xml` — Variant with hand models - `scene.xml` — Standard environment - `scene_mjx.xml` — MJX-optimized environment - `assets/` — Mesh and texture files - **Requirements:** MuJoCo 2.3.4+ - **MJX variant:** Manually designed collision geometries, tuned solver parameters, realistic PD gains validated on real hardware (MuJoCo Playground, arXiv:2502.08844) - **License:** BSD-3-Clause [T0] ### Unitree ROS URDF - **Repository:** https://github.com/unitreerobotics/unitree_ros - **Location:** `robots/g1_description/` - **Contents:** URDF with mass, inertia, moment, and joint limits - **Note:** Designed for MuJoCo, NOT Gazebo-compatible for walking [T0] ### USD Models (Isaac Sim) - **Repository:** https://github.com/unitreerobotics/unitree_model (DEPRECATED) - **Current source:** HuggingFace (newer models) - **Format:** USD, converted from URDF via Isaac Sim [T0] ## 3. unitree_mujoco — Primary Simulator Official MuJoCo simulator with seamless sim-to-real transition: [T0] | Feature | Details | |-----------------------|------------------------------------------------| | Languages | C++ (recommended) and Python | | C++ location | `simulate/` directory | | Python location | `simulate_python/` directory | | Terrain generation | Stairs, rough ground, heightmaps | | Humanoid init | Virtual elastic band for stable initialization | | Joystick support | pygame-based joystick control (Python) | ### C++ Dependencies unitree_sdk2, MuJoCo, libyaml-cpp-dev, libspdlog-dev, libboost-all-dev, libglfw3-dev ### Python Dependencies unitree_sdk2_python, mujoco (pip), pygame (for joystick) ### Supported Communication - LowCmd/LowState (motor control) - SportModeState (robot position/velocity) - IMUState (for G1 robots) ## 4. unitree_sim_isaaclab — Isaac Lab Integration High-fidelity simulation for data collection and model validation: [T0] | Feature | Details | |-------------------------|----------------------------------------------| | Isaac Sim versions | 4.5.0 or 5.0.0 | | G1 configurations | G1-29dof-gripper, G1-29dof-dex3, G1-23dof | | Tasks | Pick-and-place, stacking, mobile manipulation | | DDS communication | Same protocol as physical robot | | Visual data | Camera capture in simulation | | Performance | 1s sim = 27 min real-world (RTX 4090, rough terrain) | ### Example Command ```bash python sim_main.py --task Isaac-PickPlace-Cylinder-G129-Dex1-Joint \ --enable_dex1_dds --robot_type g129 ``` ## 5. Sim-to-Real Transfer The G1 ecosystem is designed for straightforward sim-to-real transfer: [T0] ### MuJoCo → Real Switch from simulation to real robot by changing only the network configuration: - **Simulation:** Use domain ID for DDS routing - **Real hardware:** Specify network interface (e.g., `enp2s0`) No code changes required — the same DDS API works in both environments. [T0] ### Training → Deployment Pipeline ``` 1. Train (Isaac Gym / MuJoCo) → policy checkpoint 2. Play (MuJoCo sim) → validate behavior 3. Sim2Sim (MuJoCo ↔ Isaac Lab) → cross-sim validation 4. Sim2Real (unitree_sdk2) → deploy to physical robot ``` ### Domain Randomization Standard RL training uses domain randomization for robustness: - Physics parameters (friction, mass, restitution) - Sensor noise (IMU bias, encoder noise) - Terrain variation (procedural heightmaps) - Latency simulation - **External force perturbations** — random pushes applied to torso during training for push recovery robustness (see [[push-recovery-balance]]) ### Known Sim-to-Real Gaps [T1 — Verified on real G1, 2026-02-15] | Gap | Impact | Fix | |-----|--------|-----| | **IMU mounting offset** | Persistent backward lean (~6° pitch offset between sim and real IMU) | Quaternion pitch rotation before gravity computation. See [[sensors-perception]] §4. | | **PD gain calibration** | Policy trained with specific gains; changing gains degrades balance even if tracking improves | Use sim-trained gains OR recalibrate after gain change. Policy corrections are calibrated for training gains. | | **Action clipping** | Not present in sim (RSL-RL default); adding clip in deployment causes saturation | Do NOT clip ONNX outputs — policy needs full range for push recovery | | **Surface compliance** | Carpet adds ~1° effective ankle sag vs rigid sim floors | Minor — within policy tolerance | **Key insight:** When a sim-trained policy produces poor real-world behavior, check sensor calibration BEFORE tuning gains or modifying the policy. An incorrect IMU reference frame cannot be fixed by any amount of gain tuning — the policy's balance loop actively fights the correction. ### Perturbation Testing in Simulation Both MuJoCo and Isaac Gym/Lab support applying external forces to the robot body during simulation. This is essential for: - Training push-robust locomotion policies ([[push-recovery-balance]]) - Validating balance during mocap playback ([[motion-retargeting]]) - Testing whole-body controller robustness ([[whole-body-control]]) In MuJoCo: use `mj_applyFT()` to apply forces/torques to bodies. In Isaac Gym: use `gym.apply_body_force_at_pos()` for the same. ### Motion Retargeting Validation The AMASS motion dataset (retargeted for G1, available on HuggingFace) provides reference trajectories that can be played back in simulation before real-robot execution. This enables safe validation of the full mocap → retarget → WBC → execute pipeline. See [[motion-retargeting]]. ## Key Relationships - Models from: [[ros2-integration]] (URDF files) - Trains policies for: [[learning-and-ai]] (RL training environments) - Validates: [[locomotion-control]] (test gaits in sim before real hardware) - Same API as: [[sdk-programming]] (DDS interface identical in sim and real)