Monado OpenXR Runtime
Public Member Functions | Data Fields
xrt_fusion::implementation::LowPassIIR< Value, Scalar > Struct Template Reference

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

#include <tracking/t_lowpass.hpp>

Public Member Functions

 LowPassIIR (Scalar cutoff_hz, Value const &val) noexcept
 Constructor. More...
 
void reset (Value const &val) noexcept
 Reset the filter to just-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_fusion::implementation::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_fusion::implementation::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 access state before initializing the filter with the first sample.

Member Function Documentation

◆ addSample()

template<typename Value, typename Scalar>
void xrt_fusion::implementation::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_fusion::implementation::LowPassIIR< Value, Scalar >::reset ( Value const &  val)
inlinenoexcept

Reset the filter to just-created state.

Referenced by xrt_fusion::LowPassIIRVectorFilter< 3, double >::reset().


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