# Unitree MuJoCo **Source:** https://github.com/unitreerobotics/unitree_mujoco **Fetched:** 2026-02-13 **Type:** GitHub Repository README --- # Unitree MuJoCo Simulator - Complete Overview ## Project Description "unitree_mujoco is a simulator developed based on Unitree sdk2 and mujoco." It enables seamless integration of control programs from unitree_sdk2, unitree_ros2, and unitree_sdk2_python into simulation, facilitating "a seamless transition from simulation to physical development." The project provides both C++ and Python implementations. ## Supported Robots The simulator supports multiple Unitree quadruped and humanoid robots: - Go2, B2, B2w, H1 (using unitree_go IDL) - G1, H1-2 (using unitree_hg IDL) ## Key Supported Messages The system currently supports low-level control and state feedback: - **LowCmd**: Motor control commands - **LowState**: Motor state information - **SportModeState**: Robot position and velocity data - **IMUState**: Torso IMU measurements (G1 only) ## Directory Structure ``` - simulate/ : C++ simulator (recommended) - simulate_python/ : Python simulator - unitree_robots/ : MJCF robot descriptions - terrain_tool/ : Terrain generation utilities - example/ : Sample implementations ``` ## C++ Simulator Installation **Dependencies:** ```bash sudo apt install libyaml-cpp-dev libspdlog-dev libboost-all-dev libglfw3-dev ``` **Install unitree_sdk2** to `/opt/unitree_robotics`: ```bash git clone https://github.com/unitreerobotics/unitree_sdk2.git cd unitree_sdk2/ && mkdir build && cd build cmake .. -DCMAKE_INSTALL_PREFIX=/opt/unitree_robotics sudo make install ``` **Install MuJoCo** and create symlink: ```bash cd simulate/ ln -s ~/.mujoco/mujoco-3.3.6 mujoco ``` **Compile:** ```bash mkdir build && cd build && cmake .. && make -j4 ``` **Test:** ```bash ./unitree_mujoco -r go2 -s scene_terrain.xml ``` ## Python Simulator Setup **Dependencies:** ```bash pip3 install mujoco pygame pip3 install -e unitree_sdk2_python ``` **Run:** ```bash cd simulate_python && python3 unitree_mujoco.py ``` ## Configuration **C++ Config** (`simulate/config.yaml`): - Robot selection, scene file, DDS domain ID - Joystick settings (Xbox/Switch support) - Network interface (default: "lo" for simulation) - Elastic band support for humanoid initialization **Python Config** (`simulate_python/config.py`): - Same parameters as C++ version - Configurable simulation timestep (SIMULATE_DT) - Viewer refresh rate (VIEWER_DT) ## Terrain Generation The "terrain_tool folder contains utilities for parametrically creating simulation environments, including stairs, rough ground, and heightmaps." ## Sim-to-Real Transition Three integration examples demonstrate controller transfer: 1. **unitree_sdk2 (C++)**: - Compile in `example/cpp/build` - Run: `./stand_go2` (simulation) or `./stand_go2 enp3s0` (real robot) - Domain ID switches from 1 to 0 between environments 2. **unitree_sdk2_python**: - Run: `python3 stand_go2.py` (simulation) or with network interface for hardware 3. **unitree_ros2**: - Requires unitree_ros2 environment setup - Domain ID configuration via `ROS_DOMAIN_ID` environment variable ## Joystick Support Gamepad controllers (Xbox/Switch layouts) simulate the Unitree wireless controller, publishing to the "rt/wireless_controller" topic. Custom button mappings can be configured in source files using jstest tool output. ## Humanoid-Specific Features "elastic band was designed to simulate the lifting and lowering of humanoid robots," enabling safe initialization. Press 9 to toggle, 7 to lower, 8 to lift. --- **License:** BSD-3-Clause | **Repository:** github.com/unitreerobotics/unitree_mujoco