Spin problem in ur_10 class
Hi, I have a class position.cpp
where I manipulate my robot ur_10 and in this class I must to launch
spinner.start()
In this class I would to subscribe to a topic, and for doing this and I wrote this class:
class ListMsg {
private:
ros::Subscriber sub;
ros::NodeHandle n;
public:
ListMsg(){
ros::Subscriber sub = n.subscribe ("chatter", 500, &Subscribe_And_Publish::callback, this);
ros::spin();
}
void callback(const std_msgs::String::ConstPtr& msg)
{
ROS_INFO("I heard: [%s]", msg->data.c_str());
}
};
From my position.cpp
I call this class in this way:
ListMsg listMsg1;
The problem is that my class doesn't print any information. How can I resolve it?
Thank you all.