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

Avoiding overhead when nothing is subscribed *to a pipeline*

asked 2015-08-20 10:04:41 -0500

thebyohazard gravatar image

updated 2015-08-21 09:17:32 -0500

I know that publish doesn't do anything if nothing is subscribed to a node.

A while back, you guys helped me avoid work in my own callbacks if nothing is subscribed to my node.

But what about the case of pipelines? Let's say I have nodes (a, b, c, and d), each one feeding the next. All I really care about is the output of d (except for debugging). If I write the nodes, I can subscribe and unsubscribe to the input, thus avoiding the work of the pipeline. However, with nodes I didn't write, this is likely not the case, and so I only avoid the work done by the last node, since c still has the subscriber d.

Is there any work toward this kind of efficiency of a whole pipeline? Perhaps some kind of pipeline API in the works that can tell a node not to execute a callback even if it has a subscriber because the output of the pipeline isn't being subscribed to?

EDIT

For clarity, let me elaborate a bit more and give an example.

Let's say I have a kinect and all its nodelets producing a point cloud. I also use the pcl_nodelets. The raw point cloud output goes to a cropbox nodelet. The cropbox feeds a voxelgrid nodelet, and the voxelgrid filter feeds a planar segmentation nodelet. I write a node that uses the model parameters from the plane.

kinect -> cropbox -> voxelgrid -> segmentation -> user_application

My user_application nodelet does not always need the model parameters. In the user_application node, I could subscribe and unsubscribe from the model parameters. If the segmentation nodelet is well written, it won't do any work upon recieving a point cloud from the voxelgrid filter since no one is subscribed.

However, the voxelgrid will still do work since it still has a subscriber, namely the segmentation nodelet. Likewise, the cropbox still processes for the voxelgrid. I'm interested in avoiding the work that these other nodelets are doing.

It's possible to write the node[let]s so that they subscribe and unsubscribe in each step of the pipeline, so that when my user_application node subscribes to the segmentation node, it causes a chain reaction where the segmentation node then subscribes to the voxelgrid nodelet, the voxelgrid subscribes to the cropbox and so on. Unsubscribe would work the same way. This seems hard to debug, though, as the nodes will not always show as connected in rosnode info nor in the graph gui.

It could also be standard procedure to write node[let]s that will be part of a pipeline with a separate process topic/service, so that upon receiving a message on the process topic, the pipeline processing starts or stops. That adds more overhead to get the pipeline running, though. And what if you want to look at the intermediate steps in the pipeline when the pipeline isn't running?

My thought: what if there was a way when launching ... (more)

edit retag flag offensive close merge delete

Comments

Interesting. It makes more sense to me to be implemented in lower level (maybe rostopic and equivalent) to optionally return if there's no subscribers (pretty much like your reference).

130s gravatar image 130s  ( 2015-08-20 19:55:39 -0500 )edit

Or do you think coordinated behavior (by pipeline) better? Anyway this is enhancement discussion that's better opened at somewhere else.

130s gravatar image 130s  ( 2015-08-20 19:56:58 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-08-21 10:32:22 -0500

dornhege gravatar image

Afaik this does not exist in ROS and I would have suggested to unsubscribe on demand. As you describe this, you want to uphold the subscription to see this in the node graph, but only stop processing internally. As nodes do not have any way to figure this out, you will need something external.

Given that any pipeline node cannot know anything about the configuration and where the exit subscribers are, you will have to either setup some kind of manager (for nodelets the nodelet manager could be used) or provide an parallel pipeline mechanism that connects all pipeline nodes and instead of the data only provides the information if things should be computed backwards through the pipeline.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-08-20 10:04:41 -0500

Seen: 204 times

Last updated: Aug 21 '15