ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
ros::spinOnce
(and by extension ros::spin()
) is single threaded by default. Your callbacks are handled one by one when ros::spinOnce
is called so if your callback takes 3 seconds, ros::spinOnce
will be stuck for 3 seconds before proceeding (which also means it other callbacks cannot run). You can use the MultiThreadedSpinner
or AsyncSpinner
if you want to avoid that, but that obviously means you'll have to do proper thread synchronization in your callbacks. You may also want to tune your subscriber queue size if your data is arriving faster than your callbacks can process.
More information: http://wiki.ros.org/roscpp/Overview/Callbacks%20and%20Spinning
2 | No.2 Revision |
ros::spinOnce
(and by extension ros::spin()
) is single threaded by default. Your callbacks are handled one by one when ros::spinOnce
is called so if your callback takes 3 seconds, ros::spinOnce
will be stuck for 3 seconds before proceeding (which also means it other callbacks cannot run). You can use the MultiThreadedSpinner
or AsyncSpinner
if you want to avoid that, but that obviously means you'll have to do proper thread synchronization in your callbacks. You may also want to tune your subscriber queue size if your data is arriving faster than your callbacks can process.
More information: http://wiki.ros.org/roscpp/Overview/Callbacks%20and%20Spinning
There are also many questions here and on stackoverflow regarding ROS's AsyncSpinner
that you can search for.