Ask Your Question
0

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 :http://wiki.ros.org/rospy/Overview/Services, 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
1

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.

Cheers.

edit flag offensive delete link more

Comments

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

2 followers

Stats

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

Seen: 467 times

Last updated: Jun 18 '20