angular_bounds_filter_in_place.h
Go to the documentation of this file.
00001 /*********************************************************************
00002 *
00003 * Software License Agreement (BSD License)
00004 *
00005 *  Copyright (c) 2009, Willow Garage, Inc.
00006 *  All rights reserved.
00007 *
00008 *  Redistribution and use in source and binary forms, with or without
00009 *  modification, are permitted provided that the following conditions
00010 *  are met:
00011 *
00012 *   * Redistributions of source code must retain the above copyright
00013 *     notice, this list of conditions and the following disclaimer.
00014 *   * Redistributions in binary form must reproduce the above
00015 *     copyright notice, this list of conditions and the following
00016 *     disclaimer in the documentation and/or other materials provided
00017 *     with the distribution.
00018 *   * Neither the name of Willow Garage, Inc. nor the names of its
00019 *     contributors may be used to endorse or promote products derived
00020 *     from this software without specific prior written permission.
00021 *
00022 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033 *  POSSIBILITY OF SUCH DAMAGE.
00034 *
00035 * Author: Kevin Hallenbeck
00036 *********************************************************************/
00037 #ifndef LASER_SCAN_ANGULAR_BOUNDS_FILTER_IN_PLACE_H
00038 #define LASER_SCAN_ANGULAR_BOUNDS_FILTER_IN_PLACE_H
00039 
00040 #include <filters/filter_base.h>
00041 #include <sensor_msgs/LaserScan.h>
00042 
00043 namespace laser_filters
00044 {
00045   class LaserScanAngularBoundsFilterInPlace : public filters::FilterBase<sensor_msgs::LaserScan>
00046   {
00047     public:
00048       double lower_angle_;
00049       double upper_angle_;
00050 
00051       bool configure()
00052       {
00053         lower_angle_ = 0;
00054         upper_angle_ = 0;
00055 
00056         if(!getParam("lower_angle", lower_angle_) || !getParam("upper_angle", upper_angle_)){
00057           ROS_ERROR("Both the lower_angle and upper_angle parameters must be set to use this filter.");
00058           return false;
00059         }
00060 
00061         return true;
00062       }
00063 
00064       virtual ~LaserScanAngularBoundsFilterInPlace(){}
00065 
00066       bool update(const sensor_msgs::LaserScan& input_scan, sensor_msgs::LaserScan& filtered_scan){
00067         filtered_scan = input_scan; //copy entire message
00068 
00069         double current_angle = input_scan.angle_min;
00070         unsigned int count = 0;
00071         //loop through the scan and remove ranges at angles between lower_angle_ and upper_angle_
00072         for(unsigned int i = 0; i < input_scan.ranges.size(); ++i){
00073           if((current_angle > lower_angle_) && (current_angle < upper_angle_)){
00074             filtered_scan.ranges[i] = input_scan.range_max + 1.0;
00075             if(i < filtered_scan.intensities.size()){
00076               filtered_scan.intensities[i] = 0.0;
00077             }
00078             count++;
00079           }
00080           current_angle += input_scan.angle_increment;
00081         }
00082 
00083         ROS_DEBUG("Filtered out %u points from the laser scan.", count);
00084 
00085         return true;
00086 
00087       }
00088   };
00089 };
00090 #endif


laser_filters
Author(s): Tully Foote
autogenerated on Sat Sep 9 2017 02:57:38