Skip to content

XuSen-Proto/legged_lab_amp

 
 

Repository files navigation

Legged Lab

IsaacSim Isaac Lab Python Linux platform Windows platform pre-commit License

Overview

This repository is an extension for legged robot reinforcement learning based on Isaac Lab, which allows to develop in an isolated environment, outside of the core Isaac Lab repository. The RL algorithm is based on a forked RSL-RL library.

Key Features:

  • RL Support vanilla RL for legged robots, including Unitree G1, Go2.
  • AMP Adversarial Motion Priors (AMP) for humanoid robots, including Unitree G1.
rl-video-step-0.mp4

TODOS

  • Add more details about motion retargeting
  • Add more legged robots, such as Unitree H1
  • Self-contact penalty in AMP
  • Asymmetric Actor-Critic in AMP
  • Symmetric Reward
  • Sim2sim in mujoco

Installation

  • Install Isaac Lab by following the installation guide. We recommend using the conda installation as it simplifies calling Python scripts from the terminal.

  • Clone this repository separately from the Isaac Lab installation (i.e. outside the IsaacLab directory):

# Option 1: HTTPS
git clone https://github.com/zitongbai/legged_lab

# Option 2: SSH
git clone git@github.com:zitongbai/legged_lab.git
  • Using a python interpreter that has Isaac Lab installed, install the library
python -m pip install -e source/legged_lab
  • Clone the forked RSL-RL library separately from the Isaac Lab installation and legged_lab repository (i.e. outside the IsaacLab and legged_lab directories):
# Option 1: HTTPS
git clone https://github.com/zitongbai/rsl_rl.git
# Option 2: SSH
git clone git@github.com:zitongbai/rsl_rl.git

cd rsl_rl
git checkout feature/amp
  • Install the forked RSL-RL library:
# in the rsl_rl directory
python -m pip install -e .
  • Download the usd model for Unitree G1:
# in legged lab directory
gdown "https://drive.google.com/drive/folders/1rlhZcurMenq4RGojZVUDl3a6Ja2hm-di?usp=drive_link" --folder -O ./source/legged_lab/legged_lab/data/Robots/
  • Download the motion data for Unitree G1:
# in legged lab directory
gdown "https://drive.google.com/drive/folders/1tXtyjgM_wwqWNwnpn8ny5b4q1c-GxZkm?usp=sharing" --folder -O ./source/legged_lab/legged_lab/data/
  • Verify that the extension is correctly installed by running the following command:
python scripts/rsl_rl/train.py --task=LeggedLab-Isaac-Velocity-Rough-G1-v0 --headless

Train

RL

To train the reinforcement learning for Unitree G1, you can run the following command:

python scripts/rsl_rl/train.py --task=LeggedLab-Isaac-Velocity-Rough-G1-v0 --headless

For more details about the arguments, run python scripts/rsl_rl/train.py -h.

AMP

To train the AMP algorithm, you can run the following command:

python scripts/rsl_rl/train.py --task LeggedLab-Isaac-AMP-Flat-G1-v0 --headless --max_iterations 10000

If you want to train it in a non-default gpu, you can pass more arguments to the command:

# replace `x` with the gpu id you want to use
python scripts/rsl_rl/train.py --task LeggedLab-Isaac-AMP-Flat-G1-v0 --headless --max_iterations 10000 --device cuda:x agent.device=cuda:x

Play

You can play the trained model in a headless mode and record the video:

# replace the checkpoint path with the path to your trained model
python scripts/rsl_rl/play.py --task LeggedLab-Isaac-AMP-Flat-G1-Play-v0 --headless --num_envs 64 --video --checkpoint logs/rsl_rl/experiment_name/run_name/model_xxx.pt

The video will be saved in the logs/rsl_rl/experiment_name/run_name/videos/play directory.

Code formatting

We have a pre-commit template to automatically format your code. To install pre-commit:

pip install pre-commit

Then you can run pre-commit with:

pre-commit run --all-files

Troubleshooting

Pylance Missing Indexing of Extensions

In some VsCode versions, the indexing of part of the extensions is missing. In this case, add the path to your extension in .vscode/settings.json under the key "python.analysis.extraPaths".

{
    "python.analysis.extraPaths": [
        "<path-to-ext-repo>/source/legged_lab"
    ]
}

Pylance Crash

If you encounter a crash in pylance, it is probable that too many files are indexed and you run out of memory. A possible solution is to exclude some of omniverse packages that are not used in your project. To do so, modify .vscode/settings.json and comment out packages under the key "python.analysis.extraPaths" Some examples of packages that can likely be excluded are:

"<path-to-isaac-sim>/extscache/omni.anim.*"         // Animation packages
"<path-to-isaac-sim>/extscache/omni.kit.*"          // Kit UI tools
"<path-to-isaac-sim>/extscache/omni.graph.*"        // Graph UI tools
"<path-to-isaac-sim>/extscache/omni.services.*"     // Services tools
...

About

Isaac Lab extension for legged robots.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 99.7%
  • Dockerfile 0.3%