This module focuses on retargeting human hand motion to control a robot arm + hand system within the ManiSkill simulation environment for completing various manipulation tasks.
Ensure your camera's focal length is accurately set for pose estimation.
- Modify
scaled_focal_lengthinwilor_hand_pose3d_estimation_pipeline.pyto match your camera'sfx. - Note: If you are unsure of your camera's focal length, use the tools in
manitask/camera_clibto calibrate it.
ManiSkill is the simulation environment used for the tasks.
cd thirdparty/ManiSkill
pip install -e .Requirement: ManiSkill requires Vulkan to be installed on your system.
Install additional dependencies required for processing and storing teleoperation data.
pip install open3d urdf_parser_py zarr fpsampleRun the teleoperation example to control an xArm7 with an Allegro Hand (Right):
python teleoperate.py --arm xarm7 --hand allegro --hand-type rightThe data collection process involves teleoperation, merging episodes, point cloud processing, and converting to Zarr format.
Run the teleoperation script. You can modify the env_id in teleoperate.py to switch environments (default example: LiftPegUpright-v1).
python teleoperate.py --arm xarm7 --hand allegro --hand-type right- Storage: Data is saved to
manitask/data/h5/{TaskName}/{RobotID}/origin/episode_{idx}.h5. - Auto-Save: Successful episodes are automatically saved. If
max_stepis exceeded, the episode is discarded.
Combine multiple recorded episodes into a single dataset.
- Run:
bash manitask/scripts/merge.bash - Configure: Edit the script to specify episode ranges (e.g.,
0-9). - Output:
manitask/data/h5/{TaskName}/{RobotID}/merged/
Sample and downsample point clouds from the robot model.
- Configure: Update
robot_uidin the scripts as needed.
python robot_pc_collection.py
python robot_pc_downsample.pyVerify data by replaying and converting it to the Zarr format for training.
- Run:
bash manitask/scripts/tozarr.bash - Output (Replay):
manitask/data/h5/{TaskName}/{RobotID}/merged/ - Output (Zarr):
manitask/data/zarr/{TaskName}/{RobotID}/ - Features: The bash script allows toggling replay, video saving, zarr conversion, and visualization independently.
📝 Note: Ensure you update
env_idandrobot_idin the bash scripts (merge.bash,tozarr.bash) to match your current task and robot configuration.
Follow this guide to integrate a new robot configuration (e.g., xarm7_shadow_right).
- Place
xarm7_shadow_right.urdfinthirdparty/ManiSkill/mani_skill/assets/robots/xarm7. - Naming Convention:
arm_hand_handtype(e.g.,xarm7_shadow_right).
Create a new agent file thirdparty/ManiSkill/mani_skill/agents/robots/xarm7/xarm7_shadow.py.
- Template: Copy an existing agent file to start.
- Class Name: Update to
XArm7Shadow. - UID: Set to
xarm7_shadow_right. - Friction Config: Update
urdf_configlinks (e.g., replacethtipwith your hand's fingertip link names). - Joint Names: Set
self.arm_joint_namesandself.hand_joint_names. Use/manitask/utils/URDF_check.pyto inspect the URDF. - Keyframes (Rest Pose): Set the
restqpos. This is theenv.resetinitial pose.- Crucial: Dimensions must match total active joints.
- Debug: Use
python test_qpos.py -r "robot_uid" -c "pd_joint_pos" --keyframe-actionsto visualize and adjust. - Tip: Align the robot palm with your hand's initial orientation to help the retargeting "warm start". Ensure the arm is not below the hand to avoid table collisions.
- EE Link: Set
self.ee_link_name(required for some tasks likePushCube-v1). - Register: Import the new class in the folder's
__init__.pyandagents/robots/__init__.py.
Edit the task file (e.g., thirdparty/ManiSkill/mani_skill/envs/tasks/tabletop/PushCube-v1.py):
- Import your new agent class.
- Add it to
SUPPORTED_ROBOTS. - Add the Class and UID to the
agentattribute. - (Optional) Add a hand camera config in
_default_human_render_camera_configsfor better visualization.
Create a config file dex_retargeting/configs/manitask/xarm7/leap_right.yml.
- Ref: Copy from
dex_retargeting/configs/manitask/teleop. - Edit: Update URDF path and set
add_dummy_joint: False.
Edit dex_retargeting/constants_mani.py:
- Add entries to
ArmName,HandName,HAND_NAME_MAP, andARM_NAME_MAP. - Define
LINK_BASE(robot root) andLINK_WRIST(hand palm root).
To improve initial retargeting stability, you can provide a warm start pose (usually the agent's rest keyframe).
- Camera Visualization: Modify
_default_human_render_camera_configsin the task file (e.g.,pick_cube.py) to change visualization angles. - Scene Initialization: Adjust initial positions of robots and objects in
_initialize_episodewithin the task file. - Retargeting Solvers: Explore different solver types (Position, Vector, Dexpilot) in the WiLoR-mini README.
- Retargeting Configs: All solver parameters are located in
dex_retargeting/configs/manitask/.
