ROS_INFO error in the subscriber package [closed]
Hello,
I am trying to build a subscriber package to listen to tf_static
. Here is the subscriber code:
//#include <iostream>
#include "ros/ros.h"
//#include "std_msgs/String.h"
#include "tf2_msgs/TFMessage.h"
#include "geometry_msgs/TransformStamped.h"
#include "geometry_msgs/Transform.h"
#include "geometry_msgs/Vector3.h"
//using namespace std;
void tfCallback(const tf2_msgs::TFMessage::ConstPtr& msg)
{
ROS_INFO("I heard: [%f]", msg->transforms.transform.translation.x);
}
int main(int argc, char **argv)
{
//cout << "Hello world!" << endl;
ros::init(argc, argv, "tf_subscriber_node");
ros::NodeHandle ntf;
ros::Subscriber sub = ntf.subscribe("/tf_static",1000, tfCallback);
ros::spin ();
return 0;
}
I am receiving the following error:
src/tf_subscriber_node.cpp:13:47: error: 'const _transforms_type' has no member named 'transform' ROS_INFO("I heard: [%f]", msg->transforms.transform.translation.x);
I believe the error could be due to the const
keyword. Or am I doing anything wrong in the part:
msg->transforms.transform.translation.x
Can anyone kindly guide on how to fix this?