Skip to content

Commit

Permalink
Merge pull request #3 from YoheiKakiuchi/groovy-devel
Browse files Browse the repository at this point in the history
add range_filter to laser_scan_filters.cpp
  • Loading branch information
vrabaud committed May 11, 2013
2 parents 9f9f7d3 + 7273bf9 commit 03a4e13
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 1 deletion.
94 changes: 94 additions & 0 deletions include/laser_filters/range_filter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*********************************************************************
* Software License Agreement (BSD License)
*
* Copyright (c) 2013, JSK (The University of Tokyo).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the Willow Garage nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*********************************************************************/

#ifndef LASER_SCAN_RANGE_FILTER_H
#define LASER_SCAN_RANGE_FILTER_H
/**
\author Yohei Kakiuchi
@b ScanRangeFilter takes input scans and filters within indicated range.
**/


#include "filters/filter_base.h"
#include "sensor_msgs/LaserScan.h"

namespace laser_filters
{

class LaserScanRangeFilter : public filters::FilterBase<sensor_msgs::LaserScan>
{
public:

double lower_threshold_ ;
double upper_threshold_ ;
int disp_hist_ ;

bool configure()
{
lower_threshold_ = 0.0;
upper_threshold_ = 100000.0;
disp_hist_ = 1;
getParam("lower_threshold", lower_threshold_);
getParam("upper_threshold", upper_threshold_) ;

return true;
}

virtual ~LaserScanRangeFilter()
{

}

bool update(const sensor_msgs::LaserScan& input_scan, sensor_msgs::LaserScan& filtered_scan)
{
filtered_scan = input_scan;
for (unsigned int i=0;
i < input_scan.ranges.size() && i < input_scan.intensities.size();
i++) // Need to check ever reading in the current scan
{
{
if (filtered_scan.ranges[i] <= lower_threshold_ || filtered_scan.ranges[i] >= upper_threshold_)
{
filtered_scan.ranges[i] = input_scan.range_max + 1.0 ;
}
}
}

return true;
}
} ;

}

#endif // LASER_SCAN_RANGE_FILTER_H
6 changes: 6 additions & 0 deletions laser_filters_plugins.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
This is a filter which filters sensor_msgs::LaserScan messages based on intensity
</description>
</class>
<class name="laser_filters/LaserScanRangeFilter" type="laser_filters::LaserScanRangeFilter"
base_class_type="filters::FilterBase<sensor_msgs::LaserScan>">
<description>
This is a filter which filters sensor_msgs::LaserScan messages based on intensity
</description>
</class>
<class name="laser_filters/ScanShadowsFilter" type="laser_filters::ScanShadowsFilter"
base_class_type="filters::FilterBase<sensor_msgs::LaserScan>">
<description>
Expand Down
2 changes: 2 additions & 0 deletions src/laser_scan_filters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "laser_filters/median_filter.h"
#include "laser_filters/array_filter.h"
#include "laser_filters/intensity_filter.h"
#include "laser_filters/range_filter.h"
#include "laser_filters/scan_shadows_filter.h"
#include "laser_filters/footprint_filter.h"
#include "laser_filters/interpolation_filter.h"
Expand All @@ -43,6 +44,7 @@
PLUGINLIB_DECLARE_CLASS(laser_filters, LaserMedianFilter, laser_filters::LaserMedianFilter, filters::FilterBase<sensor_msgs::LaserScan>)
PLUGINLIB_DECLARE_CLASS(laser_filters, LaserArrayFilter, laser_filters::LaserArrayFilter, filters::FilterBase<sensor_msgs::LaserScan>)
PLUGINLIB_DECLARE_CLASS(laser_filters, LaserScanIntensityFilter, laser_filters::LaserScanIntensityFilter, filters::FilterBase<sensor_msgs::LaserScan>)
PLUGINLIB_DECLARE_CLASS(laser_filters, LaserScanRangeFilter, laser_filters::LaserScanRangeFilter, filters::FilterBase<sensor_msgs::LaserScan>)
PLUGINLIB_DECLARE_CLASS(laser_filters, LaserScanAngularBoundsFilter, laser_filters::LaserScanAngularBoundsFilter, filters::FilterBase<sensor_msgs::LaserScan>)
PLUGINLIB_DECLARE_CLASS(laser_filters, LaserScanFootprintFilter, laser_filters::LaserScanFootprintFilter, filters::FilterBase<sensor_msgs::LaserScan>)
PLUGINLIB_DECLARE_CLASS(laser_filters, ScanShadowsFilter, laser_filters::ScanShadowsFilter, filters::FilterBase<sensor_msgs::LaserScan>)
Expand Down
2 changes: 1 addition & 1 deletion stack.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
<depend stack="pluginlib" /> <!-- pluginlib -->
<depend stack="ros" />
<depend stack="ros_comm" /> <!-- std_msgs, roscpp, message_filters -->
<depend stack="laser_geometry"/>
<!--depend stack="laser_geometry"/-->
</stack>

0 comments on commit 03a4e13

Please sign in to comment.