First time here? Check out the FAQ!


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

how are threads used to service callbacks in nodelets? [closed]

asked Jun 3 '14

Matias gravatar image

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?
Preview: (hide)

Closed for the following reason the question is answered, right answer was accepted by Matias
close date 2015-06-26 17:22:25.330580

Comments

No answers yet? I have the same doubts.

McMurdo gravatar image McMurdo  ( Jul 18 '14 )edit

2 Answers

Sort by » oldest newest most voted
3

answered Aug 13 '14

tfoote gravatar image

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

It's built upon the standard ROS threading, documented at: http://wiki.ros.org/roscpp/Overview/C...

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.

Preview: (hide)

Comments

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).

Matias gravatar image Matias  ( Aug 14 '14 )edit

That's correct.

tfoote gravatar image tfoote  ( Aug 14 '14 )edit
0

answered Aug 13 '14

esteve gravatar image

In your case, you could either:

Both approaches are fine, though with the first one you will be responsible for managing the thread you spawn, whereas with the second one it's all handled by the nodelet manager threadpool

Preview: (hide)

Comments

I understand the options but not what is the impact of using the MT handle. Please see my questions in the items above.

Matias gravatar image Matias  ( Aug 13 '14 )edit

Question Tools

Stats

Asked: Jun 3 '14

Seen: 6,571 times

Last updated: Aug 13 '14