ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

Is wait_for_service required before every service call?

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

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 -0600

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

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 -0600 )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 -0600 )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 -0600 )edit

Thanks for your input!

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

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

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

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: 2017-06-08 03:34:59 -0600

Seen: 3,316 times

Last updated: Jun 08 '17