Skip to content

Conversion with urdf2graspit

Jennifer Buehler edited this page Feb 22, 2016 · 15 revisions

GraspIt! requires a special xml format to read the robot files. GraspIt maintains an internal representation of the robot with the Denavit-Hartenberg parameters, to which you need to convert your URDF model. You can use the package urdf2graspit to convert your URDF to Denavit-Hartenberg and the the GraspIt! format.

Preparation: Get your URDF file

You will need to use a .urdf file, not a .xacro file. To convert xacro to URDF you can use:

rosrun xacro xacro --inorder <your-xacro-file>.xacro > <your-urdf-output-file>.urdf

or on Indigo or earlier:

rosrun xacro xacro.py <your-xacro-file>.xacro > <your-urdf-file>.urdf

Step 1: Start the converter

Run the conversion of your URDF file as follows:

rosrun urdf2graspit urdf2graspit_node `rospack find <YOUR_ROBOT>_description`/urdf/<YOUR_ROBOT>.urdf <DESTINATION_FOLDER> <WRIST_LINK_NAME> <FINGER_JOINT_NAME1> <FINGER_JOINT_NAME2> ...

There is also an example launch file to run the conversion on the Jaco robot:

roslaunch urdf2graspit example_urdf2graspit_jaco.launch output_directory:=<your-output-directory>

You may inspect this launch file and adapt it for your robot.

Step 3: Choose your contact points in the viewer

The viewer will open in which you can see your converted hand model. Click on the mouse pointer (small arrow) on the right-hand pane to enable the contact point selection. You can now select the contact points on the hand by clicking once on the hand surface where you want points to be added. If you want to move the hand again, you have to click on the hand symbol again to enable the scene rotation mode. You may also want to click on the eye symbol (right-hand pane) first, to switch into object-centered camera mode.

Make sure you select good contact points on the fingers. You don't necessarily need many, usually around 3-6 contacts per finger yield good results, depending on the hand. There should be a few on each finger and some on the palm as well.

When you are finshed, close the window, and the GraspIt! files will be generated.

Step 3: Inspect the results

The folder DESTINATION_FOLDER will contain the following files and folders:

  • models/robots/YOUR_ROBOT
    • eigen: contains eigen.xml
    • iv: contains all inventor geometry folders
    • YOUR_ROBOT.xml
    • virtual: contains contacts.vgr
  • worlds:
    • YOUR_ROBOT_world.xml

Before you can load your robot into the GraspIt! simulator GUI for inspection, you will also need to link the YOUR_ROBOT folder in the $GRASPIT/models/robots folder:

cd $GRASPIT/models/robots
ls -s <path-to-YOUR_ROBOT-folder>

If you have any objects, you should do the same for each of the object files:

cd $GRASPIT/models/objects
ls -s <path-to-your-object-xml>
ls -s <path-to-your-object-iv>

The default world file which is created by urdf2graspit loads a cube (default object in the graspit package) and the hand. To inspect the hand, you can open your world file (YOUR_ROBOT_world.xml) from the GraspIt simulator. You can start the simulator with

rosrun graspit graspit_simulator

You can now perform grasp planning for your hand using the simulator. Please refer to the instructions in the graspit package.

Note: The contact points generated by urdf2graspit may still need to be improved, I haven't had the time to inspect how they can be defined better. So the grasp planning results may not be optimal. See also notes about the contact points below.

Info: The order of the joints in the GraspIt XML robot file are according to a depth-first search in the URDF tree.

Example set-up summary: Jaco hand

Use the following command to test the converter on the Jaco hand.

rosrun urdf2graspit urdf2graspit_node `rospack find jaco_description`/urdf/jaco_robot.urdf `pwd`/jaco_graspit 6_hand_limb finger_joint_0 finger_joint_2 finger_joint_4

or using roslaunch:

roslaunch urdf2graspit example_urdf2graspit_jaco.launch output_directory:=<your-output-directory>

Note: The mesh does not perfectly fit at the base of the fingers. This is because adaptations had to be made to the model in order to more closely reflect the real robot. This should be updated some time.

You will need to create the softlinks in your $GRASPIT folder as described above. You should do this for:

  • the jaco_robot folder (softlink the whole folder into the $GRASPIT/models/robots directory).
  • all the objects .xml and .iv files which you refer to within the .world files which you want to load (softlink the files into the $GRASPIT/models/objects directory).