Monado OpenXR Runtime
m_filter_one_euro.c File Reference

The "One Euro Filter" for filtering interaction data. More...

#include "math/m_mathinclude.h"
#include "math/m_vec2.h"
#include "math/m_vec3.h"
#include "util/u_time.h"
#include "util/u_misc.h"
#include "m_filter_one_euro.h"
Include dependency graph for m_filter_one_euro.c:

Functions

static double calc_smoothing_alpha (double Fc, double dt)
 
static double exp_smooth (double alpha, float y, float prev_y)
 
static struct xrt_vec2 exp_smooth_vec2 (double alpha, struct xrt_vec2 y, struct xrt_vec2 prev_y)
 
static struct xrt_vec3 exp_smooth_vec3 (double alpha, struct xrt_vec3 y, struct xrt_vec3 prev_y)
 
static struct xrt_quat exp_smooth_quat (double alpha, struct xrt_quat y, struct xrt_quat prev_y)
 
static void filter_one_euro_init (struct m_filter_one_euro_base *f, double fc_min, double fc_min_d, double beta)
 
static bool filter_one_euro_handle_first_sample (struct m_filter_one_euro_base *f, uint64_t ts, bool commit)
 Is this the first sample? If so, please set up the common things. More...
 
static double filter_one_euro_compute_alpha_d (struct m_filter_one_euro_base *f, double *outDt, uint64_t ts, bool commit)
 Computes and outputs dt, updates the timestamp in the main structure if commit is true, and computes and returns alpha_d. More...
 
static double filter_one_euro_compute_alpha (const struct m_filter_one_euro_base *f, double dt, double smoothed_derivative_magnitude)
 Computes and returns alpha. More...
 
void m_filter_euro_f32_init (struct m_filter_euro_f32 *f, double fc_min, double fc_min_d, double beta)
 
void m_filter_euro_f32_run (struct m_filter_euro_f32 *f, uint64_t ts, const float *in_y, float *out_y)
 
void m_filter_euro_vec2_init (struct m_filter_euro_vec2 *f, double fc_min, double fc_min_d, double beta)
 
void m_filter_euro_vec2_run (struct m_filter_euro_vec2 *f, uint64_t ts, const struct xrt_vec2 *in_y, struct xrt_vec2 *out_y)
 
void m_filter_euro_vec2_run_no_commit (struct m_filter_euro_vec2 *f, uint64_t ts, const struct xrt_vec2 *in_y, struct xrt_vec2 *out_y)
 
void m_filter_euro_vec3_init (struct m_filter_euro_vec3 *f, double fc_min, double fc_min_d, double beta)
 
void m_filter_euro_vec3_run (struct m_filter_euro_vec3 *f, uint64_t ts, const struct xrt_vec3 *in_y, struct xrt_vec3 *out_y)
 
void m_filter_euro_quat_init (struct m_filter_euro_quat *f, double fc_min, double fc_min_d, double beta)
 
void m_filter_euro_quat_run (struct m_filter_euro_quat *f, uint64_t ts, const struct xrt_quat *in_y, struct xrt_quat *out_y)
 

Detailed Description

Function Documentation

◆ filter_one_euro_compute_alpha()

static double filter_one_euro_compute_alpha ( const struct m_filter_one_euro_base f,
double  dt,
double  smoothed_derivative_magnitude 
)
static

Computes and returns alpha.

Parameters
[in]ffilter base structure
dtTime change in seconds
smoothed_derivative_magnitudethe magnitude of the smoothed derivative
Returns
alpha for filtering derivative

References m_filter_one_euro_base::beta, and m_filter_one_euro_base::fc_min.

◆ filter_one_euro_compute_alpha_d()

static double filter_one_euro_compute_alpha_d ( struct m_filter_one_euro_base f,
double *  outDt,
uint64_t  ts,
bool  commit 
)
static

Computes and outputs dt, updates the timestamp in the main structure if commit is true, and computes and returns alpha_d.

Parameters
[in,out]ffilter base structure
[out]outDtpointer where we should put dt (time since last sample) after computing it.
tsdata timestamp
committrue to commit changes to the filter state
Returns
alpha_d for filtering derivative

References m_filter_one_euro_base::prev_ts, and U_TIME_1S_IN_NS.

Referenced by m_filter_euro_f32::m_filter_euro_f32_run(), m_filter_euro_quat::m_filter_euro_quat_run(), m_filter_euro_vec2::m_filter_euro_vec2_run(), m_filter_euro_vec2::m_filter_euro_vec2_run_no_commit(), and m_filter_euro_vec3::m_filter_euro_vec3_run().

◆ filter_one_euro_handle_first_sample()

static bool filter_one_euro_handle_first_sample ( struct m_filter_one_euro_base f,
uint64_t  ts,
bool  commit 
)
static

◆ m_filter_euro_quat_init()

void m_filter_euro_quat_init ( struct m_filter_euro_quat f,
double  fc_min,
double  fc_min_d,
double  beta 
)
Todo:
fix order of args