# Call service from specific node

Scenario: System of multiple nodes able to be configured during runtime via one master. Idea: every node provides a service (ex: configure_node(config)) which can be called by the master. Each node is uniquely named and does a job specific to the configuration it got.

Problem: I cant find anything about calling a service on a specific node (ex: NodeA/configure_node). Of course it could be realised using Pub/Sub but I would appreciate the RPC like features of the services. Is there anything I am missing?

edit retag close merge delete

Sort by » oldest newest most voted

You're probably aware, but: your described setup would go against the idea of location independence / agnosticity that is one of the main advantages of ROS (or any other framework/middleware with location independence).

I cant find anything about calling a service on a specific node (ex: NodeA/configure_node).

yes, and I believe that is because of what I wrote above.

Using service servers started on private nodehandles would make this possible without too much fiddling with internals.

Just to avoid an xy-problem, could you describe why you want to do this?

more

As I stated above, the idea is to call some method on a named node with the "luxury" of RPC like request/response behavior. Of course I am aware of the term "Service" as described in, for example, Service Oriented Architectures, which indeed focuses on non monolithic systems where it is not important who computes something but rather that a specific task can be handled. Currently I cannot see any other RPC like system provided by ROS, maybe you guys have some ideas. The workaround will be: let the nodes subscribe to their respective function call (ie: NodeA/configure_node) and then let the main program publish the configurations. This would work but not give the neat RPC features.

( 2019-11-26 16:22:36 -0600 )edit

It sounds like you want to use nodes almost as libraries and create a monolithic system out of something that is inherently distributed.

That way you get $node_name/$service_name instead of $service_name as the identifier for the service. In service clients you can then pass $node_name/$service_name and invoke $service_name on \$node_name specifically.

See how dynamic_reconfigure does this, as it sounds like it does something similar.

The workaround will be: let the nodes subscribe to their respective function call (ie: NodeA/configure_node) and then let the main program publish the configurations. This would work but not give the neat RPC features.

I'm not sure this is what I just described, as I don't really understand your description (nor why it is a work-around).

( 2019-11-27 01:52:45 -0600 )edit

As I stated above, the idea is to call some method on a named node with the "luxury" of RPC like request/response behavior. [..]

yes, but you haven't actually told us why you want to do that.

It could well be there is some other design pattern or interaction scheme that is better suited for what your actual goal is.

Right now we wouldn't know, as you don't describe it. So we can only discuss the problem you have identified with the solution you've already decided upon.

( 2019-11-27 01:54:36 -0600 )edit

The tip about the private nodehandlers and the use of the ~ made the trick for me. Thanks @gvdhoorn

( 2019-11-28 09:35:40 -0600 )edit