22 import cob_grasp_generation.msg
23 from cob_grasp_generation
import grasp_query_utils
30 self._as_query.start()
32 print(
"QueryGraspsServer: action started...")
38 rospy.loginfo(
'Querying grasps for object %s using gripper_type %s' % (goal.object_name, goal.gripper_type))
40 if grasp_query_utils.check_database(goal.object_name, goal.gripper_type):
41 rospy.loginfo(
'GraspTable for object %s exist in the database.', goal.object_name)
42 rospy.loginfo(
'Returning grasp list for selected object.')
43 grasp_list = grasp_query_utils.get_grasps(goal.object_name, goal.gripper_type, goal.gripper_side, goal.grasp_id, goal.num_grasps, goal.threshold)
45 rospy.logwarn(
'GraspTable for object %s does not exist!',goal.object_name)
47 if not (grasp_list == []):
50 result = cob_grasp_generation.msg.QueryGraspsResult()
51 result.success = success
52 result.grasp_list = grasp_list
55 rospy.loginfo(
'Query: Succeeded')
56 self._as_query.set_succeeded(result)
58 rospy.logwarn(
'Query: Failed')
59 self._as_query.set_aborted(result)
61 if __name__ ==
'__main__':
62 rospy.init_node(
'query_grasps_server')