update_filter.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Pilz GmbH & Co. KG
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13 
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef UPDATE_FILTER_H
19 #define UPDATE_FILTER_H
20 
22 
23 #include <vector>
24 
25 namespace message_filters
26 {
27 
40 template<typename M>
41 class UpdateFilter : public SimpleFilter<M>
42 {
43 public:
46 
50  template<typename F>
52  {
53  connectInput(f);
54  }
55 
59  template<class F>
60  void connectInput(F& f)
61  {
63  incoming_connection_ = f.registerCallback(typename UpdateFilter<M>::EventCallback(boost::bind(&UpdateFilter::cb, this, _1)));
64  }
65 
66 private:
67  void cb(const EventType& evt)
68  {
69  if(evt.getMessage()->header.stamp == last_message_time_)
70  {
71  return;
72  }
73 
74  last_message_time_ = evt.getMessage()->header.stamp;
75 
76  this->signalMessage(evt);
77  }
78 
80 
82 };
83 
84 
85 } // namespace message_filters
86 
87 #endif // UPDATE_FILTER_H
ros::MessageEvent< M const > EventType
Definition: update_filter.h:45
void signalMessage(const MConstPtr &msg)
void cb(const EventType &evt)
Definition: update_filter.h:67
Filters consecutive messages with the same timestamp. Only the first message passes, all consecutive are dropped. It is templated on the message type to be filtered.
Definition: update_filter.h:41
void connectInput(F &f)
Connect to the output of another filter.
Definition: update_filter.h:60
boost::function< void(const EventType &)> EventCallback
boost::shared_ptr< M const > MConstPtr
Definition: update_filter.h:44
UpdateFilter(F &f)
Construct the filter and connect to the output of another filter.
Definition: update_filter.h:51
boost::shared_ptr< M > getMessage() const


prbt_hardware_support
Author(s):
autogenerated on Tue Feb 2 2021 03:50:17