Go to the documentation of this file.00001
00002 from object_manipulator.cluster_bounding_box_finder import ClusterBoundingBoxFinder
00003 from tabletop_object_detector.srv import TabletopDetection
00004 from tabletop_object_detector.msg import TabletopDetectionResult
00005
00006
00007
00008
00009 cbbf = ClusterBoundingBoxFinder()
00010 object_detector = rospy.ServiceProxy("/object_detection", TabletopDetection)
00011 detects = object_detector(True, False).detection
00012 object_detector.close()
00013 if detects.result != 4:
00014 err("Detection failed (err %d)" % (detects.result))
00015 table_z = detects.table.pose.pose.position.z
00016 objects = []
00017 for cluster in detects.clusters:
00018 (object_points,
00019 object_bounding_box_dims,
00020 object_bounding_box,
00021 object_to_base_link_frame,
00022 object_to_cluster_frame) = cbbf.find_object_frame_and_bounding_box(cluster)
00023
00024 (object_pos, object_quat) = cf.mat_to_pos_and_quat(object_to_cluster_frame)
00025 angs = euler_from_quaternion(object_quat)
00026 log("angs:", angs)
00027
00028 object_pos[2] = table_z + object_bounding_box[1][2] / 2. + DETECT_ERROR
00029 log("pos:", object_pos)
00030 log("table_z:", table_z)
00031 objects += [[object_pos, angs[2]]]