Read variable from PoseStamped C++
Hello,
I am having some issues with reading a variable from the message PoseStamped. I can call the callback function and when I write something to read out the message I get the following error.
'const_pose_type' has no member named 'pose'
x_current = msg->pose.pose.position.x;
I get the message from another computer which is connected with an UTP cable as a slave to my computer which is the master. In the terminal I can echo the message and see that it is sending coordinates. The code that is running is as following.
#include "ros/ros.h"
#include <sstream>
#include "geometry_msgs/PoseStamped.h"
#include <vector>
std::vector<geometry_msgs::PoseStamped::ConstPtr> pose;
double x_current = 0;
void tf_callback(const geometry_msgs::PoseStamped::ConstPtr& msg) {
ROS_INFO_STREAM("Received pose: " << msg);
x_current = msg->pose.pose.position.x;
ROS_INFO_STREAM(x_current);
pose.push_back(msg);
}
int main(int argc, char **argv) {
ros::init(argc, argv, "subscriberTF");
ros::NodeHandle nh;
ros::Subscriber subscribetf = nh.subscribe("/visp_auto_tracker1/object_position", 1000, tf_callback);
ros::spin();
return(0);
}
Could someone please have a look at my code to see what I do wrong so that I can import the variables from the function the proper way. I want to publish the coordinates to the tf afterwards.
Thank you.