Ask Your Question

Separating callback from other modules

asked 2012-04-10 20:59:14 -0500

CaptainTrunky gravatar image

updated 2012-04-10 21:20:41 -0500


May I want something strange, but it interesting programming problem. So, I wrote class-wrapper Sensor that subscribes on topic (like /camera/image) and in callback receives data (like this->callback(Image& data), node.subscribe(..., &Sensor::callback). Data should be prepared by some filters. At this moment, filters called in callback:

void Sensor::callback(Image& data)
Image* newData;
newData = filter1(data);
newData = filter2(newData);

But I think it is not good. Is there way to separate them from Sensor? Something like this:

data = Sensor.getData();
data = filter1(data);
data = filter2(data);

I think that I missed simple idea of this.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-04-10 21:32:12 -0500

Lorenz gravatar image

Similar things have been done in ROS and other libraries already. You can either use and extend existing implementations or take them as examples on how the design could look like. Have a look at filters, pcl_ros, the pcl_ros tutorials and pcl including its tutorials.

edit flag offensive delete link more


Thanks. Filters are exactly what I need.

CaptainTrunky gravatar image CaptainTrunky  ( 2012-04-11 05:30:50 -0500 )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: 2012-04-10 20:59:14 -0500

Seen: 119 times

Last updated: Apr 10 '12