SoftFilters  0.1.0
Arduino framework and library of software data filters.
WeightedUpdateFilter< IN_T, OUT_T, INTERNAL_T > Class Template Reference

A filter that updates the output based on a weighted average between its previous output and the current input. More...

#include <SoftFilters.h>

Inheritance diagram for WeightedUpdateFilter< IN_T, OUT_T, INTERNAL_T >:
Collaboration diagram for WeightedUpdateFilter< IN_T, OUT_T, INTERNAL_T >:

Public Member Functions

 WeightedUpdateFilter (double w)
 
virtual bool update (void const *const input) override
 Internally update the filter output based on the given input. More...
 
- Public Member Functions inherited from Filter
bool push (void const *const input, void *const output)
 Push a new data through the filter. More...
 

Protected Attributes

INTERNAL_T internal_result
 representing the result in internal type in case the output type does not have the required precision
 
- Protected Attributes inherited from BaseFilter< IN_T, OUT_T >
OUT_T out_val
 Internally managed storage of the output value.
 

Private Attributes

INTERNAL_T sensitivity
 
INTERNAL_T innertia
 
bool seen_first
 

Additional Inherited Members

- Protected Member Functions inherited from BaseFilter< IN_T, OUT_T >
virtual void const *const get_output_val_ptr () final
 Push a new data through the filter. More...
 
virtual void copy_to_client (void *const output) final
 Copy the output to client memory.
 

Detailed Description

template<typename IN_T, typename OUT_T, typename INTERNAL_T = double>
class WeightedUpdateFilter< IN_T, OUT_T, INTERNAL_T >

A filter that updates the output based on a weighted average between its previous output and the current input.

Mathematically, let \(w\) be the sensitivity (weight of the input), \(1-w\) be the innertia (weight of the previous output), \(u_i\) be the \(i\)-th input, and \(v_i\) be the \(i\)-th output. Then

\begin{aligned} v_0 &= u_0 \\ v_i &= w \, u_i + (1 - w) \, v_{i-1} \;\;\;\;\text{for}\; i>0, w\in[0,1] \end{aligned}

Member Function Documentation

◆ update()

template<typename IN_T , typename OUT_T , typename INTERNAL_T = double>
virtual bool WeightedUpdateFilter< IN_T, OUT_T, INTERNAL_T >::update ( void const *const  input)
inlineoverridevirtual

Internally update the filter output based on the given input.

This method behaves similarly to the public Filter::push method, but without copying the output to the client memory. This method is for internal workings of the filter framework.

Implements Filter.


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