3 from apriltag_ros.msg
import AprilTagDetectionArray
4 from apriltag_ros.msg
import AprilTagDetection
5 from find_object_2d.msg
import ObjectsStamped
7 import geometry_msgs.msg
9 objFramePrefix_ =
"object" 13 global objFramePrefix_
15 if len(data.objects.data) > 0:
16 output = AprilTagDetectionArray()
17 output.header = data.header
18 for i
in range(0,len(data.objects.data),12):
20 objId = data.objects.data[i]
21 (trans,quat) = listener.lookupTransform(data.header.frame_id, objFramePrefix_+
'_'+str(int(objId)), data.header.stamp)
22 tag = AprilTagDetection()
24 tag.pose.pose.pose.position.x = trans[0]
25 tag.pose.pose.pose.position.y = trans[1]
26 tag.pose.pose.pose.position.z = trans[2]
27 tag.pose.pose.pose.orientation.x = quat[0]
28 tag.pose.pose.pose.orientation.y = quat[1]
29 tag.pose.pose.pose.orientation.z = quat[2]
30 tag.pose.pose.pose.orientation.w = quat[3]
31 tag.pose.header = output.header
32 if distanceMax_ <= 0.0
or trans[2] < distanceMax_:
33 output.detections.append(tag)
36 if len(output.detections) > 0:
39 if __name__ ==
'__main__':
40 pub = rospy.Publisher(
'tag_detections', AprilTagDetectionArray, queue_size=10)
41 rospy.init_node(
'objects_to_tags', anonymous=
True)
42 rospy.Subscriber(
"objectsStamped", ObjectsStamped, callback)
43 objFramePrefix_ = rospy.get_param(
'~object_prefix', objFramePrefix_)
44 distanceMax_ = rospy.get_param(
'~distance_max', distanceMax_)