grasp_segment.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #This node listens to pointclouds (from handle-extractor), requesting grasp plans for each
00003 import roslib; #roslib.load_manifest('handle')
00004 import sys
00005 roslib.load_manifest('pr2_gripper_grasp_planner_cluster')
00006 import rospy
00007 from object_manipulation_msgs.srv import GraspPlanning, GraspPlanningResponse
00008 from object_manipulation_msgs.msg import GraspableObject
00009 from sensor_msgs.msg import PointCloud
00010 
00011 a = 9
00012 
00013 def service_caller(pc):
00014     rospy.wait_for_service('plan_point_cluster_grasp')
00015     try:
00016         myproxy = rospy.ServiceProxy('plan_point_cluster_grasp', GraspPlanning)
00017         go = GraspableObject()
00018         go.cluster = pc
00019         go.reference_frame_id = "/base_link"
00020         rospy.loginfo(rospy.get_name()+"I used a pointcloud with %d points as cluster",len(go.cluster.points))
00021 
00022         myresponse = myproxy(target=go)
00023         rospy.loginfo(rospy.get_name()+"I got a %d grasps",len(myresponse.grasps))
00024         print myresponse
00025         #for i, g in enumerate(myresponse.grasps):
00026         #    rospy.loginfo(rospy.get_name()+"grasp %d has success probability %f",i,g.success_probability)
00027         #    print
00028 
00029         return myresponse
00030     except rospy.ServiceException, e:
00031         print "Service call failed: %s"%e
00032 
00033 def callback(pc):
00034     global a
00035     rospy.loginfo(rospy.get_name()+"Received a pointcloud with %d points",len(pc.points))
00036     if len(pc.points) > 10:
00037       a = service_caller(pc)
00038     rospy.signal_shutdown("done")
00039 
00040 
00041 if __name__ == '__main__':
00042     rospy.init_node('grasper')
00043     rospy.loginfo(rospy.get_name()+" subscribing to pointclouds, requesting grasp plans for each one received")
00044     rospy.Subscriber("/handle_segment", PointCloud, callback)
00045     rospy.loginfo(rospy.get_name()+" ready")
00046     rospy.spin()
00047 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


door_manipulation_tools
Author(s): Felix Endres
autogenerated on Wed Dec 26 2012 16:02:19