I am using the ar_track_alvar package in Indigo to detect AR Tags and determine their respective poses. I am able to run the tracker successfully as I can visualize the markers in RViz. I give the following command to print the pose values
rostopic echo /ar_pose_marker
and I get the following output indicating that the poses are determined.
header: seq: 0 stamp: secs: 1444430928 nsecs: 28760322 frame_id: /head_camera id: 3 confidence: 0 pose: header: seq: 0 stamp: secs: 0 nsecs: 0 frame_id: '' pose: position: x: 0.196624979223 y: -0.238047436646 z: 1.16247606451 orientation: x: 0.970435431848 y: 0.00196992162831 z: -0.126455066154 w: -0.205573121457
Now I want to use these poses in another ROS node and hence I need to subscribe to the appropriate ROS message('ar_pose_marker"). But I am unable to get enough information on the web on the header files and functions to use in order to extract data from the published message. It would be great if somebody can point to a reference implementation or documentation on handling these messages. It might be useful to note that ar_track_alvar is just a ROS wrapper and hence people who have used ALVAR outside of ROSmay also give their inputs.
UPDATE:
I tried to write code for the above task as suggested by @Ben in the comments but I get an error. The code is as follows
#include <ros/ros.h>
#include <ar_track_alvar_msgs/AlvarMarker.h>
#include <tf/tf.h>
#include <tf/transform_datatypes.h>
void printPose(const ar_track_alvar_msgs::AlvarMarker::ConstPtr& msg)
{
tf::Pose marker_pose_in_camera_;
marker_pose_in_camera_.setOrigin(tf::Vector3(msg.pose.pose.position.x,
msg.pose.pose.position.y,
msg.pose.pose.position.z));
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "pose_subscriber");
ros::NodeHandle nh;
ros::Subscriber pose_sub = nh.subscribe("ar_pose_marker", 1000, printPose);
ros::spin();
return 0;
}
And I get the following error
/home/karthik/ws_ros/src/auto_land/src/pose_subscriber.cpp: In function ‘void printPose(const ConstPtr&)’:
/home/karthik/ws_ros/src/auto_land/src/pose_subscriber.cpp:17:53: error: ‘const ConstPtr’ has no member named ‘pose’
marker_pose_in_camera_.setOrigin(tf::Vector3(msg.pose.pose));
^
make[2]: *** [auto_land/CMakeFiles/pose_subscriber.dir/src/pose_subscriber.cpp.o] Error 1
make[1]: *** [auto_land/CMakeFiles/pose_subscriber.dir/all] Error 2
make: *** [all] Error 2
Any suggestions?