Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
1e_filter.h File Reference

Implementation of the 1 euro filter. More...

#include "std.h"
#include <math.h>
+ Include dependency graph for 1e_filter.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  OneEuroLPFilter
 simple low pass filter. More...
 
struct  OneEuroFilter
 configuration parameters. More...
 

Functions

static void init_1e_filter (struct OneEuroFilter *filter, float rate, float mincutoff, float beta, float dcutoff)
 Initialize a 1 Euro Filter instance. More...
 
static void reset_1e_filter (struct OneEuroFilter *filter)
 Reset filter (gains and parameters unchanged) More...
 
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. More...
 
static float compute_1e_filter_alpha (struct OneEuroFilter *filter, float cutoff)
 Compute Alpha for a given One Euro Filter and a given cutoff frequency. More...
 
static float update_1e_filter (struct OneEuroFilter *filter, float x)
 Filter a float using the given One Euro Filter. More...
 
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. More...
 

Detailed Description

Implementation of the 1 euro filter.

See: http://cristal.univ-lille.fr/~casiez/1euro/

Ref: Casiez, G., Roussel, N. and Vogel, D. (2012). 1€ Filter: A Simple Speed-based Low-pass Filter for Noisy Input in Interactive Systems. Proceedings of the ACM Conference on Human Factors in Computing Systems (CHI '12). Austin, Texas (May 5-12, 2012). New York: ACM Press, pp. 2527-2530.

Definition in file 1e_filter.h.


Data Structure Documentation

◆ OneEuroLPFilter

struct OneEuroLPFilter

simple low pass filter.

TODO use existing implementation ?

Definition at line 42 of file 1e_filter.h.

Data Fields
bool first_time
float hatx
float hatxprev

◆ OneEuroFilter

struct OneEuroFilter

configuration parameters.

Definition at line 51 of file 1e_filter.h.

+ Collaboration diagram for OneEuroFilter:
Data Fields
float beta cutoff slope
float dcutoff derivative cutoff freq (in Hz)
struct OneEuroLPFilter dxfilt low pass filter for derivative
bool first_time first time flag
uint32_t last_time last update time in ms
float mincutoff min cutoff freq (in Hz)
float rate data update rate (in Hz)
struct OneEuroLPFilter xfilt low pass filter

Function Documentation

◆ compute_1e_filter_alpha()

static float compute_1e_filter_alpha ( struct OneEuroFilter filter,
float  cutoff 
)
inlinestatic

Compute Alpha for a given One Euro Filter and a given cutoff frequency.

Definition at line 113 of file 1e_filter.h.

References OneEuroFilter::rate.

Referenced by update_1e_filter().

+ Here is the caller graph for this function:

◆ compute_1e_filter_lp()

static float compute_1e_filter_lp ( struct OneEuroLPFilter filter,
float  x,
float  alpha 
)
inlinestatic

Filter a float using the given low-pass filter and the given alpha value.

Definition at line 99 of file 1e_filter.h.

References alpha, OneEuroLPFilter::first_time, OneEuroLPFilter::hatx, and OneEuroLPFilter::hatxprev.

Referenced by update_1e_filter().

+ Here is the caller graph for this function:

◆ init_1e_filter()

static void init_1e_filter ( struct OneEuroFilter filter,
float  rate,
float  mincutoff,
float  beta,
float  dcutoff 
)
inlinestatic

◆ reset_1e_filter()

static void reset_1e_filter ( struct OneEuroFilter filter)
inlinestatic

Reset filter (gains and parameters unchanged)

Definition at line 84 of file 1e_filter.h.

References OneEuroFilter::dxfilt, OneEuroLPFilter::first_time, OneEuroFilter::first_time, OneEuroLPFilter::hatx, OneEuroLPFilter::hatxprev, OneEuroFilter::last_time, and OneEuroFilter::xfilt.

Referenced by filter_1euro_imu_reset().

+ Here is the caller graph for this function:

◆ update_1e_filter()

static float update_1e_filter ( struct OneEuroFilter filter,
float  x 
)
inlinestatic

Filter a float using the given One Euro Filter.

Definition at line 124 of file 1e_filter.h.

References OneEuroFilter::beta, compute_1e_filter_alpha(), compute_1e_filter_lp(), OneEuroFilter::dcutoff, OneEuroFilter::dxfilt, OneEuroFilter::first_time, OneEuroLPFilter::hatxprev, OneEuroFilter::mincutoff, OneEuroFilter::rate, and OneEuroFilter::xfilt.

Referenced by accel_cb(), gyro_cb(), and update_1e_filter_at_time().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update_1e_filter_at_time()

static float update_1e_filter_at_time ( struct OneEuroFilter filter,
float  x,
uint32_t  timestamp 
)
inlinestatic

Filter a float using the given One Euro Filter and the given timestamp.

Frequency will be automatically recomputed.

Definition at line 142 of file 1e_filter.h.

References OneEuroFilter::last_time, OneEuroFilter::rate, and update_1e_filter().

Referenced by accel_cb(), and gyro_cb().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: