I'm learning about ROS, now I'm doing some examples using a Server and Client, there's something that I don't understand specifically is when ros blocks a service, I mean
rospy.wait_for_service("add_two_ints")
according to the documentation it blocks until the service named add_two_ints is available. but then is necessary to create a handle for calling the service
add_two_ints = rospy.ServiceProxy('add_two_ints', AddTwoInts)
my question is rospy.wait_for_service() will execute n times? until the service finish its work? thanks so much I'm so confused about this
So
rospy.wait_for_service("add_two_ints")
checks if the service is available and blocks as long as it cannot reach the service.
And
add_two_ints = rospy.ServiceProxy('add_two_ints', AddTwoInts)
creates the object which communicates with the Server.
If the server is available during the call of rospy.wait_for_service()
, the function returns and it is not checked further. If the server fails during execution of the remote function the try catch block has to catch the error.