Why publish if no one is subscribing?
Although it sounds like something my wife probably wonders about me sometimes - why do I talk if no one is listening? - I've wondered the same thing many times about a ROS publisher. I've never ran into any problems as long as everything is running on the same computer, but when I'm using two computers communicating over wireless, having data flow across the network that isn't getting used is costly.
As an example, I have a pioneer with a kinect on it, most of the time the robot is in an autonomous mode and I don't use the wireless, but sometimes I want to teleoperate the robot and use the kinect's camera to see where I'm going. But running the openni node publishes a TON of data, even when I turn off almost everything in the launch file. There's so much data with all the different video feeds that the network gets flooded and the lag in the video makes it unuseable. Usually I'll just dive in hacking the code and cut out all unneeded topics and create a specialized node, but is there a better way?
When I'm creating my own nodes that produce a lot of data, I usually use the publisher.getNumSubscribers() function to check if anyone is listening to a topic before publishing anything. My question is, is there a reason that all publishers don't do something similar by default? Would it be possible to add this capability to the core publisher code? Or is there something I'm missing?
Thanks, Aaron