How to use FilterChain without data copy?

asked 2019-07-10 10:26:22 -0500

seanarm gravatar image

updated 2019-07-10 11:07:30 -0500

I am using a filters::FilterChain<sensor_msgs::LaserScan> to filter lidar data. I made two custom filters. My lidar callback looks like this:

void lidarCB(const sensor_msgs::LaserScanPtr& msg)                                                                                          
    // no copy                                                                                          
    sensor_msgs::LaserScan& scan = *msg;                                                                                          
    filterChain_->update(scan, scan);                                                                                    

In my custom filters, I only operate on the second argument of the update() function because input and output should be exactly the same. What I'm finding is that this does not work as soon as more than one filter is added. And in fact, the two arguments provided to my custom filters' update() functions are not the same object when comparing using std::addressof.

bool update(const sensor_msgs::LaserScan& input, sensor_msgs::LaserScan& filtered)
    if (std::addressof(input) != std::addressof(filtered))
        // error!

Is there any way to send lidar data through a filter chain using the same object/reference?

edit retag flag offensive close merge delete