deep-robotics-retarget is a Python toolkit that uses inverse kinematics (IK) to retarget human motion data to humanoid robot joint configurations. It supports multiple human motion data sources and provides real-time visualization based on MuJoCo. Currently, the project supports the DR02 Pro robot model.
This project is modified from the GMR project.
- Multiple Input Sources: Supports SMPLX, BVH (Lafan1 / Nokov), and other motion capture formats
- Two-Stage IK Solving: Orientation-only tracking followed by combined position + orientation tracking
- Collision Avoidance: Optional self-collision and floor collision avoidance
- Body Scaling: Automatic mapping of human body proportions to the robot
- Real-Time Visualization: MuJoCo-based viewer with human motion overlay
- Batch Processing: Dataset-scale motion retargeting
| Robot | Status |
|---|---|
| DR02 Pro | ✅ Supported |
The framework is designed to be extensible. To add a new robot:
- Add the robot's MuJoCo XML to
assets/ - Create an IK configuration JSON in
general_motion_retargeting/ik_configs/ - Register the robot in
general_motion_retargeting/params.py
mujoco— Physics simulation and visualizationmink— Inverse kinematics solversmplx— SMPL-X body model (installed from GitHub)qpsolvers[proxqp]— QP solver for IKredis[hiredis]— Real-time streaming
Download the body model from the SMPL-X official website. It is recommended to download the SMPL-X with removed head bun (NPZ, 392MB) version. Extract and place it in the assets/body_models/smplx/ folder:
assets/body_models/smplx/
├── SMPLX_NEUTRAL.npz
├── SMPLX_FEMALE.npz
└── SMPLX_MALE.npz
Note
This project uses npz model files by default. If you downloaded pkl format files from the SMPL-X website, you need to change the ext parameter in the create() function within the smplx library's smplx/body_model.py from the default value npz to pkl, or convert the pkl files to npz format.
Download raw data from AMASS to any location. Make sure to select bodies as SMPL-X G or SMPL-X N. It is recommended to place it under source_data/AMASS/. For quick start, two sample files are provided in source_data/AMASS_demo/.
Download raw BVH files from the LAFAN repository (lafan1.zip), extract and place them under source_data/lafan1/. For quick start, two sample files are provided in source_data/lafan1_demo/.
Capture the required data using Nokov motion capture equipment. For quick start, three sample files are provided in source_data/nokov_demo/.
- Python == 3.11
- Linux (Ubuntu 22.04 / 24.04 recommended)
Note
This project has been tested on Ubuntu 24.04.
Create a Python 3.11 Conda environment for this project. If deep-robotics-humanoid already exists, activate it and skip creation. The MuJoCo retargeting workflow can be installed independently of Isaac Lab.
For a new environment:
conda create -n deep-robotics-humanoid -c conda-forge python=3.11 "libstdcxx-ng>=15" -y
conda activate deep-robotics-humanoid Then clone the repository and install:
# Clone the repository
git clone https://github.com/DeepRoboticsLab/deep-robotics-retarget.git
cd deep-robotics-retarget
# Install the package
python -m pip install -e .Configure the C++ runtime from this repository (Linux/Bash):
python scripts/setup_conda_runtime.py
conda deactivate
conda activate deep-robotics-humanoidThe script checks that Conda's libstdc++.so.6 provides CXXABI_1.3.15 and installs activation/deactivation hooks in the active environment. These preload Conda's runtime to avoid native-library failures caused by loading an older system copy. If the runtime is missing or outdated, run conda install -c conda-forge "libstdcxx-ng>=15", then retry. Re-running setup is safe; existing LD_PRELOAD settings are restored on deactivation, and system libraries are unchanged. Restart existing Python processes after reactivation. The hook does not install Python dependencies: if mujoco or another module is missing, complete python -m pip install -e . in this environment.
Tip
If using pip install . (non-editable mode), you need to set the environment variable to the project root:
export DEEP_ROBOTICS_RETARGET_ROOT=/path/to/deep-robotics-retargetInstall PICO SDK:
# Pull submodules
git submodule update --init
# Run the build script
bash XRobotPico_build.shpython scripts/smplx_to_robot.py \
--smplx_file <path_to_smplx_data.npz> \
--save_path <path_to_save_robot_data.pkl> \
--rate_limitBy default, running this program will display the robot motion retargeting in real-time in a MuJoCo window.
Optional parameters:
--rate_limit: Limit the retargeted robot motion data frequency to match human motion speed--record_video: Record a video of the robot motion retargeting, saved to thevideos/folder--robot: Select the robot model for retargeting, default isDR02_pro
python scripts/smplx_to_robot_dataset.py \
--src_folder <path_to_dir_of_smplx_data> \
--tgt_folder <path_to_dir_to_save_robot_data>By default, batch motion retargeting does not visualize the motion.
Note
Default FPS: lafan1=30, nokov=200. Use --motion_fps to customize the data sampling frequency.
# Lafan1 format
python scripts/bvh_to_robot.py \
--bvh_file <path_to_bvh_data> \
--save_path <path_to_save_robot_data.pkl> \
--format lafan1 \
--rate_limit \
--motion_fps 30
# Nokov format
python scripts/bvh_to_robot.py \
--bvh_file <path_to_bvh_data> \
--save_path <path_to_save_robot_data.pkl> \
--format nokov \
--rate_limit \
--motion_fps 200# Lafan1 format
python scripts/bvh_to_robot_dataset.py \
--src_folder <path_to_dir_of_bvh_data> \
--tgt_folder <path_to_dir_to_save_robot_data> \
--format lafan1
# Nokov format
python scripts/bvh_to_robot_dataset.py \
--src_folder <path_to_dir_of_bvh_data> \
--tgt_folder <path_to_dir_to_save_robot_data> \
--format nokov# Single file
python scripts/pkl_to_npz.py \
--input <path_to_pkl_data> \
--output <path_to_npz_data> \
# Batch convert
python scripts/pkl_to_npz.py \
--input_dir <path_to_dir_of_pkl_data> \
--output_dir <path_to_dir_of_npz_data> \
With the MuJoCo viewer focused, press Space to pause/resume in either script. In dataset browsing, press [ for the previous motion or ] for the next motion. Playback controls are keyboard-only; there is no separate frame-seeking window.
# Single motion
python scripts/vis_robot_motion.py \
--robot_motion_path <path_to_pkl_data>
# Dataset browsing (use '[' and ']' to switch motions)
python scripts/vis_robot_motion_dataset.py \
--robot_motion_folder <path_to_dir_of_pkl_data>python scripts/plot_retarget_motion.py \
--bvh_file <path_to_bvh_data> \
--format nokovResults are saved in the plots/ folder, including plots of root position, root orientation, and joint angles over time.
from general_motion_retargeting import GeneralMotionRetargeting, RobotMotionViewer
# Initialize retargeting
retarget = GeneralMotionRetargeting(
src_human="bvh_nokov", # Source data format
tgt_robot="DR02_pro", # Target robot
actual_human_height=1.75, # Optional: actual human height
)
# Retarget a single frame
# human_data: dict, format is {body_name: (position, quaternion)}
qpos = retarget.retarget(human_data)
# Extract joint information
root_pos = qpos[:3]
root_rot = qpos[3:7] # quaternion (wxyz)
joint_angles = qpos[7:]deep-robotics-retarget/
├── general_motion_retargeting/ # Core package
│ ├── motion_retarget.py # Main IK retargeting class
│ ├── robot_motion_viewer.py # MuJoCo visualization
│ ├── kinematics_model.py # Analytical forward kinematics
│ ├── playback_controller.py # GUI playback control
│ ├── neck_retarget.py # Head/neck retargeting
│ ├── data_loader.py # Motion data I/O
│ ├── params.py # Robot/config registry
│ ├── rot_utils.py # Rotation utilities
│ ├── torch_utils.py # PyTorch rotation ops
│ ├── xrobot_utils.py # XRobot SDK integration
│ ├── ik_configs/ # IK configuration JSONs
│ └── utils/ # Data format loaders
│ ├── smpl.py # SMPL/SMPLX loading
│ └── lafan1.py # BVH (Lafan1/Nokov) loading
├── scripts/ # Example scripts
│ ├── smplx_to_robot.py # SMPLX retargeting
│ ├── bvh_to_robot.py # BVH retargeting
│ ├── bvh_to_robot_dataset.py # Batch BVH processing
│ ├── vis_robot_motion.py # Motion visualization
│ ├── plot_retarget_motion.py # Retargeting result plotting
│ └── ... # Other utilities
├── assets/ # Robot models and body models
│ ├── DR02/ # DR02 Pro robot model
│ └── body_models/smplx/ # SMPL-X body models
└── source_data/ # Sample motion data
This project is licensed under the BSD 3-Clause License. The original GMR project is licensed under the MIT License, see LICENSE_GMR.
