0
$\begingroup$

Rosanswers logo

Let's suppose I have nodes A, B and C on a MultiThreadExecutor with two threads.

Then suppose that the Event Queue has the following events: Node A Callback1 | Node A Callback1 | Node B Callback 2

From what I understand:

  1. The first thread takes the Node A Callback1.
  2. Then the second thread takes the next Node A Callback1.

This will mean that callbacks on the same Node should be thread safe when using MultiThreadExecutor, is that true? Is there a way to guarantee that the callbacks of the same node are executed sequentially or that each node has its own thread?

Thank you


Originally posted by Teckel on ROS Answers with karma: 103 on 2019-02-23

Post score: 2

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

This will mean that callbacks on the same Node should be thread safe when using MultiThreadExecutor, is that true?

Your understanding is correct.

Is there a way to guarantee that the callbacks of the same node are executed sequentially or that each node has its own thread?

This is what callback groups are for. Adding a node to a MutuallyExclusiveCallbackGroup (rclpy) (MutuallyExclusive callback type (rclcpp)), will ensure that its callbacks are executed sequentially.


Originally posted by jacobperron with karma: 1870 on 2019-03-04

This answer was ACCEPTED on the original site

Post score: 5


Original comments

Comment by Teckel on 2019-03-04:
Thank you. You have pointed me in the right direction. Now I am sure that I should correct some mistakes on my project.

$\endgroup$

Your Answer

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