A reinforcement learning framework for training humanoid robot controllers using Isaac Lab, featuring DeepONet, Transformer, and MLP architectures for sim-to-real transfer.
GapONet implements a comprehensive training and evaluation framework for humanoid robot control with a focus on sim-to-real transfer. It supports multiple neural network architectures (DeepONet, Transformer, MLP) and provides environments for training and testing on various humanoid robot platforms.
- Isaac Sim 4.5.0+ (installed separately)
- Python 3.10+
- CUDA-capable GPU with appropriate drivers
- Isaac Lab (see Isaac Lab documentation for installation)
Before installation, download the required assets:
-
Robot Assets: Download sim2real_assets and place the corresponding files in
gaponet/source/sim2real_assets/sim2real_assets/. -
Test Data: A test data sample is provided. Please refer to this template for the format of test and training data. Place the corresponding files in
gaponet/source/sim2real/sim2real/motions/motion_amass/edited_27dof/. -
Checkpoint: A checkpoint sample is provided. Please refer to this template for the format of test and training data. Place the corresponding files in
gaponet/model/.
Use the setup script to automatically create the conda environment and install all dependencies:
# Clone the repository
git clone git@github.com:jiemingcui/gaponet.git
cd gaponet
# Run the setup script (creates 'gapo' environment by default)
./setup.sh
# Install IsaacSim
pip install "isaacsim[all,extscache]==4.5.0" --extra-index-url https://pypi.nvidia.com
# Install isaaclab
./isaaclab.sh --installTrain with DeepONet architecture on operator environment:
python scripts/rsl_rl/train.py --task Isaac-Humanoid-Operator-Delta-Action \
--num_envs=4080 --max_iterations 100000 --experiment_name Sim2Real \
--letter amass --run_name delta_action_mlp_payload --device cuda env.mode=train --headless- Evaluate a trained model:
python scripts/rsl_rl/play.py --task Isaac-Humanoid-Operator-Delta-Action \
--model ./model/model_17950.pt --num_envs 20 --headless- Export checkpoint to JIT format (for lightweight inference without Isaac Sim):
python scripts/rsl_rl/inference_jit.py \
--export \
--checkpoint ./model/model_17950.pt \
--task Isaac-Humanoid-Operator-Delta-Action \
--output ./model/policy.pt \
--device cuda:0 \
--num_envs 20This script exports a trained checkpoint to JIT/TorchScript format. The exported model can be used for inference without requiring Isaac Sim. Note: This step requires Isaac Sim to be initialized for the export process.
- Run lightweight inference and evaluation (no Isaac Sim required):
python scripts/rsl_rl/deploy.py \
--model ./model/policy.pt \
--test_data ./source/sim2real/sim2real/tasks/humanoid_operator/motions/motion_amass/edited_27dof/test.npz \This script performs inference on test data and computes evaluation metrics:
- Large Gap Ratio: Ratio of joint position errors >= 0.5 rad
- Gap IQR: Interquartile range of joint position errors
- Gap Range: Range (max - min) of joint position errors
Results are grouped by payload mass and displayed in tables. This script does not require Isaac Sim and can be run on any machine with PyTorch.
To add support for a new robot, follow these steps:
-
Create a new task directory in
source/sim2real/sim2real/tasks/:- Create a new folder (e.g.,
humanoid_your_task/) - Copy and modify files from
humanoid_operator/orhumanoid_amass/as reference - Implement your environment class (e.g.,
your_robot_env.py) - Create environment configuration (e.g.,
your_robot_env_cfg.py)
- Create a new folder (e.g.,
-
Register the task in
source/sim2real/sim2real/tasks/humanoid_your_task/__init__.py:- Use
gym.register()to register your environment - Reference existing registrations in
humanoid_operator/__init__.py
- Use
-
Create robot configuration in
source/sim2real_assets/sim2real_assets/robots/:- Create a Python file (e.g.,
your_robot.py) - Define robot configuration using
ArticulationCfg - Add joint and body name dictionaries
- Create a Python file (e.g.,
-
Add robot assets:
- Place URDF files in
source/sim2real_assets/sim2real_assets/urdfs/ - Place USD files in
source/sim2real_assets/sim2real_assets/usds/(if using USD) - Create versions with and without payloads if needed
- Place URDF files in
-
Prepare motion data:
- Format your data according to the test data template
- Save as
.npzfiles with required keys (see Motion Data section) - Place in appropriate motion directory
-
Configure agent settings:
- Create or modify agent config in
source/sim2real/sim2real/tasks/your_robot/agents/ - Choose appropriate method (DeepONet, Transformer, or MLP)
- Set network parameters based on your robot's DOF count
- Create or modify agent config in
-
Start training:
- Use the registered task name in training commands
- Adjust
num_envsand other hyperparameters as needed
The DeepONet architecture uses a branch-trunk network structure:
- Branch Network: Processes sensor data at multiple resolutions
- Trunk Network: Processes action targets and payload information
- Fusion: Combines branch and trunk outputs for action prediction
Transformer-based architecture with:
- Multi-head self-attention
- Position-wise feed-forward networks
- Separate actor and critic transformers
Standard multi-layer perceptron with:
- Configurable hidden dimensions
- History buffer for temporal information
- Action and value heads
Operator environment for training with variable payloads and sensor configurations:
- Supports multiple sensor positions
- Handles wrist and hand payloads
- Computes equivalent torques using Pinocchio
- Sub-environment structure for efficient training
AMASS motion tracking environment:
- Loads motion data from AMASS dataset
- Tracks reference motions
- Supports history-based observations
- Computes tracking rewards
Key parameters in environment configs:
mode: "train" or "play"num_envs: Number of parallel environmentsepisode_length_s: Episode length in secondsmax_payload_mass: Maximum payload mass for trainingnum_sensor_positions: Number of sensor configurations
Network-specific parameters:
branch_input_dims: Input dimensions for branch networkstrunk_input_dim: Input dimension for trunk networkhidden_dims: Hidden layer dimensionsmodel_history_length: Length of history buffer
Motion data should be provided in NumPy .npz format with the following keys:
real_dof_positions: Joint positionsreal_dof_velocities: Joint velocitiesreal_dof_positions_cmd: Target joint positionsreal_dof_torques: Joint torquesjoint_sequence: List of joint names for delta actionspayloads: Payload masses (optional)
The framework computes several metrics during evaluation:
- MPJAE: Mean Per-Joint Angle Error (in degrees)
- Large Gap Ratio: Ratio of gaps >= robot_threshold rad
- Gap IQR: Interquartile range of gaps
- Gap Range: Range of gaps
- Upper Body Joint Area: Area under error curve
- EEF Error: End-effector position error
Results are saved as CSV files and visualization plots.