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

Recursively calling spinOnce() can be dangerous. You might end up calling your TimerCallback() recursively, particularly with the timer's duration being so short.

As an alternative to recursively calling spinOnce(), you could try using a separate callback queue for the timer. See here for how this works:

http://wiki.ros.org/roscpp/Overview/Callbacks%20and%20Spinning#Advanced:_Using_Different_Callback_Queues

If you want to ignore all data received on other topics until a particular message is received, there might be better ways to do it. For example removing subscribers (sub.shutdown()) and re-creating them when ready to handle data again - although this is costly in destroying and setting up connections. Another would be a flag that tells other subscriber callbacks to ignore all received data until that particular message is received.