ROS2 One-To-Many service servers with one client
Surprisingly I did not find a question for ROS2 to this. So here we go:
Use case: I want to refactor the emergency stop functionality in our setup.
Currently each node has a "~/emergency" trigger service expanding to e.g. "my_node/emergency". This implies that the caller node will need to have an instance per node to be called.
I tested naming the (all the) service simply "/emergency". Calling it from a single client triggers all the servers. Only the response of the first (?) gets through, but that its fine.
Is this some expected and non-abusive behavior or is this more a current feature that may disappear?
The obvious alternative is to switch to a a topic-pub yet changing the legacy code from "~/emergency" to "/emergency" is easier than rewriting each server as a topic-subscriber. but just in case, if there is something in wrong with pub-sub approach as well, please advise.
All the code is in Python. Managed lifecycle nodes are therefore ASAIK yet out of reach.
Thanks!
Asked by lora on 2023-02-23 05:56:35 UTC
Comments
depends on which version you are running/targetting.
rclpy
got support for managed nodes in Humble. See Humble Hawksbill changelog and the PR: ros2/rclpy#865.Asked by gvdhoorn on 2023-02-23 06:54:27 UTC
Oh, they have been added indeed. That is a welcome feature and good motivation to update the versions. Thanks!
Asked by lora on 2023-02-23 12:12:03 UTC