ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Call service from specific node

asked 2019-11-26 12:36:06 -0500

unterbuchse gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-11-26 12:38:56 -0500

gvdhoorn gravatar image

updated 2019-11-26 12:39:45 -0500

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?

edit flag offensive delete link more

Comments

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.

unterbuchse gravatar image unterbuchse  ( 2019-11-26 16:22:36 -0500 )edit

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

In any case: as I wrote in my earlier comment: advertise your service servers on private nodehandles.

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).

gvdhoorn gravatar image gvdhoorn  ( 2019-11-27 01:52:45 -0500 )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.

gvdhoorn gravatar image gvdhoorn  ( 2019-11-27 01:54:36 -0500 )edit

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

unterbuchse gravatar image unterbuchse  ( 2019-11-28 09:35:40 -0500 )edit

Question Tools

Stats

Asked: 2019-11-26 12:36:06 -0500

Seen: 236 times

Last updated: Nov 28 '19