Unitree RL GYM

repository·main·Indexed 25 days ago

https://github.com/unitreerobotics/unitree_rl_gym

A reinforcement learning framework for Unitree robots, including Go2, H1, H1_2, and G1. It provides a complete pipeline from training in Isaac Gym to Sim2Sim (Mujoco) and Sim2Real physical deployment. The framework includes tools for training policies via legged_gym, visualizing policies with play.py, and deploying trained networks to physical hardware using deploy_real.py or a C++/LibTorch implementation for the G1 robot.

Tokens
4.6K
Snippets
18
Records
36
Agent score
84%

What's inside unitree_rl_gym

  1. Understand H1_2 RL Example constraints and limitations

    main

    The H1_2 RL task is currently in a Preview Stage. Users should be aware of the following technical constraints:

    • Simplified URDF: The simulation uses a simplified URDF where several joints are fixed and most collisions are ignored to optimize performance.
    • Fixed Joints: Joints in the hands, wrists, and elbow roll joints are fixed. These are excluded because they have limited effect on whole-body dynamics and are typically managed by separate controllers.
    • Collision Model: Collisions are only active for the foot roll links, knee links, and the base. Early termination in the environment is primarily triggered by the angular position of the base.
    • Reward Functions: Note that reward functions are currently not well-tuned and may not produce satisfactory results. A stable version is expected in a future update.
  2. Train robot policies using legged_gym/scripts/train.py

    main

    Run the training script to allow the robot to interact with the Gym simulation environment and find optimal policies.

    Supported tasks (--task): go2, g1, h1, h1_2.

    Common CLI arguments:

    • --task: (Required) The robot model to train.
    • --headless: Set to true to disable graphical rendering for higher training efficiency.
    • --resume: Continue training from a checkpoint selected from the logs.
    • --experiment_name: Name of the experiment.
    • --run_name: Name of the specific run.
    • --load_run: The run name to load (defaults to the last run).
    • --checkpoint: The checkpoint number to load (defaults to the latest).
    • --num_envs: Number of parallel environments for training.
    • --seed: Random seed.
    • --max_iterations: Maximum number of training iterations.
    • --sim_device: Simulation device (e.g., --sim_device=cpu).
    • --rl_device: Reinforcement learning device (e.g., --rl_device=cpu).

    Default save path: logs/<experiment_name>/<date_time>_<run_name>/model_<iteration>.pt

    python legged_gym/scripts/train.py --task=xxx
  3. Install MiniConda and initialize environment

    main

    If Conda is not installed, download and install MiniConda to manage virtual environments. Use the following commands to download, install, and initialize Conda for your shell:

    # Download and install MiniConda
    mkdir -p ~/miniconda3
    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
    bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
    rm ~/miniconda3/miniconda.sh
    
    # Initialize Conda
    ~/miniconda3/bin/conda init --all
    source ~/.bashrc
  4. Install MiniConda and create a virtual environment

    main

    It is recommended to use Conda to manage your environment.

    1. Install MiniConda: Download and run the installer, then initialize Conda.
    2. Create Environment: Create a new environment named unitree-rl using Python 3.8.
    3. Activate Environment: Activate the environment before installing dependencies.
    # Install MiniConda
    mkdir -p ~/miniconda3
    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
    bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
    rm ~/miniconda3/miniconda.sh
    
    # Initialize Conda
    ~/miniconda3/bin/conda init --all
    source ~/.bashrc
    
    # Create and activate environment
    conda create -n unitree-rl python=3.8
    conda activate unitree-rl
  5. Deploy trained networks on physical Unitree robots

    main

    Use deploy_real.py to deploy trained reinforcement learning networks onto physical Unitree robots.

    Supported Robots:

    • Unitree G1
    • Unitree H1
    • Unitree H1_2

    Warning: This deployment is for demonstration purposes and is not a stable control program. Avoid disturbing the robot during operation. If unexpected behavior occurs, exit control immediately.