Ask Your Question
0

Spin problem in ur_10 class

asked 2018-02-13 17:28:03 -0500

Dalde gravatar image

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-02-14 01:53:01 -0500

gvdhoorn gravatar image

How can I resolve it?

Don't call ros::spin() in your constructor.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2018-02-13 17:28:03 -0500

Seen: 24 times

Last updated: Feb 14 '18