Accessing translation data from geometry_msgs::TransformStamped
I want to access the x, y, z values and quaternion values in a geometry_msgs/TransformStamped.msg , so my subsrciber looks like:
#include "ros/ros.h"
#include <geometry_msgs/TransformStamped.h>
void geoCallback(const geometry_msgs::TransformStampedConstPtr& pose){
ROS_INFO(pose->transform.translation.x);
}
int main(int argc, char **argv){
ros::init(argc, argv, "tf_subscriber_node");
ros::NodeHandle nh;
ros::Subscriber sub = nh.subscribe("/tf_static",1000, geoCallback);
ros::spin ();
return 0;
}
So while printing float64 x
using ROS_INFO
, I am getting error during compilation like error in printing const _x_type&
, in particular error looks like:
/opt/ros/kinetic/include/ros/console.h:346:176: error: no matching function for call to _print(int, void*&, ros::console::Level&, const char [58], int, const char [50], const _x_type&)
So why it is saying _x_type&
, instead of float64
for x
? And how could I access the x, y and z value properly?
And this is my included header file geometry_msgs/TransformStamped.h