0
$\begingroup$

Rosanswers logo

I have several nodelets, each subscribes to different messages (using the single threaded node handle). However, I realized one of my nodes, which subscribes to images and to odometry messages, and which takes long to process a single image (and therefore looses odometry messages in the mean time). Another nodelet, also subscribed to odometry messages, receives all of them while the first nodelet is busy with an image. So I understand the image callback of the first nodelet is being serviced by a different thread than of the second nodelet. However, inside a single nodelet, it appears that servicing one callback blocks the other callback.

I really don't understand how does the nodelet manager uses threads to service callbacks both between nodelets and inside the same nodelet.

  • What would be the difference between using the single-threaded and multi-threaded node handles of the nodelet manager?
  • Does the nodelet manager have a single queue which receives all messages that nodelets subscribes to, and then uses the worker threads to service these? Or does each nodelet have a separate callback queue?
  • What I should I do if I only want to process two specific callbacks in parallel (after making them thread-safe) of a single nodelet, but still call any other callback (from this nodelet or others) serially?

Originally posted by Matias on ROS Answers with karma: 122 on 2014-06-03

Post score: 6


Original comments

Comment by McMurdo on 2014-07-18:
No answers yet? I have the same doubts.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The threading model is documented at: http://wiki.ros.org/nodelet#Threading_Model

It's built upon the standard ROS threading, documented at: http://wiki.ros.org/roscpp/Overview/Callbacks%20and%20Spinning

The multi-threaded node handle has the shared thread pool also shares a callback queue across all multi threaded node handles in the process.

The single threaded node handle has a custom callback queue with a single thread shared across all single threaded node handles in the process.

If you want very specific behavior I suggest setting up your own callback queues and threads within the nodelet.


Originally posted by tfoote with karma: 58457 on 2014-08-13

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by Matias on 2014-08-14:
So, any two callbacks associated to the MT handle could be executed in parallel, right? And will callbacks associated to the ST handle will also be run in parallel to MT handle callbacks? In other words, I have to ensure thread safety between any MT callback and any other callback (be it MT or ST).

Comment by tfoote on 2014-08-14:
That's correct.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.