0
$\begingroup$

I'm interested in writing a node which subscribes to some topics and does stuff, as part of this node a service will be offered that dictates how the node interacts with some other topics.

Basically, I need the service offered to wait to return until the node that's offering the service processes some message that arrives after the service call.

Do ROS2 services nodes block subscriber callbacks on the node processing the request?

$\endgroup$

1 Answer 1

1
$\begingroup$

Yes, by default callbacks are blocking. Read up on executors and callback groups for more info. Using a multithreaded executor might be a solution. See this previous answer for references.

$\endgroup$
2
  • $\begingroup$ Thanks, it doesn't look like async is part of ROS2(odd) but multi-threaded executor will work. I'm also going to need to use a flag in global memory of the node to indicate if the change has been processed. Honestly the ROS2 documentation doesn't really do a good job describing how to deal with nodes which have multiple threads running or in general issues associated with synchronization. I read all the concepts documentation but my basic issue is what is really happening in the lower level communication layers, ex are multiple threads spawned anyway, one thread handling DDS? $\endgroup$ Commented May 27 at 20:17
  • $\begingroup$ Wrt. the documentation: true. As long as nobody takes action to write it, it doesn't happen. Wrt. the threads of the RMW layer: yes, threads are spawn for this, but I don't know the details of it. If you want to know more, I suggest to ask this as a separate Robotics Stack Exchange question. $\endgroup$
    – JRTG
    Commented May 28 at 10:51

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.