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.hpp>
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
67 
68  // Setup tf::MessageFilter for input
69  tf_filter_.registerCallback(boost::bind(&GenericLaserScanFilterNode::callback, this, boost::placeholders::_1));
71 
72  // Advertise output
73  output_pub_ = nh_.advertise<sensor_msgs::LaserScan>("output", 1000);
74 
75  deprecation_timer_ = nh_.createTimer(ros::Duration(5.0), [this](auto& event){ deprecation_warn(event); });
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
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 }
ros::Publisher
GenericLaserScanFilterNode::deprecation_timer_
ros::Timer deprecation_timer_
Definition: generic_laser_filter_node.cpp:56
ros::init
ROSCPP_DECL void init(const M_string &remappings, const std::string &name, uint32_t options=0)
GenericLaserScanFilterNode::GenericLaserScanFilterNode
GenericLaserScanFilterNode()
Definition: generic_laser_filter_node.cpp:60
tf::MessageFilter::setTolerance
void setTolerance(const ros::Duration &tolerance)
ros.h
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
ros::NodeHandle::advertise
Publisher advertise(AdvertiseOptions &ops)
filters::FilterChain::configure
bool configure(std::string param_name, ros::NodeHandle node=ros::NodeHandle())
message_filters::Subscriber< sensor_msgs::LaserScan >
filters::FilterChain< sensor_msgs::LaserScan >
GenericLaserScanFilterNode::msg_
sensor_msgs::LaserScan msg_
Definition: generic_laser_filter_node.cpp:53
main
int main(int argc, char **argv)
Definition: generic_laser_filter_node.cpp:94
filters::FilterChain::update
bool update(const T &data_in, T &data_out)
message_filter.h
subscriber.h
GenericLaserScanFilterNode::scan_sub_
message_filters::Subscriber< sensor_msgs::LaserScan > scan_sub_
Definition: generic_laser_filter_node.cpp:46
ROS_WARN
#define ROS_WARN(...)
GenericLaserScanFilterNode
Definition: generic_laser_filter_node.cpp:38
GenericLaserScanFilterNode::filter_chain_
filters::FilterChain< sensor_msgs::LaserScan > filter_chain_
Definition: generic_laser_filter_node.cpp:50
ros::TimerEvent
GenericLaserScanFilterNode::tf_
tf::TransformListener tf_
Definition: generic_laser_filter_node.cpp:45
transform_listener.h
GenericLaserScanFilterNode::callback
void callback(const sensor_msgs::LaserScan::ConstPtr &msg_in)
Definition: generic_laser_filter_node.cpp:84
GenericLaserScanFilterNode::deprecation_warn
void deprecation_warn(const ros::TimerEvent &e)
Definition: generic_laser_filter_node.cpp:78
tf::MessageFilter< sensor_msgs::LaserScan >
tf::TransformListener
GenericLaserScanFilterNode::tf_filter_
tf::MessageFilter< sensor_msgs::LaserScan > tf_filter_
Definition: generic_laser_filter_node.cpp:47
ros::spin
ROSCPP_DECL void spin()
GenericLaserScanFilterNode::output_pub_
ros::Publisher output_pub_
Definition: generic_laser_filter_node.cpp:54
filter_chain.hpp
ros::NodeHandle::createTimer
Timer createTimer(Duration period, const TimerCallback &callback, bool oneshot=false, bool autostart=true) const
ros::Duration
ros::Timer
t
geometry_msgs::TransformStamped t
ros::NodeHandle
GenericLaserScanFilterNode::nh_
ros::NodeHandle nh_
Definition: generic_laser_filter_node.cpp:42


laser_filters
Author(s): Tully Foote
autogenerated on Mon Apr 3 2023 02:51:57