array_filter.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 Radu Bogdan Rusu <rusu@cs.tum.edu>
3  *
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  *
27  * $Id: $
28  *
29  */
30 
32 
33 namespace laser_filters
34 {
36  num_ranges_(1), range_filter_(NULL), intensity_filter_(NULL)
37 {
38 
39 };
40 
42 {
43 
44  bool found_range_config = getParam("range_filter_chain", range_config_);
45  bool found_intensity_config = getParam("intensity_filter_chain", intensity_config_);
46 
47  if (!found_range_config && !found_intensity_config)
48  {
49  ROS_ERROR("Cannot Configure LaserArrayFilter: Didn't find \"range_filter\" or \"intensity _filter\" tag within LaserArrayFilter params. Filter definitions needed inside for processing range and intensity");
50  return false;
51  }
52 
53  if (range_filter_)
54  delete range_filter_;
55 
57  delete intensity_filter_;
58 
59  if (found_range_config)
60  {
63  return false;
64  }
65 
66  if (found_intensity_config)
67  {
70  return false;
71  }
72 
73  return true;
74 };
75 
77 {
78  if (range_filter_)
79  delete range_filter_;
80 
82  delete intensity_filter_;
83 };
84 
85 bool LaserArrayFilter::update(const sensor_msgs::LaserScan& scan_in, sensor_msgs::LaserScan& scan_out)
86 {
87  if (!this->configured_)
88  {
89  ROS_ERROR("LaserArrayFilter not configured");
90  return false;
91  }
92 
93  boost::mutex::scoped_lock lock(data_lock);
94  scan_out = scan_in;
95 
96  if (scan_in.ranges.size() != num_ranges_) //Reallocating
97  {
98  num_ranges_ = scan_in.ranges.size();
99 
100  ROS_INFO("LaserArrayFilter cleaning and reallocating due to larger scan size");
101 
102  configure();
103  }
104 
106  range_filter_->update(scan_in.ranges, scan_out.ranges);
107  intensity_filter_->update(scan_in.intensities, scan_out.intensities);
108 
109 
110  return true;
111 }
112 }
filters::MultiChannelFilterChain< float > * intensity_filter_
Definition: array_filter.h:78
LaserScanMaskFilter removes points on directions defined in a mask from a laser scan.
bool update(const std::vector< T > &data_in, std::vector< T > &data_out)
XmlRpc::XmlRpcValue range_config_
How many data point are in each row.
Definition: array_filter.h:71
bool update(const sensor_msgs::LaserScan &scan_in, sensor_msgs::LaserScan &scan_out)
Update the filter and get the response.
#define ROS_INFO(...)
unsigned int num_ranges_
How many scans to average over.
Definition: array_filter.h:69
XmlRpc::XmlRpcValue intensity_config_
Definition: array_filter.h:72
bool getParam(const std::string &name, std::string &value) const
filters::MultiChannelFilterChain< float > * range_filter_
Definition: array_filter.h:77
bool configure(unsigned int size, std::string param_name, ros::NodeHandle node=ros::NodeHandle())
#define ROS_ERROR(...)


laser_filters
Author(s): Tully Foote
autogenerated on Mon Feb 28 2022 22:39:24