Ask Your Question
0

How to get pose from april tag topic tag_detection?

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

dj95 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);
    ros::spin();

}

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
0

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

Comments

Could you explain what 'i' here would be?

geometry_msgs::PoseWithCovariance x;
x = msg->detections[0].pose.pose;
ROS_INFO("[%f]",x.pose.position.x);

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

dj95 gravatar imagedj95 ( 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 imagestevemacenski ( 2020-02-14 14:10:53 -0600 )edit

That is true, thanks for the input.

dj95 gravatar imagedj95 ( 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 imagestevemacenski ( 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

Stats

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

Seen: 9 times

Last updated: 2 days ago