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> 45 class MovingWindowFilterPrivate
48 public: MovingWindowFilterPrivate<T>();
51 public:
unsigned int valWindowSize;
54 public: std::vector<T> valHistory;
57 public:
typename std::vector<T>::iterator valIter;
62 public:
unsigned int samples;
71 MovingWindowFilterPrivate<T>::MovingWindowFilterPrivate() :
76 this->valHistory.resize(this->valWindowSize);
77 this->valIter = this->valHistory.begin();
93 public:
void Update(T _val);
114 MovingWindowFilterPrivate<T> &_d);
117 protected: MovingWindowFilterPrivate<T> *
dataPtr;
125 :
dataPtr(new MovingWindowFilterPrivate<T>())
133 this->
dataPtr->valHistory.clear();
149 if (this->
dataPtr->valIter == this->dataPtr->valHistory.end())
158 if (this->
dataPtr->samples > this->dataPtr->valWindowSize)
163 (*this->
dataPtr->valIter) = _val;
170 (*this->
dataPtr->valIter) = _val;
178 this->
dataPtr->valWindowSize = _n;
179 this->
dataPtr->valHistory.clear();
190 return this->
dataPtr->valWindowSize;
204 return this->
dataPtr->sum /
static_cast<double>(this->
dataPtr->samples);
virtual ~MovingWindowFilter()
Destructor.
Definition: MovingWindowFilter.hh:131
Forward declarations for the common classes.
Definition: Animation.hh:26
unsigned int GetWindowSize() const
Get the window size.
Definition: MovingWindowFilter.hh:188
MovingWindowFilterPrivate< T > * dataPtr
Data pointer.
Definition: MovingWindowFilter.hh:117
void SetWindowSize(unsigned int _n)
Set window size.
Definition: MovingWindowFilter.hh:176
Base class for MovingWindowFilter.
Definition: MovingWindowFilter.hh:83
T Get()
Get filtered result.
Definition: MovingWindowFilter.hh:202
void Update(T _val)
Update value of filter.
Definition: MovingWindowFilter.hh:140
MovingWindowFilter()
Constructor.
Definition: MovingWindowFilter.hh:124
bool GetWindowFilled() const
Get whether the window has been filled.
Definition: MovingWindowFilter.hh:195