18 #ifndef _GAZEBO_MOVING_WINDOW_FILTER_HH_ 19 #define _GAZEBO_MOVING_WINDOW_FILTER_HH_ 25 #include <boost/function.hpp> 26 #include <boost/bind.hpp> 27 #include <boost/shared_ptr.hpp> 28 #include <boost/thread/mutex.hpp> 30 #include <gazebo/gazebo_config.h> 46 class MovingWindowFilterPrivate
49 public: MovingWindowFilterPrivate();
52 public:
unsigned int valWindowSize;
55 public: std::vector<T> valHistory;
58 public:
typename std::vector<T>::iterator valIter;
64 public:
unsigned int samples;
70 MovingWindowFilterPrivate<T>::MovingWindowFilterPrivate()
73 this->valWindowSize = 4;
74 this->valHistory.resize(this->valWindowSize);
75 this->valIter = this->valHistory.begin();
93 public:
void Update(T _val);
97 public:
void SetWindowSize(
unsigned int _n);
101 public:
unsigned int GetWindowSize()
const;
105 public:
bool GetWindowFilled()
const;
116 protected: MovingWindowFilterPrivate<T> *
dataPtr;
122 : dataPtr(new MovingWindowFilterPrivate<T>())
130 this->
dataPtr->valHistory.clear();
146 if (this->
dataPtr->valIter == this->dataPtr->valHistory.end())
155 if (this->
dataPtr->samples > this->dataPtr->valWindowSize)
160 (*this->
dataPtr->valIter) = _val;
167 (*this->
dataPtr->valIter) = _val;
175 this->
dataPtr->valWindowSize = _n;
176 this->
dataPtr->valHistory.clear();
187 return this->
dataPtr->valWindowSize;
201 return this->
dataPtr->sum /
static_cast<double>(this->
dataPtr->samples);
virtual ~MovingWindowFilter()
Destructor.
Definition: MovingWindowFilter.hh:128
Forward declarations for the common classes.
Definition: Animation.hh:33
unsigned int GetWindowSize() const
Get the window size.
Definition: MovingWindowFilter.hh:185
MovingWindowFilterPrivate< T > * dataPtr
Data pointer.
Definition: MovingWindowFilter.hh:116
void SetWindowSize(unsigned int _n)
Set window size.
Definition: MovingWindowFilter.hh:173
Base class for MovingWindowFilter.
Definition: MovingWindowFilter.hh:83
T Get()
Get filtered result.
Definition: MovingWindowFilter.hh:199
#define NULL
Definition: CommonTypes.hh:31
void Update(T _val)
Update value of filter.
Definition: MovingWindowFilter.hh:137
MovingWindowFilter()
Constructor.
Definition: MovingWindowFilter.hh:121
bool GetWindowFilled() const
Get whether the window has been filled.
Definition: MovingWindowFilter.hh:192