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

What to do with unused node?

asked 2012-06-05 03:49:20 -0500

liborw gravatar image

updated 2014-04-20 14:09:31 -0500

ngrennan gravatar image

Hi,

there are some tasks (topics) that are needed only from time to time (i.e. camera capture and processing), however, it is not good idea to implement them as services (i.e. the topic is subscribed by many nodes).

One option that come to my mind are to use parameter server to control where the node is computing and where is doing nothing.

What are the the other options? Or what is the advised approach to deal with unused nodes?

Thanks

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
4

answered 2012-06-05 04:02:48 -0500

DimitriProsser gravatar image

The ros::Publisher class provides a method that you could use:

ros::Rate poll_rate(100);
while(chatter_pub.getNumSubscribers() == 0)
    poll_rate.sleep();

This block of code will wait until there's a subscriber connected to continue. I'm not sure if this is what you need, but it is one option.

I'm not sure how your system of nodes is configured, but another option you could use would be to provide a "start" and "stop" service that you could call to tell the node when to compute. This is much easier than using the parameter server to do so.

edit flag offensive delete link more
1

answered 2012-06-05 03:59:41 -0500

Lorenz gravatar image

You can write nodes that only produce data when there is at least one subscriber. Two ways to achieve that:

  1. NodeHandle::advertise supports subscription callbacks that are executed whenever a node subscribes or unsubscribes from the topic.

  2. The Publisher object returned by advertise has a method getNumSubscribers.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-06-05 03:49:20 -0500

Seen: 329 times

Last updated: Jun 05 '12