33 #include "generated/airframe.h"
39 #if SEND_INVARIANT_FILTER
64 #define AHRS_INV_LX 2. * (0.06 + 0.1)
68 #define AHRS_INV_LY 2. * (0.06 + 0.06)
72 #define AHRS_INV_LZ 2. * (0.1 + 0.06)
76 #define AHRS_INV_MX 2. * 0.05 * (0.06 + 0.1)
80 #define AHRS_INV_MY 2. * 0.05 * (0.06 + 0.06)
84 #define AHRS_INV_MZ 2. * 0.05 * (0.1 + 0.06)
88 #define AHRS_INV_N 0.25
92 #define AHRS_INV_O 0.5
98 static const struct FloatVect3 A = { 0.f, 0.f, -9.81f };
101 #define B ahrs_float_inv.mag_h
107 static inline void invariant_model(
float *o,
const float *
x,
const int n,
const float *u,
const int m);
199 #if SEND_INVARIANT_FILTER
234 #define MAG_FROZEN_COUNT 30
241 if (last_mx == mag->
x) {
243 if (mag_frozen_count == 0) {
261 static inline void invariant_model(
float *o,
const float *x,
const int n,
const float *u,
262 const int m __attribute__((unused)))
265 #pragma GCC diagnostic push
266 #pragma GCC diagnostic ignored "-Wcast-qual"
269 #pragma GCC diagnostic pop
276 if (fabs(
s->as) < 0.1) {
306 memcpy(o, &s_dot, n *
sizeof(
float));
319 if (fabs(_ahrs->
state.
as) < 0.1) {
struct AhrsFloatInv ahrs_float_inv
void float_quat_vmul_right(struct FloatQuat *mright, const struct FloatQuat *q, struct FloatVect3 *vi)
Right multiplication by a quaternion.
void ahrs_float_invariant_align(struct FloatRates *lp_gyro, struct FloatVect3 *lp_accel, struct FloatVect3 *lp_mag)
static void init_invariant_state(void)
static const struct FloatVect3 A
static void error_output(struct AhrsFloatInv *_ins)
Compute correction vectors E = ( ŷ - y ) LE, ME, NE, OE : ( gain matrix * error )
static void invariant_model(float *o, const float *x, const int n, const float *u, const int m)
Compute dynamic mode.
void ahrs_float_invariant_init(void)
void ahrs_float_invariant_propagate(struct FloatRates *gyro, float dt)
void ahrs_float_invariant_update_accel(struct FloatVect3 *accel)
void ahrs_float_invariant_update_mag(struct FloatVect3 *mag)
AHRS using invariant filter.
#define INV_STATE_DIM
Invariant filter state dimension.
struct inv_measures meas
measurement vector
#define INV_COMMAND_DIM
Invariant filter command vector dimension.
struct inv_command cmd
command vector
bool reset
flag to request reset/reinit the filte
struct inv_correction_gains corr
correction gains
struct inv_gains gains
tuning gains
struct inv_state state
state vector
Invariant filter structure.
static void ahrs_float_get_quat_from_accel_mag(struct FloatQuat *q, struct FloatVect3 *accel, struct FloatVect3 *mag)
Utility functions for fixed point AHRS implementations.
static void float_quat_normalize(struct FloatQuat *q)
static void float_quat_identity(struct FloatQuat *q)
initialises a quaternion to identity
static void float_vect_zero(float *a, const int n)
a = 0
#define FLOAT_QUAT_EXTRACT(_vo, _qi)
#define FLOAT_VECT3_ZERO(_v)
void float_quat_vmult(struct FloatVect3 *v_out, struct FloatQuat *q, const struct FloatVect3 *v_in)
rotate 3D vector by quaternion.
#define FLOAT_QUAT_NORM2(_q)
void float_eulers_of_quat(struct FloatEulers *e, struct FloatQuat *q)
euler rotation 'ZYX'
static void float_quat_invert(struct FloatQuat *qo, struct FloatQuat *qi)
#define FLOAT_RATES_ZERO(_r)
void float_quat_derivative(struct FloatQuat *qd, struct FloatRates *r, struct FloatQuat *q)
Quaternion derivative from rotational velocity.
#define RATES_COPY(_a, _b)
#define RATES_ASSIGN(_ra, _p, _q, _r)
#define VECT3_CROSS_PRODUCT(_vo, _v1, _v2)
#define VECT3_SMUL(_vo, _vi, _s)
#define VECT3_COPY(_a, _b)
#define QUAT_ASSIGN(_q, _i, _x, _y, _z)
#define RATES_DIFF(_c, _a, _b)
#define VECT3_DIFF(_c, _a, _b)
#define VECT3_ADD(_a, _b)
#define QUAT_SMUL(_qo, _qi, _s)
#define QUAT_ADD(_qo, _qi)
#define VECT3_DOT_PRODUCT(_v1, _v2)
float lx
Tuning parameter of accel and mag on attitude (longitudinal subsystem)
float o
Tuning parameter of accel and mag on mag bias (scaling subsystem)
float n
Tuning parameter of accel and mag on accel bias (scaling subsystem)
float mz
Tuning parameter of accel and mag on gyro bias (heading subsystem)
struct FloatRates bias
Estimated gyro biases.
float OE
Correction gains on magnetometer sensitivity.
float ly
Tuning parameter of accel and mag on attitude (lateral subsystem)
struct FloatVect3 LE
Correction gains on attitude.
float lz
Tuning parameter of accel and mag on attitude (heading subsystem)
struct FloatVect3 ME
Correction gains on gyro biases.
float as
Estimated accelerometer sensitivity.
float cs
Estimates magnetometer sensitivity.
struct FloatVect3 mag
Measured magnetic field.
struct FloatQuat quat
Estimated attitude (quaternion)
float NE
Correction gains on accel bias.
struct FloatRates rates
Input gyro rates.
float mx
Tuning parameter of accel and mag on gyro bias (longitudinal subsystem)
struct FloatVect3 accel
Measured accelerometers.
float my
Tuning parameter of accel and mag on gyro bias (lateral subsystem)
Invariant filter command vector.
Paparazzi floating point algebra.
Paparazzi fixed point algebra.
Runge-Kutta library (float version)
static void runge_kutta_4_float(float *xo, const float *x, const int n, const float *u, const int m, void(*f)(float *o, const float *x, const int n, const float *u, const int m), const float dt)
Fourth-Order Runge-Kutta.
Periodic telemetry system header (includes downlink utility and generated code).
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.