How to poke multiple node from a node in ROS?

357 views Asked by At

I have a node for common issues and there is a parameter in this node. When this parameter change, how can it poke the other nodes to be aware?

For example: I have a service to stop the robot. When I call this service, the other nodes should be aware because of some issues, e.g. waiting, putting in order, cancel plan.

Firstly, I tried to create services with same names in nodes, but it doesn't work. Only, the last run service works. Then, I tried to use parameter service. At this time, the other nodes should always listen parameter service and check it. I don't want to use this method for performs issues. Lastly, I tried to use dynamic reconfiguration. Unfortunately, the dynamic reconfiguration is related only for a specific node.

I have another opinion for this situation, which is Signal & Slot mechanism. But, I don't want to use QT or any other 3rd party framework.

I know, I am so delicate :) I would like to learn your approaches. Is there any light way?

Thank you!

1

There are 1 answers

0
JWCS On

I'm gonna throw it out there that, for most information-communication things in ros, messages and callbacks are the way to go, 95% of the time. After that, actions have more valid use cases / better integration than services; and the dynamic reconfig is a horrible option usually from bad design.

The ros parameter server only gets the parameter when you request it in the node, so if you change the value in the parameter server, it doesn't by default grab the new value. The parameter server is best used in launch files, for changing the runtime conditions before execution, but without forcing a recompile.

The simplest and clearest solution is to use a topic for sending any changes, and a callback within all the other nodes for this. This event-driven callback system is exactly what you're requesting: when an event happens, do something; this is what ros is designed around.

If this is code duplication, you can pull out the redundant callbacks / code into a separate file to include/import. If you find yourself having multiple values that change at the same time, you could make your own message (type) to send the values bundled, or you can use multiple topics.