This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
SPIDER (Scalable Physics-Informed DExterous Retargeting) is a physics-based retargeting framework that converts human motion (from video or mocap) into robot actions for dexterous hands and humanoid robots. Developed by Meta/FAIR. Python 3.12+, licensed CC BY-NC 4.0.
uv sync # Install dependencies (preferred)
pip install --no-deps -e . # Editable install without pulling depsruff check . # Lint
ruff check --fix . # Auto-fix
ruff format . # Formatuv run spider/simulators/mjwp_test.py # MuJoCo Warp simulator
uv run spider/simulators/dexmachina_test.py # DexMachina simulator
uv run spider/simulators/hdmi_test.py # HDMI simulator# Single task
uv run examples/run_mjwp.py +override=gigahand task=p36-tea data_id=0 robot_type=xhand embodiment_type=bimanual
# With remote viewer
uv run examples/run_mjwp.py viewer="rerun"uv run spider/process_datasets/gigahand.py --task=TASK --embodiment-type=TYPE --data-id=ID
uv run spider/preprocess/decompose_fast.py --task=TASK --dataset-name=NAME --data-id=ID --embodiment-type=TYPE
uv run spider/preprocess/detect_contact.py --task=TASK --dataset-name=NAME --data-id=ID --embodiment-type=TYPE
uv run spider/preprocess/generate_xml.py --task=TASK --dataset-name=NAME --data-id=ID --embodiment-type=TYPE --robot-type=ROBOT
uv run spider/preprocess/ik.py --task=TASK --dataset-name=NAME --data-id=ID --embodiment-type=TYPE --robot-type=ROBOT --open-hand
uv run examples/run_mjwp.py +override=NAME task=TASK data_id=ID robot_type=ROBOT embodiment_type=TYPE- Ruff for linting and formatting: 88-char line length, Google-style docstrings, Python 3.12+ target
- See
[tool.ruff]inpyproject.tomlfor full lint rule configuration
spider/config.py defines a single @dataclass Config (~150 fields) that drives the entire pipeline. Configs are loaded via Hydra/OmegaConf from YAML files in examples/config/. Dataset-specific overrides live in examples/config/override/. The +override=DATASET Hydra syntax selects a dataset config overlay.
- Raw data (
.pkl) →spider/process_datasets/*.pyconverts dataset-specific formats to standard NPZ - Preprocessing (
spider/preprocess/) → mesh decomposition, contact detection, scene XML generation, inverse kinematics - Physics optimization (
examples/run_mjwp.py) → sampling-based MPC retargeting using simulator - Postprocessing (
spider/postprocess/) → success metrics, robot deployment prep
- MJWP (
mjwp.py, ~1400 lines) — primary backend, GPU-accelerated MuJoCo + Warp with batched environments - MJWP-EQ (
mjwp_eq.py) — variant with equality constraints - DexMachina (
dexmachina.py) — Genesis simulator for RL training - HDMI (
hdmi.py) — humanoid RL workflow - Isaac (
isaac.py) — NVIDIA Isaac integration
Sampling-based MPC using cross-entropy method. Key functions: make_rollout_fn, make_optimize_fn, make_optimize_once_fn. Supports torch.compile for speedup, noise scheduling with temperature annealing, and contact guidance.
Multiple visualization backends (MuJoCo, Rerun, Viser) with a common interface. Selected via viewer= config parameter. Supports simultaneous multi-viewer (e.g., viewer="mujoco-rerun").
Each supported dataset (GigaHands, OakInk, Hot3D, GMR, FAIR-MON, FAIR-FRE) has a dedicated processor that converts raw data to standard format. New datasets require a new processor here outputting NPZ files.
Requires: MJCF assets in spider/assets/, embodiment mappings in spider/config.py, and reward weight tuning.
spider/io.py— data loading/saving, path resolutionspider/math.py— quaternion/rotation math utilitiesspider/interp.py— trajectory interpolationspider/mujoco_utils.py— MuJoCo model helpers