Monado OpenXR Runtime
xrt::auxiliary::math::detail::LowPassIIR< Value, Scalar > Struct Template Reference

The shared implementation (between vector and scalar versions) of an IIR low-pass filter. More...

#include <math/m_lowpass_float.hpp>

Collaboration diagram for xrt::auxiliary::math::detail::LowPassIIR< Value, Scalar >:

Public Member Functions

 LowPassIIR (Scalar cutoff_hz, Value const &val) noexcept
 Constructor. More...
 
void reset (Value const &val) noexcept
 Reset the filter to newly-created state. More...
 
void addSample (Value const &sample, timepoint_ns timestamp_ns, Scalar weight=1)
 Filter a sample, with an optional weight. More...
 

Data Fields

Value state
 
Scalar time_constant
 
bool initialized {false}
 
timepoint_ns filter_timestamp_ns {0}
 

Detailed Description

template<typename Value, typename Scalar>
struct xrt::auxiliary::math::detail::LowPassIIR< Value, Scalar >

The shared implementation (between vector and scalar versions) of an IIR low-pass filter.

Constructor & Destructor Documentation

◆ LowPassIIR()

template<typename Value , typename Scalar >
xrt::auxiliary::math::detail::LowPassIIR< Value, Scalar >::LowPassIIR ( Scalar  cutoff_hz,
Value const &  val 
)
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.
valThe value to initialize the filter with. Does not affect the filter itself: only seen if you get state before initializing the filter with the first sample.

Member Function Documentation

◆ addSample()

template<typename Value , typename Scalar >
void xrt::auxiliary::math::detail::LowPassIIR< Value, Scalar >::addSample ( Value const &  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.
Todo:
limit max dt?

◆ reset()

template<typename Value , typename Scalar >
void xrt::auxiliary::math::detail::LowPassIIR< Value, Scalar >::reset ( Value const &  val)
inlinenoexcept

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