|
| 1 | +# Neural WBC - Hardware Wrapper for Unitree H1 |
| 2 | + |
| 3 | +This module is a high-level wrapper for the [Unitree H1](https://unitree.com/h1) robot hardware. It is designed to provide convenient interfaces to deploy the trained policy on the Unitree H1 robot. The main purpose of this wrapper is to validate Whole Body Control (WBC) policies trained in IsaacLab on the real robot. |
| 4 | +> **Note:** The sim-to-real deployment wrapper currently only supports the Unitree H1 robot. It can be extended to other robots by implementing the corresponding hardware wrapper interface. |
| 5 | +
|
| 6 | +## Setup |
| 7 | +Our deployment setup uses an Ubuntu PC with GPU for running policy inference, connected to the H1 robot via Ethernet. For network configuration, please refer to the [Unitree H1 Quick Start Guide](https://support.unitree.com/home/en/H1_developer/start). |
| 8 | +<div align="center"> |
| 9 | +<div style="background-color: #f5f5f5; padding: 20px; border-radius: 8px; display: inline-block;"> |
| 10 | +<img src="docs/unitree_h1_setup.png" width="400"/> |
| 11 | +<br> |
| 12 | +<font size="1"><em>Unitree H1 setup</em></font> |
| 13 | +</div> |
| 14 | +</div> |
| 15 | + |
| 16 | +> **Note:** This guide assumes familiarity with basic Unitree H1 operation. Please refer to the official [Unitree H1 Operation Guide](https://support.unitree.com/home/en/H1_developer/quick_start) for fundamental robot operations, as these are outside the scope of this guide. |
| 17 | +
|
| 18 | +## Installation |
| 19 | + |
| 20 | +To install the required dependencies: |
| 21 | + |
| 22 | +```bash |
| 23 | +${ISAACLAB_PATH:?}/isaaclab.sh -p -m pip install -r requirements_deploy.txt |
| 24 | +``` |
| 25 | +For any issues with Unitree SDK installation, see the [Unitree Python SDK](https://github.com/unitreerobotics/unitree_sdk2_python). |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +### Check for successful connection with the robot |
| 30 | +- Make sure the robot is in develop mode using the joystick before executing the below example. Use the [Unitree Operation guide](https://support.unitree.com/home/en/H1_developer/quick_start) to transition the robot to develop mode. |
| 31 | +- Make sure robot is safely mounted on gantry with enough space around it. |
| 32 | + ```bash |
| 33 | + cd ~/unitree_sdk2_python |
| 34 | + python3 example/h1/low_level/h1_low_level_example.py <network interface> |
| 35 | + ``` |
| 36 | +If the robot responds to the low-level example commands, your setup and network connection are working correctly. You can proceed to the next steps after exiting the example program. |
| 37 | + |
| 38 | +### Check for successful setup of the Hover stack: |
| 39 | +- Execute the below commands from the hover stack root directory. |
| 40 | +- First ensure that all dependencies are installed using the common script |
| 41 | + [./install_deps.sh](../../install_deps.sh) |
| 42 | + |
| 43 | +- Run the simple viewer with: |
| 44 | + |
| 45 | + ```sh |
| 46 | + ${ISAACLAB_PATH}/isaaclab.sh -p neural_wbc/inference_env/scripts/mujoco_viewer_player.py |
| 47 | + ``` |
| 48 | + |
| 49 | +The viewer is paused on start by default, press `SPACE` key to start simulation or `RIGHT` arrow key |
| 50 | +to step forward once. By default this script will load the UniTree H1 robot model scene from |
| 51 | +[data/mujoco/models](../data/data/mujoco/models/scene.xml). |
| 52 | + |
| 53 | +## Deployment |
| 54 | + |
| 55 | +> **Note:** Current deployment does not use external sensors for robot root tracking. The setup supports deploying stable motions where the robot stabilizes in place while executing upper body motions. |
| 56 | + |
| 57 | +By default the policy is deployed in OmniH2O mode (tracking head and hand positions). In order to deploy a different mode, change the configuration in [config_file](../inference_env/inference_env/neural_wbc_env_cfg_real_h1.py). |
| 58 | + |
| 59 | +Once sim-to-sim validation is done, the policy can be deployed on the real robot using the following steps. |
| 60 | + |
| 61 | +1. Follow the [Unitree H1 Operation Guide](https://support.unitree.com/home/en/H1_developer/quick_start) to: |
| 62 | + - Boot the robot (Steps 1-5 under "Boot Process") |
| 63 | + - Switch to develop mode using the joystick (Steps under "Develop Mode") |
| 64 | +2. Once the H1 robot is transitioned to develop mode, execute this command to deploy the policy while the robot is securely mounted on the gantry: |
| 65 | + ```bash |
| 66 | + ${ISAACLAB_PATH:?}/isaaclab.sh -p neural_wbc/inference_env/scripts/s2r_player.py \ |
| 67 | + --student_path neural_wbc/data/data/policy/h1:student/ \ |
| 68 | + --student_checkpoint model_<iteration_number>.pt \ |
| 69 | + --reference_motion_path neural_wbc/data/data/motions/<motion_name>.pkl \ |
| 70 | + --robot unitree_h1 \ |
| 71 | + --max_iterations 5000 \ |
| 72 | + --num_envs 1 |
| 73 | + ``` |
| 74 | + You can now deploy the policy on the real robot in headless mode by passing the `--headless` option. |
| 75 | + |
| 76 | +2. Upon command execution, the robot will automatically move to match the starting pose of the reference motion. You can preview this motion in the Mujoco viewer UI, where the reference trajectory is visualized as red dots. |
| 77 | + |
| 78 | +3. Once the robot is in the starting pose: |
| 79 | + - Gradually lower the gantry until the robot's feet make contact with the ground |
| 80 | + - Press the space bar in the Mujoco viewer UI to begin policy execution |
| 81 | + - Completely lower the gantry to allow free movement of the robot |
| 82 | +
|
| 83 | +<div align="center"> |
| 84 | +<img src="docs/push_recovery.gif" width="400"/> |
| 85 | +<br> |
| 86 | +<font size="1"><em> Policy deployment of stable motion</em></font> |
| 87 | +</div> |
| 88 | +
|
| 89 | +> **Note:** If the robot loses motor torque and becomes unresponsive to joystick commands, restart the robot and contact Unitree support for troubleshooting. |
| 90 | +
|
| 91 | +## Unit Tests |
| 92 | +
|
| 93 | +The tests are located in the `tests` directory and can be run with the `unittest` module. |
| 94 | +
|
| 95 | +```bash |
| 96 | +cd neural_wbc/hw_wrappers |
| 97 | +${ISAACLAB_PATH:?}/isaaclab.sh -p -m unittest |
| 98 | +``` |
0 commit comments