Ask Your Question

How to get pose from april tag topic tag_detection?

asked 2020-02-14 10:51:53 -0600

dj95 gravatar image

updated 2022-01-22 16:10:20 -0600

Evgeny gravatar image

Hi, Currently, I have a bag file which publishes the /tag_detections coming from apriltag node. I'm having trouble in writing a callback function which could extract information like pose from the topic.

The details of the topic are:

rosmsg show apriltag_ros/AprilTagDetectionArray

std_msgs/Header header
  uint32 seq
  time stamp
  string frame_id
apriltag_ros/AprilTagDetection[] detections
  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

The piece of code that I manage to write till now is:

#include "ros/ros.h"
#include "apriltag_ros/AprilTagDetectionArray.h"

void callback(const apriltag_ros::AprilTagDetectionArray::ConstPtr &msg)
    //What to do?

int main(int argc, char **argv)
    ros::init(argc, argv, "apriltag_location");
    ros::NodeHandle n;
    ros::Subscriber sub = n.subscribe("tag_detections",1000,callback);


Could someone point out on how to get the pose from here?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-02-14 12:16:54 -0600

The pose is the msg->detections[i].pose of type geometry_msgs/PoseWithCovariance for all N detections.

edit flag offensive delete link more


Could you explain what 'i' here would be?

geometry_msgs::PoseWithCovariance x;
x = msg->detections[0].pose.pose;

Writing like gives me a message 'Segmentation fault (core dumped)'

dj95 gravatar image dj95  ( 2020-02-14 13:05:20 -0600 )edit

I think your issue here is not really understanding C++ rather than a ROS-specific issue. I'd recommend going through some C++ STL tutorials and then coming back to revisit to this.

stevemacenski gravatar image stevemacenski  ( 2020-02-14 14:10:53 -0600 )edit

That is true, thanks for the input.

dj95 gravatar image dj95  ( 2020-02-14 15:38:12 -0600 )edit

If I've answered your question, can you hit the checkmark so its removed from our unanswered questions queue?

stevemacenski gravatar image stevemacenski  ( 2020-02-14 16:48:23 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2020-02-14 10:51:53 -0600

Seen: 692 times

Last updated: Feb 14 '20