1 Environment Setup
The full X2 locomotion reinforcement-learning pipeline (URDF → Isaac Lab training → ONNX export → MuJoCo sim2sim → real-robot deployment) spans two mutually exclusive Python environments. This section explains how to get the code and set up both the training and deployment environments.
1.1 Overview: why two environments are needed
The full X2 pipeline involves two Python environments, which are version-incompatible and cannot be merged into a single environment:
Role |
Purpose |
Python |
Key dependencies |
|---|---|---|---|
Training machine |
Isaac Lab PPO training, ONNX export, MuJoCo sim2sim |
conda Python 3.11 |
IsaacSim / IsaacLab / rsl_rl |
Deployment machine |
Connects to the real robot and runs the deployment script |
System Python 3.10 |
ROS2 Humble / aimdk_msgs / onnxruntime |
The root cause of the conflict is: ROS2 Humble is bound to system Python 3.10, whereas IsaacLab requires Python 3.11, and the two cannot coexist in the same interpreter. The training environment is therefore isolated with conda, while the deployment environment uses system Python directly. The only hand-off artifact between the two environments is the exported extra/mc-rl/x2_deploy_pkg/models/policy.onnx—produced by the training machine and loaded by the deployment machine.
1.2 Getting the Code
The code and assets in this chapter are shipped together with the SDK package. For how to obtain the SDK package, see Get the SDK.
After obtaining it, enter the root directory of the SDK main repo (the actual path depends on where you obtained it); this directory is hereafter referred to as the code root directory, and unless otherwise noted, all commands are executed in this directory.
The RL training and validation code lives in the git submodule extra/mc-rl/. If that directory is empty or missing, first run the following command from the code root directory:
git submodule update --init --recursive extra/mc-rl
The directory layout of extra/mc-rl/ is as follows; confirm that its contents are complete before proceeding to environment setup:
extra/mc-rl/
├── rl/ # RL training and validation code
│ ├── agibot_rl_lab/ # X2 robot definition, RL task and PPO config; training / inference scripts in scripts/rsl_rl/{train,play}.py
│ ├── sim2sim/ # sim2sim validation script
│ └── train/ # batch training, model export and checkpoint selection
├── x2_deploy_pkg/ # real-robot deployment package
│ ├── deploy_x2.py # main deployment program
│ ├── env_check.sh # pre-deployment self-check script
│ ├── deploy_to_board.sh # one-click deployment script
│ └── models/
│ └── policy.onnx # deployment model (the only hand-off artifact: exported by the training machine, loaded by the deployment machine)
├── x2_config/ # config layer shared by training / sim2sim / deployment
│ ├── joint_gains.yaml # single source of truth for joint PD gains, loaded by joint_gains.py in the same directory
│ ├── shared/ # constants (policy_defs.py) and key bindings (keyboard.py) shared by all three ends
│ ├── deploy/ # deployment-side parameters (deploy_config.py: HAL topic mapping, control parameters, etc.)
│ └── sim/ # sim2sim-side parameters (sim_config.py: MuJoCo scene, simulation step, etc.)
├── third_party/
│ └── unitree_rl_lab/ # the Unitree training framework it depends on (X2 reuses its mdp)
└── x2_urdf/ # URDF and MuJoCo XML assets for X2
1.3 Training Environment
The training machine handles Isaac Lab PPO training, ONNX export, and MuJoCo sim2sim, using conda Python 3.11.
Version Table
Component |
Requirement |
Reference tested version |
|---|---|---|
Python |
3.11 |
3.11.15 |
IsaacSim |
5.1.0 |
5.1.0.0 |
IsaacLab |
2.3.2 |
2.3.2 |
rsl_rl (rsl_rl_lib) |
5.0.1 |
5.0.1 |
MuJoCo |
≥ 3.0 |
3.7.0 |
PyTorch |
CUDA build |
2.7.0+cu128 |
numpy |
— |
1.26.0 |
onnxruntime |
— |
1.24.4 |
NVIDIA driver |
≥ 580.65 |
580.126.09 |
GPU |
RTX 5090 |
RTX 5090 |
Installing Key Dependencies
See the “Version Table” above for the version requirements of each component. Install in the following order:
NVIDIA driver: install following NVIDIA’s official documentation.
PyTorch (CUDA build): see the PyTorch website and select according to your local CUDA version.
Isaac Sim / Isaac Lab: see the official Isaac Lab installation docs (the conda workflow they provide is recommended, which can install Isaac Sim at the same time).
Activate the training environment and specify the Isaac Lab installation directory:
conda activate isaaclab export ISAACLAB_PATH=<isaaclab-path> # Point to the local Isaac Lab install dir; use the actual path
Install the remaining Python dependencies (MuJoCo, rsl_rl, onnxruntime, numpy):
pip install mujoco rsl-rl-lib onnxruntime numpy
Installing the two extension packages in this repository
In the activated training environment, install the two packages unitree_rl_lab and agibot_rl_lab in editable mode (pip install -e):
pip install -e extra/mc-rl/third_party/unitree_rl_lab/source/unitree_rl_lab # Unitree framework (reuse its mdp)
pip install -e extra/mc-rl/rl/agibot_rl_lab/source/agibot_rl_lab # AgiBot X2 (robot / task / PPO / scripts)
Editable mode (-e) does not copy the source code; instead, it links the source directories in the repository directly into the Python environment, so edits to the source take effect immediately without reinstalling—convenient for repeatedly modifying files such as velocity_env_cfg.py while tuning a training recipe. The source code of both packages lives under extra/mc-rl/, and it is exactly this source that gets installed.
Note
The division of responsibilities between the two packages:
unitree_rl_labis reused as the underlying framework; X2 onlyimports itsmdp(reward / curriculum / observation) and does not modify its source code.agibot_rl_labis X2’s own implementation, containing the training scripts and PPO config (already adapted for X2).
Once installed, you can run training (train.py), export (play.py --export-only), and sim2sim (extra/mc-rl/rl/sim2sim/sim2sim_x2.py) in this environment; see the two documents Training and model export and sim2sim validation for details.
1.4 Deployment Environment
Deployment Environment Version Table
Component |
Version |
|---|---|
Python |
3.10 |
ROS2 |
Humble |
aimdk_msgs |
AimDK workspace |
onnxruntime |
>= 1.16 |
numpy |
System / |
Warning
The deployment machine installs neither conda nor IsaacLab; it uses system Python 3.10 directly to avoid a Python version conflict with ROS2 (see “Troubleshooting” below). If onnxruntime or numpy is missing, you can install it into the user directory via pip3 install --user onnxruntime / pip3 install --user numpy.
source order
Before deployment you must source two setups in order: first the ROS2 base, then the AimDK workspace.
source /opt/ros/humble/setup.bash
source <aimdk-workspace>/install/setup.bash # AimDK workspace; use the actual local path
Use the actual local install path for the AimDK workspace. To verify: after sourcing, run the following command; if the import succeeds, the configuration is correct:
python3 -c "from aimdk_msgs.msg import JointCommandArray"
1.5 Troubleshooting
Problem |
Cause |
Solution |
|---|---|---|
Python version conflict |
ROS2 is py3.10 and IsaacLab is py3.11; the two are mutually exclusive |
Use conda (py3.11) for training and system Python (py3.10) for deployment—physically isolated |
|
The AimDK workspace was not sourced |
Run |
|
The 5-second |
|
|
Centralized DDS discovery issue |
Use an rclpy script to publish/subscribe topics directly instead (e.g. the main deployment program |
|
conda/miniforge is installed on the development machine, so the default |
The deployment script must run with system Python 3.10: first run |
Warning
Origin and nature of KP/KD (spanning training and deployment): the joint KP/KD come from the single source of truth extra/mc-rl/x2_config/joint_gains.yaml (loaded via extra/mc-rl/x2_config/joint_gains.py), and all three—training agibot.py, sim2sim, and deployment extra/mc-rl/x2_deploy_pkg/deploy_x2.py—read from here, so a change in one place takes effect in all three simultaneously. Of these, rl_gains (model X2 T2.5) are simulated values, not measured on the real robot; the stance-phase standup_gains and the damping damping_kd are measured values. No changes are needed when setting up the environment—this is just for awareness.
Once the environment is ready, proceed to Training and model export.