0
$\begingroup$

Rosanswers logo

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.


Originally posted by Lauran on ROS Answers with karma: 19 on 2018-01-30

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

This is straightforward: You have one pose too much.

Check the docu of the message: http://docs.ros.org/api/geometry_msgs/html/msg/PoseStamped.html So, correct would be: msg->pose.position.x.


Originally posted by mgruhler with karma: 12390 on 2018-01-30

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by Lauran on 2018-01-30:
Thank you. I just managed to find that as well :)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.