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

#include <MedianFilter.hpp>

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

Public Member Functions

 MedianFilter ()
 
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

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

Static Protected Attributes

static constexpr int medianIndex {static_cast<int>(floor(N/2))}
 

Friends

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

Detailed Description

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

A median filter (MedianFilter) block is used to filter an input signal. The output signal value depends on the current and various past input signal values. The median filter algorithm sorts all values. The median value will be set as output signal value if the MedianFilter instance is enabled.

MedianFilter is a class template with one type and one non-type template argument. The type template argument specifies the type which is used for the values when the class template is instantiated. The non-type template argument specifies the number of stored values.

If the MedianFilter is used with matrices (Matrix, Vector), the filter algorithm will consider all values in the matrice and will not separate them. For example a 3-tuple of a Vector3 instance will be kept together during processing in the MedianFilter.
If the sort algorithm can not sort the values, they will be left unchanged.

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

Constructor & Destructor Documentation

template<size_t N, typename Tval = double>
eeros::control::MedianFilter< N, Tval >::MedianFilter ( )
inline

Constructs a MedianFilter instance.

Member Function Documentation

template<size_t N, typename Tval = double>
virtual void eeros::control::MedianFilter< N, Tval >::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>
virtual void eeros::control::MedianFilter< N, Tval >::enable ( )
inlinevirtual

Enables the filter.

If enabled, run() will set the output signal value to the median value which results from sorting the current and the past values.

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

Runs the filter algorithm.

Performs the calculation of the filtered output signal value.

Sorts the current and various past input signal values. The median value will be set as output signal value if the MedianFilter 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>
template<size_t No, typename ValT >
std::ostream& operator<< ( std::ostream &  os,
MedianFilter< No, ValT > &  filter 
)
friend

Member Data Documentation

template<size_t N, typename Tval = double>
Tval eeros::control::MedianFilter< N, Tval >::currentMedianValue
protected
template<size_t N, typename Tval = double>
Tval eeros::control::MedianFilter< N, Tval >::currentValues[N] {}
protected
template<size_t N, typename Tval = double>
bool eeros::control::MedianFilter< N, Tval >::enabled {true}
protected
template<size_t N, typename Tval = double>
constexpr int eeros::control::MedianFilter< N, Tval >::medianIndex {static_cast<int>(floor(N/2))}
staticprotected

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