# GraspIt plugin dbase_grasp_planner computing grasp in database throws error about get_mark_next_dbase_task_of_type

(My goal: I am trying to add new objects to a local copy of the household_objects_database, and compute grasps for them, so that I can test grasps using tabletop_detection and pr2_pick_and_place for some of our own object models. I have done the former - adding object models, but the latter - computing grasps - is giving me problems.)

What I have done so far: I installed a local copy of household_objects_database in a PostgreSQL localhost database, and I added some of our own object models successfully to the database, using insert_model.cpp from household_objects_database, changing the database connection line from wgs36 to localhost.

What I need: Now I would like to compute the grasps for the new objects I added - because seems like the grasps are not automatically computed when the object models are added to the database (Is that correct? Because in the pgadmin3 GUI, I see our new models in original_model and scaled_model tables, but I don't see any grasps for these new scaled_model_ids in the "grasp" table.)

Where I'm stuck:

To compute grasps using the GraspIt plugin in dbase_grasp_planner, I am running this file with some modifications

$roslaunch graspit_ros_planning ros_graspit_interface.launch  which I got to run following two other ROS Answers pages. (I also changed the IP to localhost in dbTaskDispatcher.cpp, and recompiled my copies of graspit_dbase_tasks and dbase_grasp_planner to generate new libgraspit_dbase_tasks.so and libdbase_grasp_planner.so files, the latter is needed by the launch file.) What all that does is that now the launch file starts the GraspIt plugin, connects to the localhost database successfully. However, GraspIt now throws this error: Processing arguments Function name dbase_grasp_planning plugin creator autostart 1 [ INFO] [1368320844.809613707]: Function call: get_mark_next_dbase_task_of_type(ARRAY['GRASP_PLANNING','GUIDED_GRASP_PLANNING','VELO_GRASP_PLANNING','GRASP_CLUSTERING']) [ERROR] [1368320844.922216835]: Database get list: query failed. Error: ERROR: function get_mark_next_dbase_task_of_type(text[]) does not exist LINE 1: SELECT get_mark_next_dbase_task_of_type FROM get_mark_next_... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. [ERROR] [1368320844.922357154]: Failed to get the id of the next task of given type to be run [ERROR] [1368320844.922438910]: Function call: get_mark_next_dbase_task_of_type(ARRAY['GRASP_PLANNING','GUIDED_GRASP_PLANNING','VELO_GRASP_PLANNING','GRASP_CLUSTERING']) Dispatcher: error reading next task deleting IVmgr QThreadStorage: Thread 0xaac540 exited after QThreadStorage 7 destroyed  I searched for get_mark_next_dbase_task_of_type many times, and all that comes up is the source code from household_objects_database/database_task.h. Seems like it's looking for a function called get_mark_next_dbase_task_of_type in the database, but the database only has 4 Functions, compute_grasp_robustness, get_grasps, get_models, update_grasps, none of them are that. I see what it's looking for. Tables dbase_task, dbase_task_type, task_outcome all have relevant stuff. It's trying to get the columns from dbase_task that say TO_RUN, set them to RUNNING, and runs them; when it finishes a task, it sets it to COMPLETED. But I don't know how to give them to it. So I am reaching a conjecture that I have to create entries in the table that say TO_RUN, create that get_mark_next_dbase_task_of_type() SQL function in the database, and then ... edit retag close merge delete ## Comments The "get_mark..." function does need to be in the database, and it should be in the latest version... Which version of the database did you download? Then, generating grasps is indeed not documented - I will try to add a short tutorial on the wiki. ( 2013-05-14 10:02:45 -0600 )edit (Thank you SO much for the response, Matei! I was about to email you just now.) Hmm I downloaded the household_objects-0.6_fuerte_prerelease_1.backup, is that not the latest version? Is the SQL function accessible somewhere in a repo that I can just copy-paste it into my function? ( 2013-05-14 10:18:48 -0600 )edit We found that in a previous version of the .backup file, the 0.5_electric one, there were functions get_mark_next_dbase_task(), get_mark_next_task(), and save_grasp(), which are not in the 0.6_fuerte.backup file. Still, there is no get_mark_next_dbase_task_of_type() though. ( 2013-05-17 11:23:28 -0600 )edit Does anyone know if the mentioned "generating grasps tutorial" ever got created? ( 2014-08-11 16:25:02 -0600 )edit ## 1 Answer Sort by » oldest newest most voted Solution: I wrote my own get_mark_next_dbase_task_of_type(), which worked and added grasps to the database successfully for GRASP_PLANNING and GRASP_CLUSTERING tasks. I did not test it with the other two types (GUIDED_GRASP_PLANNING, VELO_GRASP_PLANNING). It is written based on the get_mark_next_dbase_task() from the 0.5_electric.backup file. -- Function: get_mark_next_dbase_task_of_type(text[]) -- DROP FUNCTION get_mark_next_dbase_task_of_type(text[]); CREATE OR REPLACE FUNCTION get_mark_next_dbase_task_of_type(IN dbasetasktype text[]) RETURNS integer AS$BODY$DECLARE next_id INTEGER; BEGIN SELECT dbase_task_id INTO next_id FROM dbase_task WHERE dbase_task_type = ANY ($1)
LIMIT 1 FOR UPDATE;
return next_id;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
OWNER TO willow;


Another thing I had to do before the grasps would calculate correctly was to rescale our model to be much smaller. Rule of thumb is that both the object and the arm you're using should show up in GraspIt. Manually running GraspIt Eigengrasp Planner to see what's supposed to happen helps ( www.cs.columbia.edu/~cmatei/graspit/html-manual/graspit-manual_12.html#id5 ). The ROS GraspIt plugin uses the Eigengrasp Planner with Search Space Complete and simulated annealing to output the [tx ty tz qw qx qy qz].

more