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

Is it bad practice to create and shutdown services during runtime?

asked 2014-11-24 09:10:00 -0600

didi2002 gravatar image

Hi all!

I'm trying to connect my robot to a webserver using a node communication node.
This node creates the service "/get_webdata" when the connection is established and authenticated. When the connection is lost, the service is destroyed again. This allows me to use wait_for_service in other nodes, which is pretty useful for waiting without ugly sleep-loops.

So my question is: is this a common ros practice to use:

webdata = rospy.Service("/get/webdata", Webdata, self.web_cb)

and

webdata.shutdown("Connection lost")

to signal other nodes if the connection is up?
I didn't read anywhere that it's bad practice, but it feels like I'm abusing this feature. Would it be a better solution to keep the service running all the time and instead return a status variable, indicating that the connection is unavailable?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-11-24 10:03:03 -0600

Miquel Massot gravatar image

Hi didi2002!

if you are providing some sort of feedback or action after the service is called I don't see any problem. However, if the only reason why the service is online is to be able to ask if service "X" is available, then maybe a true/false parameter in the parameter server may be enough. The alternative solution that you are proposing is also valid.

edit flag offensive delete link more

Comments

The ros-service is also used by the other nodes, not only for checking if the connection is up. I like the idea of using the parameter server, but I want to avoid polling and sleeping because that introduced quite a delay.

Thanks for your reply!

didi2002 gravatar image didi2002  ( 2014-11-24 10:25:06 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2014-11-24 09:10:00 -0600

Seen: 401 times

Last updated: Nov 24 '14