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

Revision history [back]

click to hide/show revision 1
initial version

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.

Cheers.