Import msg data python
Hi all, I use the Apriltags2_ros software, and the python coding. I got the software running, and I am able to detect the apriltag with id=0 with rostopic echo /tag_detections. Now I want to import the position's data in a python script, to be able to control my robot. What I have worked with some other apriltags software, though I had to switch to the new one due to changing circumstances. I had to change some things, but now it doesn't work anymore. Can somebody help me?
#!/usr/bin/env python
import rospy
from apriltags2_ros.msg import AprilTagDetection
class CameraPosition():
def __init__(self):
rospy.Subscriber("/tag_detections", AprilTagDetection, self.get_tags)
def get_tags(self, msg):
pos_x = msg.detections[0].pose.pose.position.x
print(pos_x)
if __name__ == "__main__":
CameraPosition()
rospy.spin()
sorry I had to do it this way; I want to do screenshots but I haven't got enough points yet. If I only get the x position I will figure the orientation and other positions out, I just need a bump in the right direction
rosmsg show apriltags2_ros/AprilTagDetection
int32[] id
float64[] size
geometry_msgs/PoseWithCovarianceStamped pose
std_msgs/Header header
uint32 seq
time stamp
string frame_id
geometry_msgs/PoseWithCovariance pose
geometry_msgs/Pose pose
geometry_msgs/Point position
float64 x
float64 y
float64 z
geometry_msgs/Quaternion orientation
float64 x
float64 y
float64 z
float64 w
float64[36] covariance