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

Revision history [back]

For single-threaded nodes:

If you have an infinite loop of your own that does some processing, use spinOnce() somewhere in the loop. This allows ROS to process the callbacks for queued messages - if you don't include it, your messages will never be called and none of your messages will be published.

If all your calculations are performed in callbacks and you don't need an infinite loop for your custom processing, just use spin() which continuously pumps for callbacks.

For single-threaded nodes:

If you have an infinite loop of your own that does some processing, use spinOnce() somewhere in the loop. This allows ROS to process the callbacks for queued messages - if you don't include it, your messages callbacks will never be called and none of your messages will be published.

If all your calculations are performed in callbacks and you don't need an infinite loop for your custom processing, just use spin() which continuously pumps for callbacks.