Dex-Net installation procedure on system installed with Anaconda and ROS

This blog explains installation procedure for Dex-Net on a system installed with Anaconda and ROS. If you don't have or willing to uninstall Anaconda and work with the Dexnet then you can follow the installation procedure as explained in berkeley automation documentation. I wanted to retain Anaconda, Jupyter installation on my system, hence i've documented the procedure so that it will help people who are in a similar situation. Most part of this blog is similar to the procedure provided in berkeley automation blog, it has been added with few workarounds for the problems that you might come across.

Dex-Net package is a Python API for working with the dex-net database. It lets you manage HDF5 database, supports creation of databases with custom datasets of your own objects. The HDF5 databases consists of 3D object models, parallel-jaw grasps, and grasp robustness metrics used in the Dex-Net 2.0 paper.

Download the datasets
  1. GQ-CNN Training Datasets 
  2. Pre-trained GQ-CNN Models
  3. Object Mesh Dataset v1.1 
  4. HDF5 Database of 3D Objects, Parallel-Jaw Grasps for YuMi, and Robustness Metrics
Installation procedure for Dex-Net

1. Clone the Dex-Net repository
$ cd /path/to/your/catkin-workspace/src
$ git clone https://github.com/BerkeleyAutomation/dex-net.git

2. Run the installation script
The installation script will install the required dependencies like tensorflow, numpy, scipy, scikit, SDFGen, Boost.NumPy, autolab_core, perception, gqcnn, meshpy, visualization.

$ sudo sh install.sh {cpu|gpu} {python|ros}

Choose between cpu or gpu:
  •  cpu: no TensorFlow GPU support
  •  gpu: TensorFlow GPU support for GQ-CNN training
Choose between Python or ROS:
  • python: Python-only installation. No ROS services will be installed for dex-net or any of the Berkeley AUTOLAB modules.
  • ros: Installation as a ROS package. Enables ROS services for the Berkeley AUTOLAB modules and supports dex-net ROS nodes and services that may be developed in the future.
I had installed with gpu support and ros.
$ sudo sh install.sh gpu ros

Since in the workspace dependencies are installed with root user, the autolab_core, perception, gqcnn, meshpy, visualization packages gets cloned with owner being root. You can change the permission with command
$ sudo chmod -R a+rw {package}

Boost.NumPy will be installed but its library path will not be configured. Hence, specify its path in the .bashrc file.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/lib64

In my case the tensorflow had been preinstalled using anaconda, hence i removed the tensorflow that got installed using the installation script.
$ sudo pip uninstall tensorflow

3. Build the catkin workspac
$ catkin_make

4. Test the installation
$ python setup.py test

Even if doesn't work it is fine. You can go ahead.

5. Pre-resolve the errors that might occur while running dexnet command line interface and training GQ-CNN network
Install joblib package in case of error: "Unable to import DataStreamSyncer and Recorder! Likely due to missing multiprocess"
$ sudo apt-get install python-joblib

Install empy package in case of error: ImportError: No module named em
$ pip install empy

Upgrade your numpy to the latest version 1.13.3. The HDF5 library that is installed is compiled with the latest version of numpy, hence it might display error in mismatch with the version of numpy installed in your system (in my case it was 1.8.2). Usually you may see error as "ValueError: numpy.dtype has the wrong size, try recompiling. Expected 88, got 96", "RuntimeError: module compiled against API version 0xa but this version of numpy is 0x9"
$ sudo easy_install --upgrade numpy

Install the rospkg and catkin_pkg in anaconda. This is required for import rospy from anaconda python.
$ pip install rospkg catkin_pkg

Add the following lines to your .bashrc file
source /path/to/your/catkin-workspace/devel/setup.bash
export PATH=/home/user/anaconda2/bin:/home/user/anaconda2/lib/python2.7/site-packages:$PATH
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:/usr/local/lib/python2.7/dist-packages:/usr/lib/pymodules/python2.7/:$PYTHONPATH

Note:
  • The path :/usr/lib/pymodules/python2.7 is added to PYTHONPATH for joblib package
  • In case you get error "Unable to import Kinect2 sensor modules! Likely due to missing pylibfreenect2". Install libfreenect2 and pylibfreenect2 with instructions from https://github.com/OpenKinect/libfreenect2 http://r9y9.github.io/pylibfreenect2/stable/installation.html
6. Dexnet Command line interface dexnet_cli.py
The command line interface is a module that can be used for:
  • Creating a databse consisting of 3D object models, stable resting poses of 3D objects, parallel-jaw grasps, quasi-static grasp quality metrics, synthetic binary masks and depth images of 3D models.
  • Visualizing database contents 
Create HDF5 database from the part files downloaded from dexnet_2.0_training_database
$ cd /path/to/download/dexnetdatabase/
$ cat hdf5.dexnet_2_database_parta* > dexnet_2_database.hdf5

Go to dexnet source folder and execute the dexnet command line interface
$ cd /path/to/your/catkin/workspace/src/dex-net/
$ python apps/dexnet_cli.py

Select command to open a database. Give the path to dexnet_2_database.hdf5 manually. CLI supports tab completion.

 
After opening the database, select to open a dataset, and enter the dataset name you want to open.
Select command to display the grasps for an object from the dataset. Enter the robot name for which grasps has to be computed.
 Enter the object name and metric name for computing the grasps.
You should see a image of the selected object with the all possible antipodal grasps and the probability of successful grasps expressed with color coding. Green color specifies a higher and red color lower probability for a successful grasp.


Comments

Popular posts from this blog

Creating a URDF robot model from scratch for Cool1000 robotic manipulator