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

Spin problem in ur_10 class

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

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 {
    ros::Subscriber sub;
    ros::NodeHandle n;
  ros::Subscriber sub = n.subscribe ("chatter", 500, &Subscribe_And_Publish::callback, this);

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

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

gvdhoorn gravatar image

How can I resolve it?

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

edit flag offensive delete link more

Question Tools


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

Seen: 67 times

Last updated: Feb 14 '18