Ask Your Question

Difference between rospy.Service and rospy.Serviceproxy

asked 2020-06-17 15:58:32 -0600

hammerli gravatar image

Hi When I'm learning the concepts about ROS service from this web :, I was confused by these two similar functions rospy.Service and rospy.Serviceproxy. From my understanding , both functions do the same things as they pass the same arguments. Hope someone can address my question.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-06-18 15:01:36 -0600

Weasfas gravatar image

Hi @hammerli,

  1. Therospy.Servicedirective returns an Service instance with a callback for the node to provide a service communication.
  2. The rospy.ServiceProxydirective returns a callable instance that is used to perform a request to the server client.

To provide a simple example I will use the main tutorial about this paradigm of communication.

Let us say that you have two nodes: Node A provides a service with the name add_integers to sum two integer numbers, so it needs to use rospy.Service to let ROS know that it provides this kind of service for anyone willing to compute the sum of two integers. Meanwhile, Node B, that struggles to compute the sum of two numbers, suddenly realised that it can use the implementation provided by Node A and solve its problem. In that case, Node B, will use a rospy.ServiceProxy instance refering to the add_integers Service to request Node A with the sum of two integer that he provides. With that particular set up you have a Server/Client architecture where one node processes requests (Node A) and another one just requests things (Node B).

I hope that helps you to understand better both directives.


edit flag offensive delete link more


Thanks for your explanation, it really helps!

hammerli gravatar image hammerli  ( 2020-06-22 13:15:06 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-06-17 15:58:32 -0600

Seen: 467 times

Last updated: Jun 18 '20