EEROS  1.0.0.0
API for the EEROS Real-Time Robotics Framework
eeros::control::MAFilter< N, Tval, Tcoeff > Class Template Reference

#include <MAFilter.hpp>

Inheritance diagram for eeros::control::MAFilter< N, Tval, Tcoeff >:
Collaboration diagram for eeros::control::MAFilter< N, Tval, Tcoeff >:

Public Member Functions

 MAFilter (Tcoeff(&coeff)[N])
 
virtual void run ()
 
virtual void enable ()
 
virtual void disable ()
 
- Public Member Functions inherited from eeros::control::Block1i1o< Tval >
 Block1i1o ()
 
virtual Input< Tval > & getIn ()
 
virtual Output< Tval > & getOut ()
 
- Public Member Functions inherited from eeros::control::Block
virtual void setName (std::string name)
 
virtual std::string getName ()
 
- Public Member Functions inherited from eeros::Runnable
virtual ~Runnable ()
 

Protected Attributes

Tcoeff * coefficients
 
Tval previousValues [N] {}
 
bool enabled {true}
 
- Protected Attributes inherited from eeros::control::Block1i1o< Tval >
Input< Tval > in
 
Output< Tval > out
 

Friends

template<size_t No, typename ValT , typename CoeffT >
std::ostream & operator<< (std::ostream &os, MAFilter< No, ValT, CoeffT > &filter)
 

Detailed Description

template<size_t N, typename Tval = double, typename Tcoeff = Tval>
class eeros::control::MAFilter< N, Tval, Tcoeff >

A moving average filter (MAFilter) block is used to filter an input signal. The output signal value depends linearly on the current and various past input signal values. This is achieved by multiplying the current and the past values with the specified coefficients. The results are accumulated and lead to the output signal value. The following terms represents the operation performed in this block.

y[t] = c[0]*x[t-N] + c[1]*x[t-N+1] + ... + c[N]*x[t]

Outp = c[0]*prev[0] + c[1]*prev[1] + ... + c[N]*Inp

MAFilter is a class template with two type and one non-type template arguments. The two type template arguments specify the types which are used for the values and the coefficients when the class template is instanciated. The non-type template argument specifies the number of coefficients and the number of concidered past values respectively.

Template Parameters
N- number of coefficients
Tval- value type (double - default type)
Tcoeff- coefficients type (Tval - default value)
Since
v0.6

Constructor & Destructor Documentation

template<size_t N, typename Tval = double, typename Tcoeff = Tval>
eeros::control::MAFilter< N, Tval, Tcoeff >::MAFilter ( Tcoeff(&)  coeff[N])
inlineexplicit

Constructs a MAFilter instance with the coefficients coeff.

Parameters
coeff- coefficients

Member Function Documentation

template<size_t N, typename Tval = double, typename Tcoeff = Tval>
virtual void eeros::control::MAFilter< N, Tval, Tcoeff >::disable ( )
inlinevirtual

Disables the filter.

If disabled, run() will set the output signal to the input signal.

See also
run()
template<size_t N, typename Tval = double, typename Tcoeff = Tval>
virtual void eeros::control::MAFilter< N, Tval, Tcoeff >::enable ( )
inlinevirtual

Enables the filter.

If enabled, run() will set the output signal value to the accumulated values which result from the current and the past values weighted by the coefficients.

See also
run()
template<size_t N, typename Tval = double, typename Tcoeff = Tval>
virtual void eeros::control::MAFilter< N, Tval, Tcoeff >::run ( )
inlinevirtual

Runs the filter algorithm.

Performs the calculation of the filtered output signal value. Multiplies the current and past input signal values with the coefficients. The coefficients weight the current and past input signal values. Finally, the resulting values are accumulated and yield to the output signal value if the filter instance is enabled. Otherwise, the output signal value is set to the actual input signal value.

The timestamp value will not be altered.

See also
enable()
disable()

Implements eeros::Runnable.

Friends And Related Function Documentation

template<size_t N, typename Tval = double, typename Tcoeff = Tval>
template<size_t No, typename ValT , typename CoeffT >
std::ostream& operator<< ( std::ostream &  os,
MAFilter< No, ValT, CoeffT > &  filter 
)
friend

Member Data Documentation

template<size_t N, typename Tval = double, typename Tcoeff = Tval>
Tcoeff* eeros::control::MAFilter< N, Tval, Tcoeff >::coefficients
protected
template<size_t N, typename Tval = double, typename Tcoeff = Tval>
bool eeros::control::MAFilter< N, Tval, Tcoeff >::enabled {true}
protected
template<size_t N, typename Tval = double, typename Tcoeff = Tval>
Tval eeros::control::MAFilter< N, Tval, Tcoeff >::previousValues[N] {}
protected

The documentation for this class was generated from the following file: