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

Revision history [back]

click to hide/show revision 1
initial version

The tutorial (this one probably?) doesn't put an infinite while in a constructor, nor in a callback. Callbacks should be short, deal with the msg. Not run an eventloop of their own. You're also running an eventloop ..

The tutorial (this one probably?) doesn't put an infinite while in a constructor, nor in a callback. Callbacks should be short, deal with the msg. Not run an eventloop of their own. own.

You're also running an eventloop ..(while (ros::ok()) { ros::spinOnce() }) inside another eventloop (ros::spin() in your callback). You want to study carefully what the tutorial does. Note where ros::spin() is called.

If you want to use a class, instantiate it in a main and run your eventloop in the main.