Skip to content

zihanwang0422/legged_rl_lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

105 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

legged_rl_lab

IsaacSim Isaac Lab Python Linux platform License

🧰️ Setup

conda create -n legged_rl_lab python=3.11
conda activate legged_rl_lab
pip install -U torch==2.7.0 torchvision==0.22.0 --index-url https://download.pytorch.org/whl/cu128
pip install --upgrade pip
  • Install isaacsim 5.1 and isaaclab 2.3
pip install isaaclab[isaacsim,all]==2.3.0 --extra-index-url https://pypi.nvidia.com
  • Verify the installization
isaacsim
  • Install the project
python -m pip install -e source/legged_rl_lab
  • List the tasks available in the project
python scripts/list_envs.py

πŸš€ Train

πŸ•οΈ Go2

Walk (Flat)

Walk (Flat)

#Train
python scripts/rsl_rl/train.py \
  --task=LeggedRLLab-Isaac-Velocity-Flat-Unitree-Go1-v0 \
  --num_envs 4096 \
  --headless \
  --resume \
  --load_run /path/to/log/folder \
  --checkpoint model_xx.pt  
#Play
python scripts/rsl_rl/play.py \
    --task=LeggedRLLab-Isaac-Velocity-Flat-Unitree-Go1-v0 \
    --num_envs 16
Walk (Rough)

Walk(rough)

#Train
python scripts/rsl_rl/train.py \
  --task=LeggedRLLab-Isaac-Velocity-Rough-Unitree-Go1-v0 \
  --num_envs 4096 \
  --headless

CUDA_VISIBLE_DEVICES=0,1,2,3 python -m torch.distributed.run \
    --nproc_per_node=4 \
    --master_port=54321 \
    scripts/rsl_rl/train.py \
    --task LeggedRLLab-Isaac-Velocity-Rough-Unitree-Go2-v0 \
    --num_envs 4096 \
    --headless  
#Play
python scripts/rsl_rl/play.py \
    --task=LeggedRLLab-Isaac-Velocity-Rough-Unitree-Go1-v0 \
    --num_envs 16
Handstand

Footstand

python scripts/rsl_rl/train.py \
  --task=LeggedRLLab-Isaac-Velocity-Footstand-Unitree-Go2-v0 \
  --num_envs 4096 \
  --headless
python scripts/rsl_rl/play.py \
    --task=LeggedRLLab-Isaac-Velocity-Handstand-Unitree-Go2-v0 \
    --num_envs 16

πŸ€–οΈ G1

Walk (Flat)
#Train
python scripts/rsl_rl/train.py \
  --task=LeggedRLLab-Isaac-Velocity-Flat-Unitree-G1-v0 \
  --num_envs 4096 \
  --headless
#Play
python scripts/rsl_rl/play.py \
    --task=LeggedRLLab-Isaac-Velocity-Flat-Unitree-G1-v0 \
    --num_envs 16
Walk (Rough)
#Train
python scripts/rsl_rl/train.py \
  --task=LeggedRLLab-Isaac-Velocity-Rough-Unitree-G1-v0 \
  --num_envs 4096 \
  --headless
#Play
python scripts/rsl_rl/play.py \
    --task=LeggedRLLab-Isaac-Velocity-Rough-Unitree-G1-v0 \
    --num_envs 16
Cross-Embodied G1+Go2 (Mixed)
#Train (multi-GPU)
python -m torch.distributed.run \
  --nproc_per_node=4 \
  scripts/rsl_rl/train_cross_embodied_shared.py \
  --num_envs 4096 \
  --headless

#Train (single-GPU)
python scripts/rsl_rl/train_cross_embodied_shared.py \
  --num_envs 4096 \
  --headless
#Play
python scripts/rsl_rl/play_cross_embodied_shared.py \
  --num_envs 32
Procedural Quadruped
# Flat – Train
python scripts/rsl_rl/train.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Flat-Procedural-Quadruped-v0 \
    --num_envs 4096 \
    --headless

# Flat – Play
python scripts/rsl_rl/play.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Flat-Procedural-Quadruped-Play-v0 \
    --num_envs 32

# Rough – Train
python scripts/rsl_rl/train.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Rough-Procedural-Quadruped-v0 \
    --num_envs 4096 \
    --headless

# Rough – Play
python scripts/rsl_rl/play.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Rough-Procedural-Quadruped-Play-v0 \
    --num_envs 32
Procedural Humanoid
# Flat – Train
python scripts/rsl_rl/train.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Flat-Procedural-Humanoid-v0 \
    --num_envs 4096 \
    --headless

# Flat – Play
python scripts/rsl_rl/play.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Flat-Procedural-Humanoid-Play-v0 \
    --num_envs 32

# Rough – Train
python scripts/rsl_rl/train.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Rough-Procedural-Humanoid-v0 \
    --num_envs 4096 \
    --headless

# Rough – Play
python scripts/rsl_rl/play.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Rough-Procedural-Humanoid-Play-v0 \
    --num_envs 32
Procedural Mixed (Humanoid + Quadruped)

Trains a single policy across procedurally generated bipeds and quadrupeds simultaneously. Three pluggable obs-encoder back-ends are available:

Encoder Flat Train Task Rough Train Task
Mask (default) …-Flat-Procedural-Mixed-v0 …-Rough-Procedural-Mixed-v0
Transformer …-Flat-Procedural-Mixed-Transformer-v0 …-Rough-Procedural-Mixed-Transformer-v0
GCN …-Flat-Procedural-Mixed-GCN-v0 …-Rough-Procedural-Mixed-GCN-v0

Architecture note: encoder lives in mdp/cross_procedural_mdp.py; all three procedural env types (ProceduralHumanoidRobotEnv, ProceduralQuadrupedRobotEnv, ProceduralMixedRobotEnv) inherit from CrossProceduralEnv which provides the unified morphology-params interface.

# ── Flat – Mask (default) ────────────────────────────────────────────────
# Train
python scripts/rsl_rl/train.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Flat-Procedural-Mixed-v0 \
    --num_envs 4096 \
    --headless

# Play
python scripts/rsl_rl/play.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Flat-Procedural-Mixed-Play-v0 \
    --num_envs 32

# ── Flat – Transformer ───────────────────────────────────────────────────
# Train
python scripts/rsl_rl/train.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Flat-Procedural-Mixed-Transformer-v0 \
    --num_envs 4096 \
    --headless

# Play
python scripts/rsl_rl/play.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Flat-Procedural-Mixed-Play-v0 \
    --num_envs 32

# ── Flat – GCN ───────────────────────────────────────────────────────────
# Train
python scripts/rsl_rl/train.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Flat-Procedural-Mixed-GCN-v0 \
    --num_envs 4096 \
    --headless

# Play
python scripts/rsl_rl/play.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Flat-Procedural-Mixed-GCN-Play-v0 \
    --num_envs 32

# ── Rough – Mask (default) ───────────────────────────────────────────────
# Train
python scripts/rsl_rl/train.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Rough-Procedural-Mixed-v0 \
    --num_envs 4096 \
    --headless

# Play
python scripts/rsl_rl/play.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Rough-Procedural-Mixed-Play-v0 \
    --num_envs 32

# ── Rough – Transformer ──────────────────────────────────────────────────
# Train
python scripts/rsl_rl/train.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Rough-Procedural-Mixed-Transformer-v0 \
    --num_envs 4096 \
    --headless

# Play
python scripts/rsl_rl/play.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Rough-Procedural-Mixed-Play-v0 \
    --num_envs 32

# ── Rough – GCN ──────────────────────────────────────────────────────────
# Train
python scripts/rsl_rl/train.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Rough-Procedural-Mixed-GCN-v0 \
    --num_envs 4096 \
    --headless
    
# Play
python scripts/rsl_rl/play.py \
    --task LeggedRLLab-Isaac-CrossEmboided-Rough-Procedural-Mixed-GCN-Play-v0 \
    --num_envs 32

πŸƒ Mimic

Datasets

Place the following datasets in the corresponding directories:

source/legged_rl_lab/legged_rl_lab/data/motion/
β”œβ”€β”€ LAFAN1_Retargeting_Dataset/   # Motion capture retargeted CSV (30 FPS)
β”‚   └── g1/                       # 40 CSV clips (walk, run, dance, jump, fight, fall …)
└── AMASS_Retargeted_for_G1/      # Large-scale motion capture NPZ (25 sub-libraries, 17,714 files)
    └── g1/
        β”œβ”€β”€ CMU/
        β”œβ”€β”€ KIT/
        └── ...

AMP (Adversarial Motion Priors)

The motion data path is configured directly in the env config (amp_flat_env_cfg.py) and points to a walks-only subset of LAFAN1 (g1_walk_only_npz: 6 clips β€” walk1/walk2 subjects). Run/sprint clips are intentionally excluded: mixing walk (~1 m/s) with sprint (~4 m/s) lets the discriminator trivially separate expert from policy from the first iteration, collapsing the style reward to zero before the policy has any chance to learn.

The env also uses Reference State Initialization (RSI): at each reset the robot is spawned from a near-stable reference frame (low base velocity + upright posture) instead of the default pose, which breaks the "stand in place" local optimum that otherwise dominates early training.

# Train β€” G1 humanoid, flat terrain, AMP + RSI (recommended: 1500+ iterations)
python scripts/amp/train.py \
    --task LeggedRLLab-Isaac-AMP-Flat-Unitree-G1-v0 \
    --num_envs 4096 \
    --headless

# Resume from a checkpoint
python scripts/amp/train.py \
    --task LeggedRLLab-Isaac-AMP-Flat-Unitree-G1-v0 \
    --num_envs 4096 \
    --headless \
    --resume
# Play / visualise
python scripts/amp/play.py \
    --task LeggedRLLab-Isaac-AMP-Flat-Unitree-G1-Play-v0 \
    --num_envs 50

Motion Tracking

Task ID Description
Tracking-Flat-G1-v0 Standard, with state estimation
Tracking-Flat-G1-Wo-State-Estimation-v0 No state estimation (closer to real deployment)
Tracking-Flat-G1-Low-Freq-v0 Half-frequency control
# Step 1 β€” Convert retargeted CSV to NPZ (runs FK via Isaac Sim to compute full body states)
python scripts/csv_to_npz.py \
  --input_file <path/to/csv/file> \
  --input_fps 30 \
  --headless
# Step 2 β€” (Optional) Replay NPZ in Isaac Sim to verify
python scripts/replay_npz.py \
    --file </path/to/npz/file>
# Step 3 β€” Train
python scripts/rsl_rl/train.py \
  --task Tracking-Flat-G1-v0 \
  --motion_file </path/to/npz/file> \
  --num_envs 4096 --headless

# Resume
python scripts/rsl_rl/train.py \
  --task Tracking-Flat-G1-v0 \
  --motion_file <path/to/npz/file> \
  --resume --load_run <run_folder> --checkpoint model_xxx.pt \
  --num_envs 4096 --headless
# Step 4 β€” Play
python scripts/rsl_rl/play.py \
  --task Tracking-Flat-G1-v0 \
  --motion_file /path/to/motion.npz \
  --num_envs 16

python scripts/rsl_rl/play.py \
  --task Tracking-Flat-G1-v0 \
  --motion_file source/legged_rl_lab/legged_rl_lab/data/motion/LAFAN1_Retargeting_Dataset/g1_jump/jumps1_subject1.npz \
  --num_envs 16 \
  --checkpoint logs/rsl_rl/g1_flat/2026-04-02_02-32-52/model_11000.pt

Sim2Sim

Terrain Generator: use the terrain generator script, see terrain_tool for details.

python3 deploy/utils/terrain_tool/terrain_generator.py
Go1 Walk

See deploy/go1_deploy/README.md for details.

pip install mujoco
python deploy/go1_deploy/sim2sim_walk.py --model go1_flat.pt
Go2 Walk / Handstand

See deploy/go2_deploy/README.md for details.

pip install mujoco
# Walk
python deploy/go2_deploy/sim2sim_walk.py --model go2_rough.pt
# Handstand
python deploy/go2_deploy/sim2sim_handstand.py --model go2_handstand.pt
G1 Walk

See deploy/g1_deploy/README.md for details.

pip install mujoco
python deploy/g1_deploy/sim2sim_walk.py --model g1_flat_1.onnx --config g1_walk.yaml

Sim2Real

Go1 Walk

See deploy/go1_deploy/README.md for details.

# Dependency: unitree_legged_sdk (see README)
python deploy/go1_deploy/sim2real_walk.py --mode real --model policy.pt
Go2 Walk

See deploy/go2_deploy/README.md for details.

python deploy/go2_deploy/sim2real_walk.py --mode real --model policy.pt
G1 Walk

See deploy/g1_deploy/README.md for details.

# Dependency: cyclonedds + unitree_sdk2_python (see README)
python deploy/g1_deploy/sim2real_walk.py

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_rl_lab"
    ]
}

Restart Terminal

pkill -f "python.*train.py"

Acknowledgements

About

Isaaclab for Go2/G1 (sim2sim2real)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors