Skip to content

GraspIt API ROS Wrapper

Jennifer Buehler edited this page Feb 28, 2019 · 8 revisions

The package grasp_planning_graspit_ros is a ROS Wrapper for the C++ API in grasp_planning_graspit.

The ROS services provided by the package are described in more detail on this wiki page.

This tutorial describes how to use the individual services to build a GraspIt database and then run the planning on models in it.

For this tutorial you are going to be using the example graspit files for the Kinova Jaco hand. You can find them in the directory jaco_graspit_sample.

Prerequisites: You whould have completed the introductory Eigengrasp planning tutorial.

Use individual services to build a GraspIt! database and run the planner.

Instead of running the planner directly as in the introductory Eigengrasp planning tutorial, you can also use the database and add several robots and objects to it. Then, you can pick which robots and objects you want to load into the GraspIt! world to do the planning.

This provides a bit more flexibility, and several nodes may request to plan on different robots and objects. However, at the current time, the service can only plan on one robot and one object at the same time, so other requests would be on hold until the earlier request is finished.

Step 1

Launch the services with

roslaunch grasp_planning_graspit_ros grasp_planning_service.launch \
    results_output_directory:=<your-results-directory>

Make sure you leave this terminal open in the background while completing the rest of this tutorial. For the next commands, use a separate terminal.

Step 2

Now load models into the graspit database. Make sure you have the graspit server launched in step 1 still running in another terminal.

roslaunch grasp_planning_graspit_ros graspit_add_robot_example.launch

The output should show an int ID which has been assigned to the robot. This should be 1 for the first model loaded. You will need this ID whenever you want to plan with that robot. It is possible to load several robots to the database and plan with any of them.

Step 3

Similar to step 2, also load the examle cube into the database:

roslaunch grasp_planning_graspit_ros graspit_add_object_example.launch

Again, you should see an int ID for the loaded object which you can use to refer to this object later.

Step 4

The database now contains the robot and the object. You still need to load them into the GraspIt! world before you can plan with them. The following assumes that your robot got ID=1 and the object ID=2. If that is different, adjust the values in the launch file before running:

roslaunch grasp_planning_graspit_ros graspit_load_models_example.launch

This should only print a few status messages that the robot and object have been loaded.

At any time, you may save the currently loaded GraspIt! world with the following command:

rosrun grasp_planning_graspit_ros save_world_client <destination-path-to-file>.iv true

The last argument determines whether to save as Inventor or GraspIt! file. You can inspect this file just like the results (see description below).

Step 5

Now you can run the EigenGrasp planner on the loaded world.

The following assumes that the robot name is "jaco_robot" (set by the launch file in step 2) and the ID of your object was 2 (should have resulted from launch file in step 3).

Background info: Why the mix of name and ID?
Because the manipulation_msgs/GraspPlanning.srv message is used, which refers to objects with an ID and to robots with names, we have to refer to the robot and object accordingly. UPDATE: See also issue #41: this will be changed as soon as issue #32 is fully completed.

Start the planning process with:

roslaunch grasp_planning_graspit_ros graspit_eigengrasp_planner_client_example.launch

The planner output can now be seen in the other terminal where you launched the graspit ROS services.

The client will exit when the planning process is finished, which can take a while. When the planner is finished, you can find the graspit world files and the inventor files in <your-results-directory>.

Inspect the results

You may inspect the inventor files:

rosrun urdf_viewer urdf_viewer_node <path-to-iv-file> --iv

or open the graspit simulator which you can use to open the world file:

graspit_simulator

When using graspit_simulator, you will have to set the GRASPIT variable to empty in the current terminal, because absolute paths are still used in the generated files.

Where to next?

Now you should be familiar with the GraspIt! Eigengrasp planner and are ready to try out the C++ interface to control the planner yourself. This tutorial will guide you through a simple example.