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

1 Answer

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 imagehamzamerzic ( 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 imagegstavrinos ( 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 imagetfoote ( 2017-06-08 16:29:30 -0600 )edit

Thanks for your input!

gstavrinos gravatar imagegstavrinos ( 2017-06-08 16:37:44 -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



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

Seen: 814 times

Last updated: Jun 08 '17