13 #error "This header is C++-only." 19 #include <type_traits> 23 namespace implementation {
28 template <
typename Value,
typename Scalar>
struct LowPassIIR 33 std::is_floating_point<Scalar>::value,
34 "Filter is designed only for floating-point values. If " 35 "you want fixed-point, you must reimplement it.");
50 explicit LowPassIIR(Scalar cutoff_hz, Value
const &val) noexcept
58 reset(Value
const &val) noexcept
89 Scalar weighted = dt * weight;
124 : impl_(cutoff_hz, 0)
149 impl_.addSample(sample, timestamp_ns, weight);
167 return impl_.filter_timestamp_ns;
176 return impl_.initialized;
LowPassIIR(Scalar cutoff_hz, Value const &val) noexcept
Constructor.
Definition: t_lowpass.hpp:50
bool initialized
Definition: t_lowpass.hpp:102
LowPassIIRFilter(Scalar cutoff_hz) noexcept
Constructor.
Definition: t_lowpass.hpp:123
A very simple low-pass filter, using a "one-pole infinite impulse response" design (one-pole IIR)...
Definition: t_lowpass.hpp:113
void addSample(Value const &sample, timepoint_ns timestamp_ns, Scalar weight=1)
Filter a sample, with an optional weight.
Definition: t_lowpass.hpp:75
void addSample(Scalar sample, timepoint_ns timestamp_ns, Scalar weight=1)
Filter a sample, with an optional weight.
Definition: t_lowpass.hpp:147
Value state
Definition: t_lowpass.hpp:100
Time-keeping: a clock that is steady, convertible to system time, and ideally high-resolution.
void reset(Value const &val) noexcept
Reset the filter to just-created state.
Definition: t_lowpass.hpp:58
timepoint_ns getTimestampNs() const noexcept
Access the time of last update.
Definition: t_lowpass.hpp:165
int64_t timepoint_ns
Integer timestamp type.
Definition: u_time.h:34
bool isInitialized() const noexcept
Access whether we have initialized state.
Definition: t_lowpass.hpp:174
struct vive_imu_sample sample[3]
Definition: vive_protocol.h:210
timepoint_ns filter_timestamp_ns
Definition: t_lowpass.hpp:103
Scalar getState() const noexcept
Access the filtered value.
Definition: t_lowpass.hpp:156
Definition: t_fusion.hpp:25
Scalar time_constant
Definition: t_lowpass.hpp:101
void reset() noexcept
Reset the filter to just-created state.
Definition: t_lowpass.hpp:132
The shared implementation (between vector and scalar versions) of an IIR low-pass filter...
Definition: t_lowpass.hpp:28