pcdfilter_pa_ros_throttle.cpp
Go to the documentation of this file.
1 /******************************************************************************
2 * *
3 * pcdfilter_pa_ros_throttle.cpp *
4 * ============================= *
5 * *
6 *******************************************************************************
7 * *
8 * github repository *
9 * https://github.com/TUC-ProAut/ros_pcdfilter *
10 * *
11 * Chair of Automation Technology, Technische Universität Chemnitz *
12 * https://www.tu-chemnitz.de/etit/proaut *
13 * *
14 *******************************************************************************
15 * *
16 * New BSD License *
17 * *
18 * Copyright (c) 2015-2018, Peter Weissig, Technische Universität Chemnitz *
19 * All rights reserved. *
20 * *
21 * Redistribution and use in source and binary forms, with or without *
22 * modification, are permitted provided that the following conditions are met: *
23 * * Redistributions of source code must retain the above copyright *
24 * notice, this list of conditions and the following disclaimer. *
25 * * Redistributions in binary form must reproduce the above copyright *
26 * notice, this list of conditions and the following disclaimer in the *
27 * documentation and/or other materials provided with the distribution. *
28 * * Neither the name of the Technische Universität Chemnitz nor the *
29 * names of its contributors may be used to endorse or promote products *
30 * derived from this software without specific prior written permission. *
31 * *
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" *
33 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *
34 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE *
35 * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY *
36 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
37 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
38 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER *
39 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT *
40 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY *
41 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
42 * DAMAGE. *
43 * *
44 ******************************************************************************/
45 
46 // local headers
48 
49 //**************************[cPcdFilterPaRosThrottle]**************************
51  skip_count_ = 0;
52  skip_time_ = 0.1;
54 
55  block_all_input_ = false;
56 
57  resetThrottle();
58 }
59 
60 //**************************[~cPcdFilterPaRosThrottle]*************************
62 }
63 
64 //**************************[checkNewInput]************************************
66 
67  bool result = false;
68 
69  if (block_all_input_) {
70  return false;
71  }
72 
73  // check for time discontinuities
74  if (time_ > ros::Time(1)) {
76  resetThrottle();
77  }
78  }
79 
80  // check counter
81  count_input_++;
82  if (skip_count_ > 0) {
83  if (count_input_ % (skip_count_ + 1) != 1) {
84  return false;
85  }
86  }
87 
88  // check time
89  if ((skip_time_ > 0) && (time_ > ros::Time(1))) {
90  if (time - time_ < ros::Duration(skip_time_)) {
91  return false;
92  }
93  }
94 
95  time_ = time;
96  return true;
97 }
98 //**************************[resetThrottle]************************************
100 
101  count_input_ = 0;
102  time_ = ros::Time(0);
103  block_all_input_ = false;
104 }
~cPcdFilterPaRosThrottle()
default destructor
cPcdFilterPaRosThrottle()
default constructor
int count_input_
number of incoming messages - used for dropping some input
ros::Time time_
ros time of last input
void resetThrottle(void)
forces the throttle filter to accept next input
bool checkNewInput(ros::Time time=ros::Time::now())
checks if the current data is accepted


pcdfilter_pa
Author(s):
autogenerated on Mon Dec 23 2019 03:56:23