Ask Your Question
2

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
3

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

Comments

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
2

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
0

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

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

Seen: 2,498 times

Last updated: Jun 08 '17