generic_laser_filter_node.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 
31 #include "ros/ros.h"
32 #include "sensor_msgs/LaserScan.h"
34 #include "tf/message_filter.h"
35 #include "tf/transform_listener.h"
36 #include "filters/filter_chain.h"
37 
39 {
40 protected:
41  // Our NodeHandle
43 
44  // Components for tf::MessageFilter
48 
49  // Filter Chain
51 
52  // Components for publishing
53  sensor_msgs::LaserScan msg_;
55 
57 
58 public:
59  // Constructor
61  scan_sub_(nh_, "scan_in", 50),
62  tf_filter_(scan_sub_, tf_, "base_link", 50),
63  filter_chain_("sensor_msgs::LaserScan")
64  {
65  // Configure filter chain
66  filter_chain_.configure("");
67 
68  // Setup tf::MessageFilter for input
69  tf_filter_.registerCallback(boost::bind(&GenericLaserScanFilterNode::callback, this, _1));
70  tf_filter_.setTolerance(ros::Duration(0.03));
71 
72  // Advertise output
73  output_pub_ = nh_.advertise<sensor_msgs::LaserScan>("output", 1000);
74 
75  deprecation_timer_ = nh_.createTimer(ros::Duration(5.0), boost::bind(&GenericLaserScanFilterNode::deprecation_warn, this, _1));
76  }
77 
79  {
80  ROS_WARN("'generic_laser_filter_node' has been deprecated. Please switch to 'scan_to_scan_filter_chain'.");
81  }
82 
83  // Callback
84  void callback(const sensor_msgs::LaserScan::ConstPtr& msg_in)
85  {
86  // Run the filter chain
87  filter_chain_.update (*msg_in, msg_);
88 
89  // Publish the output
90  output_pub_.publish(msg_);
91  }
92 };
93 
94 int main(int argc, char **argv)
95 {
96  ros::init(argc, argv, "scan_filter_node");
97 
99  ros::spin();
100 
101  return 0;
102 }
filters::FilterChain< sensor_msgs::LaserScan > filter_chain_
void publish(const boost::shared_ptr< M > &message) const
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
#define ROS_WARN(...)
ROSCPP_DECL void spin(Spinner &spinner)
void deprecation_warn(const ros::TimerEvent &e)
Timer createTimer(Rate r, Handler h, Obj o, bool oneshot=false, bool autostart=true) const
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
bool update(const T &data_in, T &data_out)
message_filters::Subscriber< sensor_msgs::LaserScan > scan_sub_
bool configure(std::string param_name, ros::NodeHandle node=ros::NodeHandle())
void callback(const sensor_msgs::LaserScan::ConstPtr &msg_in)
void setTolerance(const ros::Duration &tolerance)
tf::MessageFilter< sensor_msgs::LaserScan > tf_filter_
int main(int argc, char **argv)
Connection registerCallback(const C &callback)


laser_filters
Author(s): Tully Foote
autogenerated on Wed Jul 3 2019 19:33:47