GitHub - unitreerobotics/unitree_rl_gym (original) (raw)

Unitree RL GYM

๐ŸŒŽEnglish | ๐Ÿ‡จ๐Ÿ‡ณไธญๆ–‡

This is a repository for reinforcement learning implementation based on Unitree robots, supporting Unitree Go2, H1, H1_2, and G1.

Isaac Gym Mujoco Physical

๐Ÿ“ฆ Installation and Configuration

Please refer to setup.md for installation and configuration steps.

๐Ÿ” Process Overview

The basic workflow for using reinforcement learning to achieve motion control is:

Train โ†’ Play โ†’ Sim2Sim โ†’ Sim2Real

๐Ÿ› ๏ธ User Guide

1. Training

Run the following command to start training:

python legged_gym/scripts/train.py --task=xxx

โš™๏ธ Parameter Description

Default Training Result Directory: logs/<experiment_name>/<date_time>_<run_name>/model_<iteration>.pt


2. Play

To visualize the training results in Gym, run the following command:

python legged_gym/scripts/play.py --task=xxx

Description:

๐Ÿ’พ Export Network

Play exports the Actor network, saving it in logs/{experiment_name}/exported/policies:

Play Results

Go2 G1 H1 H1_2
go2 g1 h1 h1_2

3. Sim2Sim (Mujoco)

Run Sim2Sim in the Mujoco simulator:

python deploy/deploy_mujoco/deploy_mujoco.py {config_name}

Parameter Description

Example: Running G1

python deploy/deploy_mujoco/deploy_mujoco.py g1.yaml

โžก๏ธ Replace Network Model

The default model is located at deploy/pre_train/{robot}/motion.pt; custom-trained models are saved in logs/g1/exported/policies/policy_lstm_1.pt. Update the policy_path in the YAML configuration file accordingly.

Simulation Results

G1 H1 H1_2
mujoco_g1 mujoco_h1 mujoco_h1_2

4. Sim2Real (Physical Deployment)

Before deploying to the physical robot, ensure itโ€™s in debug mode. Detailed steps can be found in the Physical Deployment Guide:

python deploy/deploy_real/deploy_real.py {net_interface} {config_name}

Parameter Description

Deployment Results

G1 H1 H1_2
real_g1 real_h1 real_h1_2

Deploy with C++

There is also an example of deploying the G1 pre-trained model in C++. the C++ code is located in the following directory.

deploy/deploy_real/cpp_g1

First, navigate to the directory above.

cd deploy/deploy_real/cpp_g1

The C++ implementation depends on the LibTorch library, download the LibTorch

wget https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.7.1%2Bcpu.zip unzip libtorch-cxx11-abi-shared-with-deps-2.7.1+cpu.zip

To build the project, executable the following steps

mkdir build cd build cmake .. make -j4

After successful compilation, executate the program with:

./g1_deploy_run {net_interface}

Replace {net_interface} with your actual network interface name (e.g., eth0, wlan0).

๐ŸŽ‰ Acknowledgments

This repository is built upon the support and contributions of the following open-source projects. Special thanks to:


๐Ÿ”– License

This project is licensed under the BSD 3-Clause License:

  1. The original copyright notice must be retained.
  2. The project name or organization name may not be used for promotion.
  3. Any modifications must be disclosed.

For details, please read the full LICENSE file.