ros2_control - rolling
Loading...
Searching...
No Matches
Public Member Functions | List of all members
control_toolbox::LowPassFilter< T > Class Template Reference

A Low-pass filter class. More...

#include <low_pass_filter.hpp>

Public Member Functions

 LowPassFilter (double sampling_frequency, double damping_frequency, double damping_intensity)
 
 ~LowPassFilter ()
 Destructor of LowPassFilter class.
 
bool configure ()
 Configure the LowPassFilter (access and process params).
 
bool configure (const T &initial_state)
 Configure the LowPassFilter and initialize its internal state.
 
bool update (const T &data_in, T &data_out)
 Applies one iteration of the IIR filter.
 
bool is_configured () const
 
void set_params (double sampling_frequency, double damping_frequency, double damping_intensity)
 Internal computation of the feedforward and feedbackward coefficients according to the LowPassFilter parameters.
 

Detailed Description

template<typename T>
class control_toolbox::LowPassFilter< T >

A Low-pass filter class.

This class implements a low-pass filter for various data types based on an Infinite Impulse Response Filter. For vector elements, the filtering is applied separately on each element of the vector.

In particular, this class implements a simplified version of an IIR filter equation :

\(y(n) = b x(n-1) + a y(n-1)\)

where:

and the Low-Pass coefficient equation:

where:

Usage

For manual instantiation, you should first call configure() (in non-realtime) and then call update() at every update step.

Member Function Documentation

◆ configure() [1/2]

template<typename T >
bool control_toolbox::LowPassFilter< T >::configure ( )

Configure the LowPassFilter (access and process params).

The internal state is left uninitialized, so that the filter is initialized with the input of the first update() call.

Returns
true

◆ configure() [2/2]

template<typename T >
bool control_toolbox::LowPassFilter< T >::configure ( const T &  initial_state)

Configure the LowPassFilter and initialize its internal state.

In contrast to configure(), the filter starts from initial_state instead of from the input of the first update() call. The first update() therefore returns the stored signal values from initial_state, and the filter converges towards the input from there (metadata, if any, is still taken from the update() input).

Parameters
initial_stateInitial state of the filter
Returns
false if initial_state is not finite, leaving the filter unchanged, true otherwise

◆ update()

template<typename T >
bool control_toolbox::LowPassFilter< T >::update ( const T &  data_in,
T &  data_out 
)

Applies one iteration of the IIR filter.

Parameters
data_ininput to the filter
data_outfiltered output
Returns
false if filter is not configured, true otherwise

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