Skip to content

Commit

Permalink
Merge pull request #79 from Jailander/indigo-devel
Browse files Browse the repository at this point in the history
Adding invert filter parameter to BOX filter
  • Loading branch information
jonbinney authored Jul 1, 2019
2 parents 1ef0baa + 3a7da52 commit 6a82d1c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions examples/box_filter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ scan_filter_chain:
min_x: -0.45
min_y: -0.34
min_z: -0.28
invert: false
1 change: 1 addition & 0 deletions include/laser_filters/box_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class LaserScanBoxFilter : public filters::FilterBase<sensor_msgs::LaserScan>

// defines two opposite corners of the box
tf::Point min_, max_;
bool invert_filter;
bool up_and_running_;
};

Expand Down
20 changes: 18 additions & 2 deletions src/box_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ bool laser_filters::LaserScanBoxFilter::configure(){
bool x_min_set = getParam("min_x", min_x);
bool y_min_set = getParam("min_y", min_y);
bool z_min_set = getParam("min_z", min_z);
bool invert_set = getParam("invert", invert_filter);

ROS_INFO("BOX filter started");

max_.setX(max_x);
max_.setY(max_y);
max_.setZ(max_z);
Expand Down Expand Up @@ -88,6 +91,11 @@ bool laser_filters::LaserScanBoxFilter::configure(){
if(!z_min_set){
ROS_ERROR("min_z is not set!");
}
if(!invert_set){
ROS_INFO("invert filter not set, assuming false");
invert_filter=false;
}


return box_frame_set && x_max_set && y_max_set && z_max_set &&
x_min_set && y_min_set && z_min_set;
Expand Down Expand Up @@ -174,9 +182,17 @@ bool laser_filters::LaserScanBoxFilter::update(

tf::Point point(x, y, z);

if(inBox(point)){
output_scan.ranges[index] = std::numeric_limits<float>::quiet_NaN();
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();
}
}

}
up_and_running_ = true;
return true;
Expand Down

0 comments on commit 6a82d1c

Please sign in to comment.