ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

The first thing to do is determine what is the message used in that topic, e.g:

$ rostopic info /robot/limb/left/endpoint_state
Type: baxter_core_msgs/EndpointState

Therefore, your function leftEndpointCallback should look like this:

void leftEndpointCallback(const baxter_core_msgs::EndpointStateConstPtr& _msg) 
{
  // The pose is within the _msg object
  ROS_INFO_STREAM("pose: " << _msg->pose);
  ROS_INFO_STREAM("pose.position.x: " << _msg->pose.position.x);
  ROS_INFO_STREAM("pose.position.y: " << _msg->pose.position.y);
  ROS_INFO_STREAM("pose.position.z: " << _msg->pose.position.z);
}

How to use these values somewhere else is scope of C/C++ callbacks. If you really need to process this data outside the callback you may consider implementing a Class. It seems that most people hate global variables (count me as well)