How mandizhao/dexmachina works
Purpose and Entry Points
DexMachina is a Python research stack for functional retargeting of bimanual human manipulation demonstrations to multiple dexterous robot hands, followed by simulation-based RL training and evaluation. Primary executable entry points are retargeting scripts, RL training/evaluation scripts, and shell examples: dexmachina/retargeting/parallel_retarget.py, dexmachina/rl/train_rl_games.py, dexmachina/rl/eval_rl_games.py, and examples/train_rl.sh.
Asset and Embodiment Layer
The repository is asset-heavy: it packages URDFs, collision/visual meshes, and per-hand retarget configuration for supported robot embodiments (Ability, Allegro, Dex3, DexRobot, Inspire, Schunk, XHand) plus MANO human hands. These assets form the kinematic and physical interface consumed by processing, retargeting, and simulation.
• dexmachina/assets/allegro_hand/allegro_hand_right_6dof.urdf
• dexmachina/assets/xhand/retarget_config.yaml
• dexmachina/assets/mano_hand/right/mano.urdf
Demonstration-to-Retargeting Pipeline
ARCTIC manipulation trajectories are stored as processed NumPy sequences. Retargeting code processes source demonstrations, maps contacts, and produces target-hand motion representations. Repository snapshots include both intermediate retargeter vectors (.npy) and final parameterized trajectories (.pt), establishing a file-based pipeline boundary rather than a service API.
• Input demonstrations: dexmachina/assets/arctic/processed/s01/box_use_01.npy
• Pipeline modules: dexmachina/retargeting/process_arctic.py, dexmachina/retargeting/map_contacts.py, dexmachina/retargeting/parallel_retarget.py
• Outputs: dexmachina/assets/retargeted/allegro_hand/s01/box_use_01_vector_para.pt
Simulation Environment Construction
The environment subsystem defines the control loop used for imitation/manipulation training: base environment lifecycle, hand/object construction, contacts, randomization, curriculum, rewards, and demonstration ingestion. Hand-specific Python configurations bridge generic environment construction to the packaged URDF assets; object support includes articulated ARCTIC objects and a plane.
• Core environment: dexmachina/envs/base_env.py, dexmachina/envs/constructors.py, dexmachina/envs/maniptrans_curr.py
• Physics/task boundaries: dexmachina/envs/contacts.py, dexmachina/envs/object.py, dexmachina/envs/robot.py
• Embodiment configs: dexmachina/envs/hand_cfgs/allegro.py, dexmachina/envs/hand_cfgs/dex3.py
Training and Runtime Integration
RL is integrated through a wrapper around a custom rl_games fork, with PPO configuration and separate train/evaluation drivers. The simulation runtime depends on a custom Genesis fork; PyTorch is the primary tensor/runtime dependency. Training additionally expects Gymnasium and may use Ray, Weights & Biases, and visualization/geometry libraries, but no deployed external service is required by the repository structure.
• dexmachina/rl/rl_games_wrapper.py
• dexmachina/rl/configs/rl_games_ppo_cfg.yaml
• dexmachina/rl/train_rl_games.py
Hand Onboarding and Model Transformation
hand_proc is the extension boundary for adding or adapting robot hands. It inspects raw URDFs, adds wrist degrees of freedom, supports minimal retargeting, and tunes gains. Generated/edited URDFs and matching retarget_config.yaml files then feed the normal asset and environment paths.
• dexmachina/hand_proc/inspect_raw_urdf.py
• dexmachina/hand_proc/add_wrist_dof.py
• dexmachina/hand_proc/minimal_retarget.py
Evaluation Outputs
Evaluation utilities compute pose/alignment metrics and aggregate grouped experiment results. Existing group configuration and persisted AUC statistics indicate offline, artifact-based reporting over training/retargeting runs.
• dexmachina/eval/compute_add.py
• dexmachina/eval/group_results.py
• dexmachina/eval/group_cfgs/dexmachina_main.yaml
Main entry points: parallel_retarget.py Parallel retargeting · base_env.py Base environment · allegro_hand_right_6dof.urdf Robot hand assets · process_arctic.py ARCTIC processing
Components 20
Assets & Embodiments
Robot, MANO, and ARCTIC data assets.
- Robot hand assets · Supported hand embodiments and their retarget settings.
dexmachina/assets/allegro_hand/allegro_hand_right_6dof.urdf - Hand retarget config · Per-hand mapping parameters accompany embodiment assets.
dexmachina/assets/xhand/retarget_config.yaml - MANO hand model
dexmachina/assets/mano_hand/right/mano.urdf - ARCTIC demonstrations
dexmachina/assets/arctic/processed/s01/box_use_01.npy
Retargeting Pipeline
File-based conversion of human demonstrations to robot trajectories.
- ARCTIC processing
dexmachina/retargeting/process_arctic.py - Contact mapping
dexmachina/retargeting/map_contacts.py - Parallel retargeting · Produces target-hand motion representations.
dexmachina/retargeting/parallel_retarget.py - Retargeted trajectories · File boundary between retargeting and simulation.
dexmachina/assets/retargeted/allegro_hand/s01/box_use_01_vector_para.pt
Simulation Environment
Genesis-backed manipulation task construction and control.
- Base environment · Owns task lifecycle, control loop, and demonstration ingestion.
dexmachina/envs/base_env.py - Environment construction · Builds hands, objects, and simulation components.
dexmachina/envs/constructors.py - Robot, object & contacts · Encapsulates hand/object construction and contact handling.
dexmachina/envs/contacts.py - Manipulation curriculum · Applies randomization, curriculum, and reward logic.
dexmachina/envs/maniptrans_curr.py - Hand environment configs · Connects generic tasks to hand-specific assets.
dexmachina/envs/hand_cfgs/allegro.py - Custom Genesis fork
RL Training & Evaluation
PPO runtime, experiment execution, and offline reporting.
- RL Games wrapper · Bridges vectorized environments to the custom RL runtime.
dexmachina/rl/rl_games_wrapper.py - PPO configuration
dexmachina/rl/configs/rl_games_ppo_cfg.yaml - RL training
dexmachina/rl/train_rl_games.py - RL evaluation
dexmachina/rl/eval_rl_games.py - Offline metrics & grouping · Computes alignment metrics and aggregates experiment results.
dexmachina/eval/compute_add.py
Hand Onboarding
URDF transformation path for new embodiments.
- Hand processing · Inspects hands, adds wrist DOFs, and supports minimal retargeting.
dexmachina/hand_proc/add_wrist_dof.py
Connections 21
- Hand processing → Robot hand assets: generates or edits
- Hand processing → Hand retarget config: creates matching config
- MANO hand model → ARCTIC processing: human kinematics
- ARCTIC demonstrations → ARCTIC processing: source sequences
- ARCTIC processing → Contact mapping: processed poses
- Contact mapping → Parallel retargeting: contact targets
- Robot hand assets → Parallel retargeting: target embodiment
- Hand retarget config → Parallel retargeting: mapping parameters
- Parallel retargeting → Retargeted trajectories: writes .pt trajectories
- Robot hand assets → Hand environment configs: URDF embodiment
- Hand environment configs → Environment construction: hand specification
- Environment construction → Robot, object & contacts: assembles
- Robot, object & contacts → Base environment: simulation entities
- Retargeted trajectories → Base environment: demonstration ingestion
- Base environment → Manipulation curriculum: task lifecycle
- Custom Genesis fork → Base environment: physics backend
- Manipulation curriculum → RL Games wrapper: observations and rewards
- PPO configuration → RL training: PPO settings
- RL training → RL Games wrapper: runs training
- RL evaluation → RL Games wrapper: runs policy evaluation
- RL evaluation → Offline metrics & grouping: evaluation artifacts