ros-perception / laser_filters

Assorted filters designed to operate on 2D planar laser scanners, which use the sensor_msgs/LaserScan type.
BSD 3-Clause "New" or "Revised" License
172 stars 204 forks source link

Is there an inverted Box-Filter? #147

Closed NikolasE closed 1 year ago

NikolasE commented 2 years ago

I would like to use the box-filter to remove everything but(!) the points in front of the robot, but in the current implementation, the points in the box are deleted:

      if (inBox(point))
        {
          output_scan.ranges[*iter_i] = std::numeric_limits<float>::quiet_NaN();
        } 

Is there already in inverted version? (otherwise I'll create a small PR with an additional "keep_box_points"-parameter that defaults to false)

JohnTGZ commented 2 years ago

May I know which branch are you currently on? I think on the "noetic-devel" branch, there should already be a parameter for box_filter to invert "removing" the points. You can also find the source code that corresponds to this implementation in box_filter.cpp here:

    if(!invert_filter){
      if(inBox(point)){
        output_scan.ranges[index] = std::numeric_limits<float>::quiet_NaN();
      }
    }
    else{
      if(!inBox(point)){
        output_scan.ranges[index] = std::numeric_limits<float>::quiet_NaN();
      }
    }
jonbinney commented 2 years ago

I think that @NikolasE is on the ros2 branch; we've had some discussion about porting the invert param to that branch here: https://github.com/ros-perception/laser_filters/pull/148