32 #ifndef ONE_EURO_FILTER_H
33 #define ONE_EURO_FILTER_H
115 float tau = 1.0f / (2.f * M_PI * cutoff);
116 float te = 1.0f / filter->
rate;
117 return 1.0f / (1.0f + tau / te);
134 float cutoff = filter->
mincutoff + filter->
beta * fabsf(edx);
145 filter->
rate = 1e6f / (float)(timestamp - filter->
last_time);
float mincutoff
min cutoff freq (in Hz)
static float compute_1e_filter_lp(struct OneEuroLPFilter *filter, float x, float alpha)
Filter a float using the given low-pass filter and the given alpha value.
static float update_1e_filter_at_time(struct OneEuroFilter *filter, float x, uint32_t timestamp)
Filter a float using the given One Euro Filter and the given timestamp.
bool first_time
first time flag
struct OneEuroLPFilter xfilt
low pass filter
float dcutoff
derivative cutoff freq (in Hz)
static void reset_1e_filter(struct OneEuroFilter *filter)
Reset filter (gains and parameters unchanged)
static void init_1e_filter(struct OneEuroFilter *filter, float rate, float mincutoff, float beta, float dcutoff)
Initialize a 1 Euro Filter instance.
struct OneEuroLPFilter dxfilt
low pass filter for derivative
uint32_t last_time
last update time in ms
static float compute_1e_filter_alpha(struct OneEuroFilter *filter, float cutoff)
Compute Alpha for a given One Euro Filter and a given cutoff frequency.
static float update_1e_filter(struct OneEuroFilter *filter, float x)
Filter a float using the given One Euro Filter.
float rate
data update rate (in Hz)
configuration parameters.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.