18 #ifndef COB_TWIST_CONTROLLER_UTILS_MOVING_AVERAGE_H 19 #define COB_TWIST_CONTROLLER_UTILS_MOVING_AVERAGE_H 33 virtual void reset() = 0;
47 weighting_.assign(size_, 1.0);
57 if (s_.size() < size_)
59 s_.push_front(element);
64 s_.push_front(element);
74 for (uint16_t i = 0; i < s_.size(); ++i)
76 sum += s_[i] * weighting_[i];
77 diff += weighting_[i];
103 this->weighting_.clear();
104 for (uint16_t i = 0; i < this->size_; i++)
106 this->weighting_.push_front(triangle(i));
119 return static_cast<double>(n)*(static_cast<double>(n)+1.0)/2.0;
151 average_ = factor_ * element + (1.0 - factor_) * average_;
181 #endif // COB_TWIST_CONTROLLER_UTILS_MOVING_AVERAGE_H MovingAverageExponential< double > MovingAvgExponential_double_t
MovingAverageWeighted< double > MovingAvgWeighted_double_t
virtual void addElement(T element)=0
IMETHOD Vector diff(const Vector &p_w_a, const Vector &p_w_b, double dt=1)
MovingAverageWeighted(uint16_t size)
MovingAverageBase< double > MovingAvgBase_double_t
MovingAverageExponential(double factor)
virtual bool calcMovingAverage(T &average) const =0
bool calcMovingAverage(T &average) const
MovingAverageSimple(uint16_t size)
void addElement(T element)
std::deque< double > weighting_
double triangle(uint16_t n)
virtual bool calcMovingAverage(T &average) const
MovingAverageSimple< double > MovingAvgSimple_double_t
virtual void addElement(T element)