Monado OpenXR Runtime
xrt::auxiliary::math::LowPassIIRFilter< Scalar > Class Template Reference

A very simple low-pass filter, using a "one-pole infinite impulse response" design (one-pole IIR). More...

#include <math/m_lowpass_float.hpp>

Public Member Functions

 LowPassIIRFilter (Scalar cutoff_hz) noexcept
 Constructor. More...
 
void reset () noexcept
 Reset the filter to newly-created state. More...
 
void addSample (Scalar sample, timepoint_ns timestamp_ns, Scalar weight=1)
 Filter a sample, with an optional weight. More...
 
Scalar getState () const noexcept
 Get the filtered value. More...
 
timepoint_ns getTimestampNs () const noexcept
 Get the time of last update. More...
 
bool isInitialized () const noexcept
 Get whether we have initialized state. More...
 

Detailed Description

template<typename Scalar>
class xrt::auxiliary::math::LowPassIIRFilter< Scalar >

A very simple low-pass filter, using a "one-pole infinite impulse response" design (one-pole IIR).

Configurable in scalar type.

Constructor & Destructor Documentation

◆ LowPassIIRFilter()

template<typename Scalar >
xrt::auxiliary::math::LowPassIIRFilter< Scalar >::LowPassIIRFilter ( Scalar  cutoff_hz)
inlineexplicitnoexcept

Constructor.

Parameters
cutoff_hzA cutoff frequency in Hertz: signal changes much lower in frequency will be passed through the filter, while signal changes much higher in frequency will be blocked.

Member Function Documentation

◆ addSample()

template<typename Scalar >
void xrt::auxiliary::math::LowPassIIRFilter< Scalar >::addSample ( Scalar  sample,
timepoint_ns  timestamp_ns,
Scalar  weight = 1 
)
inline

Filter a sample, with an optional weight.

Parameters
sampleThe value to filter
timestamp_nsThe time that this sample was measured.
weightAn optional value between 0 and 1. The smaller this value, the less the current sample influences the filter state. For the first call, this is always assumed to be 1.

◆ getState()

template<typename Scalar >
Scalar xrt::auxiliary::math::LowPassIIRFilter< Scalar >::getState ( ) const
inlinenoexcept

Get the filtered value.

Referenced by m_lowpass_float::m_lowpass_float_get_state().

◆ getTimestampNs()

template<typename Scalar >
timepoint_ns xrt::auxiliary::math::LowPassIIRFilter< Scalar >::getTimestampNs ( ) const
inlinenoexcept

Get the time of last update.

Referenced by m_lowpass_float::m_lowpass_float_get_timestamp_ns().

◆ isInitialized()

template<typename Scalar >
bool xrt::auxiliary::math::LowPassIIRFilter< Scalar >::isInitialized ( ) const
inlinenoexcept

Get whether we have initialized state.

Referenced by m_lowpass_float::m_lowpass_float_is_initialized().

◆ reset()

template<typename Scalar >
void xrt::auxiliary::math::LowPassIIRFilter< Scalar >::reset ( )
inlinenoexcept

Reset the filter to newly-created state.

References xrt::auxiliary::math::detail::LowPassIIR< Value, Scalar >::reset().


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