Problem using subscribed motor position topic
Hi, I am new to ROS and I am trying to get access to my servo motor position to use in broadcasting a transform. I have done the listener tutorial and my listen program below runs and compiles fine, it even triggers the void function when the motor publishes a position topic. How can I get pull the position variable that I am subscribed to in order to use it in a program? Specifically what do I need to change "sg->data.c_str()" to in order for it to say the motor position integer in the message?
======================listener.cpp==============
#include "ros/ros.h"
#include "ax12_driver_core/MotorStateList.h"
void motorchatterCallback(const ax12_driver_core::MotorStateList::ConstPtr&)
{
// ROS_INFO("I heard: [%s]", msg->data.c_str());
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "listener");
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("motor_states/ttyUSB0", 1000, motorchatterCallback);
ros::spin();
return 0;
}