Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
ahrs_float_mlkf.c File Reference

Multiplicative linearized Kalman Filter in quaternion formulation. More...

#include "modules/ahrs/ahrs_float_mlkf.h"
#include "modules/ahrs/ahrs_float_utils.h"
#include <string.h>
#include "math/pprz_algebra_float.h"
#include "math/pprz_algebra_int.h"
#include "math/pprz_simple_matrix.h"
#include "generated/airframe.h"
Include dependency graph for ahrs_float_mlkf.c:

Go to the source code of this file.

Macros

#define AHRS_MAG_NOISE_X   0.2
#define AHRS_MAG_NOISE_Y   0.2
#define AHRS_MAG_NOISE_Z   0.2

Functions

static void propagate_ref (struct FloatRates *gyro, float dt)
static void propagate_state (float dt)
 Progagate filter's covariance We don't propagate state as we assume to have reseted.
static void update_state (const struct FloatVect3 *i_expected, struct FloatVect3 *b_measured, struct FloatVect3 *noise)
 Incorporate one 3D vector measurement.
static void update_state_heading (const struct FloatVect3 *i_expected, struct FloatVect3 *b_measured, struct FloatVect3 *noise)
 Incorporate one 3D vector measurement, only correcting heading.
static void reset_state (void)
 Incorporate errors to reference and zeros state.
void ahrs_mlkf_init (void)
bool ahrs_mlkf_align (struct FloatRates *lp_gyro, struct FloatVect3 *lp_accel, struct FloatVect3 *lp_mag)
void ahrs_mlkf_propagate (struct FloatRates *gyro, float dt)
void ahrs_mlkf_update_accel (struct FloatVect3 *accel)
void ahrs_mlkf_update_mag (struct FloatVect3 *mag)
void ahrs_mlkf_update_mag_2d (struct FloatVect3 *mag)
void ahrs_mlkf_update_mag_full (struct FloatVect3 *mag)

Variables

struct AhrsMlkf ahrs_mlkf

Detailed Description

Multiplicative linearized Kalman Filter in quaternion formulation.

Estimate the attitude, heading and gyro bias.

Definition in file ahrs_float_mlkf.c.

Macro Definition Documentation

◆ AHRS_MAG_NOISE_X

#define AHRS_MAG_NOISE_X   0.2

Definition at line 44 of file ahrs_float_mlkf.c.

Referenced by ahrs_mlkf_init().

◆ AHRS_MAG_NOISE_Y

#define AHRS_MAG_NOISE_Y   0.2

Definition at line 45 of file ahrs_float_mlkf.c.

Referenced by ahrs_mlkf_init().

◆ AHRS_MAG_NOISE_Z

#define AHRS_MAG_NOISE_Z   0.2

Definition at line 46 of file ahrs_float_mlkf.c.

Referenced by ahrs_mlkf_init().

Function Documentation

◆ ahrs_mlkf_align()

bool ahrs_mlkf_align ( struct FloatRates * lp_gyro,
struct FloatVect3 * lp_accel,
struct FloatVect3 * lp_mag )

Definition at line 91 of file ahrs_float_mlkf.c.

References ahrs_float_get_quat_from_accel_mag(), ahrs_mlkf, and AhrsMlkf::lp_accel.

Referenced by aligner_cb().

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

◆ ahrs_mlkf_init()

void ahrs_mlkf_init ( void )

Definition at line 62 of file ahrs_float_mlkf.c.

References AHRS_MAG_NOISE_X, AHRS_MAG_NOISE_Y, AHRS_MAG_NOISE_Z, ahrs_mlkf, float_quat_identity(), FLOAT_RATES_ZERO, and VECT3_ASSIGN.

Referenced by ahrs_mlkf_wrapper_init().

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

◆ ahrs_mlkf_propagate()

void ahrs_mlkf_propagate ( struct FloatRates * gyro,
float dt )

Definition at line 106 of file ahrs_float_mlkf.c.

References propagate_ref(), and propagate_state().

Referenced by gyro_cb().

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

◆ ahrs_mlkf_update_accel()

void ahrs_mlkf_update_accel ( struct FloatVect3 * accel)

Definition at line 112 of file ahrs_float_mlkf.c.

References ahrs_mlkf, alpha, dn, float_vect3_norm(), reset_state(), and update_state().

Referenced by accel_cb().

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

◆ ahrs_mlkf_update_mag()

void ahrs_mlkf_update_mag ( struct FloatVect3 * mag)

Definition at line 125 of file ahrs_float_mlkf.c.

References ahrs_mlkf_update_mag_2d(), and ahrs_mlkf_update_mag_full().

Referenced by mag_cb().

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

◆ ahrs_mlkf_update_mag_2d()

void ahrs_mlkf_update_mag_2d ( struct FloatVect3 * mag)

Definition at line 134 of file ahrs_float_mlkf.c.

References ahrs_mlkf, reset_state(), and update_state_heading().

Referenced by ahrs_mlkf_update_mag().

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

◆ ahrs_mlkf_update_mag_full()

void ahrs_mlkf_update_mag_full ( struct FloatVect3 * mag)

Definition at line 140 of file ahrs_float_mlkf.c.

References ahrs_mlkf, reset_state(), and update_state().

Referenced by ahrs_mlkf_update_mag().

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

◆ propagate_ref()

void propagate_ref ( struct FloatRates * gyro,
float dt )
inlinestatic

Definition at line 147 of file ahrs_float_mlkf.c.

References ahrs_mlkf, alpha, float_quat_integrate(), FLOAT_RATES_LIN_CMB, RATES_COPY, and RATES_SUB.

Referenced by ahrs_mlkf_propagate().

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

◆ propagate_state()

void propagate_state ( float dt)
inlinestatic

Progagate filter's covariance We don't propagate state as we assume to have reseted.

Definition at line 172 of file ahrs_float_mlkf.c.

References ahrs_mlkf, MAT_MUL, and MAT_MUL_T.

Referenced by ahrs_mlkf_propagate().

Here is the caller graph for this function:

◆ reset_state()

void reset_state ( void )
inlinestatic

Incorporate errors to reference and zeros state.

Definition at line 341 of file ahrs_float_mlkf.c.

References ahrs_mlkf, float_quat_comp(), float_quat_identity(), and float_quat_normalize().

Referenced by ahrs_mlkf_update_accel(), ahrs_mlkf_update_mag_2d(), and ahrs_mlkf_update_mag_full().

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

◆ update_state()

void update_state ( const struct FloatVect3 * i_expected,
struct FloatVect3 * b_measured,
struct FloatVect3 * noise )
inlinestatic

Incorporate one 3D vector measurement.

Parameters
i_expectedexpected 3d vector in inertial frame
b_measuredmeasured 3d vector in body/imu frame
noisemeasurement noise vector (diagonal of covariance)

Definition at line 206 of file ahrs_float_mlkf.c.

References ahrs_mlkf, float_quat_vmult(), H, K, MAT_INV33, MAT_MUL, MAT_MUL_T, MAT_SUB, VECT3_DIFF, FloatVect3::x, FloatVect3::y, and FloatVect3::z.

Referenced by ahrs_mlkf_update_accel(), and ahrs_mlkf_update_mag_full().

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

◆ update_state_heading()

void update_state_heading ( const struct FloatVect3 * i_expected,
struct FloatVect3 * b_measured,
struct FloatVect3 * noise )
inlinestatic

Incorporate one 3D vector measurement, only correcting heading.

Parameters
i_expectedexpected 3d vector in inertial frame
b_measuredmeasured 3d vector in body/imu frame
noisemeasurement noise vector (diagonal of covariance) TODO: optimize

Definition at line 274 of file ahrs_float_mlkf.c.

References ahrs_mlkf, float_quat_vmult(), H, K, MAT_INV33, MAT_MUL, MAT_MUL_T, MAT_SUB, VECT3_DIFF, FloatVect3::x, FloatVect3::y, and FloatVect3::z.

Referenced by ahrs_mlkf_update_mag_2d().

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

Variable Documentation

◆ ahrs_mlkf