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

Is wait_for_service required before every service call?

asked 2017-06-08 03:34:59 -0500

hamzamerzic gravatar image

Hi, I don't fully understand the mechanics of rospy's wait_for_service function. Are we required to call wait for service every time we want to call the service, or only once when creating the ServiceProxy?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2017-06-08 04:10:27 -0500

updated 2017-06-08 04:11:36 -0500

You don't need to call wait_for_service, but it is highly advisable, since you want to make sure that your service is available before calling it.

edit flag offensive delete link more


What can cause the service to become unavailable?

hamzamerzic gravatar image hamzamerzic  ( 2017-06-08 05:25:40 -0500 )edit

Too many things actually. From connection problems to bad code handling that would kill the node that runs the service. Keep in mind that you can set a timeout in wait_for_services after which an exception will be thrown.

gstavrinos gravatar image gstavrinos  ( 2017-06-08 05:39:33 -0500 )edit

The most common reason is at startup that the other node has not yet advertised the service or the connection has not been established.

tfoote gravatar image tfoote  ( 2017-06-08 16:29:30 -0500 )edit

Thanks for your input!

gstavrinos gravatar image gstavrinos  ( 2017-06-08 16:37:44 -0500 )edit

answered 2021-10-13 16:47:47 -0500

Joshi_Kashyap gravatar image

rospy.wait_for_servicefunction will wait for the service to active, when the server will get activated then it will return response of your request and then your client side program will proceed further!

I hope you got something meaningful from this :)

edit flag offensive delete link more

Question Tools



Asked: 2017-06-08 03:34:59 -0500

Seen: 4,179 times

Last updated: Jun 08 '17