Giter Club home page Giter Club logo

dex-hand-teleop's Introduction

From One Hand to Multiple Hands: Imitation Learning for Dexterous Manipulation from Single-Camera Teleoperation

From One Hand to Multiple Hands: Imitation Learning for Dexterous Manipulation from Single-Camera Teleoperation

Yuzhe Qin, Hao Su*, Xiaolong Wang*, RA-L & IROS 2022.

Here we provide a simple system for teleoperation with dexterous hand in simulation, as well as a conversion between MANO/SMPL hand format and simulatable robot model (.urdf) format

Teaser

Installation

git clone [email protected]:yzqin/dex-hand-teleop.git
cd dex-hand-teleop 
conda create --name dexteleop python=3.8
conda activate dexteleop
pip install -e .

Download data file for the scene from Google Drive Link. Place the day.ktx at assets/misc/ktx/day.ktx.

pip install gdown
gdown https://drive.google.com/uc?id=1Xe3jgcIUZm_8yaFUsHnO7WJWr8cV41fE

Download additional weights for hand detection

Follow the guidelines provided by the FrankMocap project to download the weight files for the SMPLX hand model and hand pose detector.

Please note that you only need to obtain a subset of the files utilized in the original FrankMocap repository. If the process is completed successfully, the final file structure should appear as follows within the hand_detector/extra_data directory. Some weights required by FrankMocap is not necessary for this repo if not listed below.

├── extra_data
│   ├── hand_module
│   │   ├── mean_mano_params.pkl
│   │   ├── pretrained_weights
│   │   │   └── pose_shape_best.pth
│   │   └── SMPLX_HAND_INFO.pkl
│   └── smpl
│       └── SMPLX_NEUTRAL.pkl

File Structure

  • hand_teleop: main content for the environment, utils, and other staff needs for simulation. It utilizes the same code structure as DexPoint.
  • hand_detector: perception code and model to detect hand bbox and regress hand pose in SMPLX format
  • assets: robot and object models, and other static files
  • example: entry files to learn how to use the teleoperation and the customized robot hand

How to Use

Use the customized robot hand proposed in the paper

Run example/customized_robot_hand.py to learn how to construct and control a robot hand based on SMPLX hand parameterization.

Replay the collected demo and generate observation-action trajectory

Run example/simple_replay.py to visualize the provided example_teleop_data for each task. It simply replays the demonstration without modification, i.e. visualize the saved demonstration trajectory without retargeting and generating anything.

Teaser

Run example/replay_generate_bc_data.py to visualize the processed example_teleop_data for each task. It replays the demonstration after retargeting and generate the state-action trajectory that can be consumed by imitation learning algorithms.

Teaser

Use the teleoperation system to collect some demo

Before running the teleoperation demo, make sure that your computer are connected to an iPhone and iPad, and the Record3D app are installed on your device. I am really sorry that the current teleoperation code requires USB connection to the iPad/IPhone, which is not a free function of this app. Feel free to email me if you know other IOS app that provides free camera streaming functionality.

Then follow the instructions in the Record3D repo to make sure that your computer can stream the video from iPhone/iPad. You need to first successfully run the Record3D example before running the teleoperation demo.

Next, set the parameters correctly on your Record3D app. You should use the front FaceID camera instead of the rear lidar camera. The Live RGBD Video Streaming mode should be set to USB. The Animation Rate (FPS) should be set to 15 initially. You can increase FPS if your hardware is great.

Run example/teleop_collect_data.py to learn how to utilize the teleoperation system to perform a manipulation data and collect the data as a pickle file. If you can see a colored human, it means that you are at the stage of initialization. During initialization, you need to keep your finger spread out and flat to finish the initialization. Otherwise, the initialization process will be restarted again and again. Place the iPhone/iPad in a good position will make your teleoperation much easier, e.g. similar as Figure 3 in the paper.

Pipeline of Using Teleoperation for Imitation Learning

  1. Integrate a new simulation environment into hand_teleop/env/sim_env. This environment should include all necessary simulation entities, except for the robot. For instance, a grasping task might only require a table and an object within the simulation environment. Data collection for teleoperation will be performed in this simulation environment.

  2. Use teleoperation to collect data within the simulation environment as in the teleop_collect_data.py above. This process saves the simulation's internal state during teleoperation without taking into account observations and rewards from the reinforcement learning (RL) perspective.

  3. Based on the simulation environment, define an RL environment within hand_teleop/env/rl_environment. Building upon the simulation environment, the RL environment incorporates the definition of observations, actions, rewards, and reset functions.

  4. When generating Imitation Learning data (e.g., state-action trajectories for Behavioral Cloning or reward trajectories), replay or reload the collected simulation states from step 2 and produce corresponding RL data. The advantage of decoupling teleoperation and RL environment definition is that any changes to the observation space (e.g., transitioning from state observation to depth image) do not require recollecting data. Instead, simply replay the pre-collected simulation states to generate new observations.

Acknowledgements

We would like to thank the following people for providing valuable feedback when testing the system.

Jiarui Xu, Crystina Zhang, Binghao Huang, Jiashun Wang, Ruihan Yang, Jianglong Ye, Yang Fu, Jiteng Mu, Shaowei Liu.

We would like to express our gratitude to the authors of SMPL-X for providing the hand representation, as well as the creators of FrankMocap and MediaPipe for their amazing hand pose detector.

This repository employs the same code structure for simulation environment to that used in DexPoint.

Thanks enyen for adding the RealSense support in the pull request.

Bibtex

@misc{qin2022from,
  author         = {From One Hand to Multiple Hands: Imitation Learning for Dexterous Manipulation from Single-Camera Teleoperation},
  title          = {Qin, Yuzhe and Su, Hao and Wang, Xiaolong},
  archivePrefix  = {arXiv},
  year           = {2022},
}

dex-hand-teleop's People

Contributors

enyen avatar yzqin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

dex-hand-teleop's Issues

Robot Assets

Where can I get the assets for robot to run `example/replay_generate_bc_data.py'

hand pose estimation

Hi @yzqin

Great work!!! I would like to know which hand pose estimation method is better, the method used in this paper or the one used in dexmv-sim? What's the difference between them and why did you choose a new method for hand pose estimation?

Choice of optimization algorithm

Hi, I am using your code to retarget a 5-fingered hand different from the ones considered for your experiments. I am running the code in optimizer.py and I noticed that it is quite common to have nlopt failure errors. For example, this happens changing the following line:

init_qpos = np.clip(random_qpos + np.random.randn(robot.dof) * 0.1, joint_limit[:, 0], joint_limit[:, 1])

into:
init_qpos = np.clip(random_qpos + 0.1, joint_limit[:, 0], joint_limit[:, 1])
I tried to modify the algorithm used for optimization in nlpopt and the amount of nlopt failure errors decreases. Are there any motivations to choose the LD_LBFGS algorithm for optimization? Did you experience any problems with different algorithms? Thanks in advance!

How to use properly the code

Good afternoon, I am using the code provided for my own robotic hand. I have been able to load it correctly but the steps to follow are not very clear. What I have followed so far is:

  1. Launch teleop_collect_data.py for one of the proposed tasks (for example the task of opening the door).
  2. Repeat the process modifying the name of the data (default is 0000.pkl, I take different data until I get about 30 demos).

Once I have this, I don't know how to continue to use the DAPG. I don't know exactly if I have to launch some additional process to generate the .pkl of the imitation process to be later reproduced with the code replay_generate_bc_data.py. Could you tell me which are the steps to follow? Maybe i am doing something wrong and instead of recording different pkl for each demostrantion, has to be all of them in the same demonstration (instead of 0000.pkl,0001.pkl,0002.pkl... it has to be just one 0000.pkl that contain all the demosntrations)
Thank you very much for your work.

Thanks for the great work.

I got the program running.Are there some methods to adjust the back and forward movement of the hand.In my experiment,the hand didn't move back and forward well,it's okay to move left and right.

Releasing training data

Do you have any plan to release the 50 collected demo used for training in each task?
Thanks!

No module named 'hand_detector'

(dexteleop) (base) *****@*****:~/dex-hand-teleop$ /home/*****/anaconda3/envs/dexteleop/bin/python /home/*****/dex-hand-teleop/example/teleop_collect_data.py Traceback (most recent call last): File "/home/*****/dex-hand-teleop/example/teleop_collect_data.py", line 7, in <module> from hand_detector.hand_monitor import Record3DSingleHandMotionControl ModuleNotFoundError: No module named 'hand_detector'

When I try to run the teleop_collect_data.py file, I encounter the aforementioned error. Could you advise on how to resolve this issue? Did I make a mistake during the installation process?

hand movement during teleop

The code is running smoothly, but when i am running the teleop_collect_data.py the hand movement and grasping in the sapien are not as sensitive as shown in the demonstration. I tried plotting the visualization as well.

I also tried plotting the estimated x,y,z position of the hand w,r,t time. I plotted 3 positions

XYZ_vs_time

blue -> current_pose which i got from self.robot.get_qpos()
green -> estimated robot_qpos given as input to the mano_robot.control_robot()
orange -> is the next estimated position of the robot_qpos using the LPFilter

It can be seen that initially when the hand is stable the blue(current_pose), green(estimated position) and the orange(next estimated robot_qpos) almost over laps, but when i move my hand, it takes atleast 10-15 frames for the blue curve to overlap the orange and green curve.

To ensure stability i am also dividing the estimated robot's qpos's translation value by 30, because without that the hand in sapien is moving even when my hand is stable.

Can you please help me with this?

assets/misc

It seems that assets/misc/ktx/day.ktx were missing.when I run replay_generate_bc_data.py:
RuntimeError: filesystem error: cannot make canonical path: No such file or directory [/home/ustc/PycharmProjects/dex-hand-teleop/assets/misc/ktx/day.ktx]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.