34 #include "generated/airframe.h"
40 #if SEND_INVARIANT_FILTER
65 #define AHRS_INV_LX 2. * (0.06 + 0.1)
69 #define AHRS_INV_LY 2. * (0.06 + 0.06)
73 #define AHRS_INV_LZ 2. * (0.1 + 0.06)
77 #define AHRS_INV_MX 2. * 0.05 * (0.06 + 0.1)
81 #define AHRS_INV_MY 2. * 0.05 * (0.06 + 0.06)
85 #define AHRS_INV_MZ 2. * 0.05 * (0.1 + 0.06)
89 #define AHRS_INV_N 0.25
93 #define AHRS_INV_O 0.5
102 #define B ahrs_float_inv.mag_h
108 static inline void invariant_model(
float *o,
const float *
x,
const int n,
const float *u,
const int m);
205 #if SEND_INVARIANT_FILTER
240 #define MAG_FROZEN_COUNT 30
247 if (last_mx == mag->
x) {
249 if (mag_frozen_count == 0) {
272 const int m __attribute__((unused)))
275 #pragma GCC diagnostic push // require GCC 4.6
276 #pragma GCC diagnostic ignored "-Wcast-qual"
279 #pragma GCC diagnostic pop // require GCC 4.6
286 if (fabs(s->
as) < 0.1) {
316 memcpy(o, &s_dot, n *
sizeof(
float));
329 if (fabs(_ahrs->
state.
as) < 0.1) {
#define VECT3_CROSS_PRODUCT(_vo, _v1, _v2)
#define VECT3_DOT_PRODUCT(_v1, _v2)
Interface to align the AHRS via low-passed measurements at startup.
#define INV_STATE_DIM
Invariant filter state dimension.
struct VehicleInterface vi
static void orientationSetQuat_f(struct OrientationReps *orientation, struct FloatQuat *quat)
Set vehicle body attitude from quaternion (float).
#define INV_COMMAND_DIM
Invariant filter command vector dimension.
#define VECT3_ADD(_a, _b)
float lx
Tuning parameter of accel and mag on attitude (longitudinal subsystem)
static struct Int32RMat * orientationGetRMat_i(struct OrientationReps *orientation)
Get vehicle body attitude rotation matrix (int).
struct FloatVect3 ME
Correction gains on gyro biases.
float OE
Correction gains on magnetometer sensitivity.
struct OrientationReps body_to_imu
body_to_imu rotation
float n
Tuning parameter of accel and mag on accel bias (scaling subsystem)
struct FloatVect3 accel
Measured accelerometers.
#define FLOAT_QUAT_NORMALIZE(_q)
float o
Tuning parameter of accel and mag on mag bias (scaling subsystem)
void ahrs_float_invariant_init(void)
float mx
Tuning parameter of accel and mag on gyro bias (longitudinal subsystem)
Periodic telemetry system header (includes downlink utility and generated code).
#define QUAT_SMUL(_qo, _qi, _s)
static void float_quat_identity(struct FloatQuat *q)
initialises a quaternion to identity
static void init_invariant_state(void)
struct FloatQuat quat
Estimated attitude (quaternion)
#define VECT3_DIFF(_c, _a, _b)
#define RATES_ASSIGN(_ra, _p, _q, _r)
#define FLOAT_RATES_ZERO(_r)
static void invariant_model(float *o, const float *x, const int n, const float *u, const int m)
Compute dynamic mode.
Invariant filter command vector.
#define RATES_DIFF(_c, _a, _b)
void ahrs_float_invariant_propagate(struct Int32Rates *gyro, float dt)
static const struct FloatVect3 A
struct inv_command cmd
command vector
struct FloatVect3 LE
Correction gains on attitude.
float mz
Tuning parameter of accel and mag on gyro bias (heading subsystem)
float my
Tuning parameter of accel and mag on gyro bias (lateral subsystem)
AHRS using invariant filter.
float ly
Tuning parameter of accel and mag on attitude (lateral subsystem)
#define FLOAT_VECT3_ZERO(_v)
void ahrs_float_inv_set_body_to_imu_quat(struct FloatQuat *q_b2i)
bool_t reset
flag to request reset/reinit the filter
#define RATES_FLOAT_OF_BFP(_rf, _ri)
Paparazzi floating point algebra.
float NE
Correction gains on accel bias.
struct inv_correction_gains corr
correction gains
#define FLOAT_QUAT_NORM2(_q)
static void float_vect_zero(float *a, const int n)
a = 0
#define QUAT_ASSIGN(_q, _i, _x, _y, _z)
struct FloatRates rates
Input gyro rates.
static void ahrs_float_get_quat_from_accel_mag(struct FloatQuat *q, struct Int32Vect3 *accel, struct Int32Vect3 *mag)
void float_quat_vmult(struct FloatVect3 *v_out, struct FloatQuat *q, const struct FloatVect3 *v_in)
rotate 3D vector by quaternion.
static void float_quat_invert(struct FloatQuat *qo, struct FloatQuat *qi)
float lz
Tuning parameter of accel and mag on attitude (heading subsystem)
void ahrs_float_invariant_align(struct Int32Rates *lp_gyro, struct Int32Vect3 *lp_accel, struct Int32Vect3 *lp_mag)
#define ACCELS_FLOAT_OF_BFP(_ef, _ei)
struct FloatVect3 mag
Measured magnetic field.
struct FloatRates bias
Estimated gyro biases.
void float_quat_derivative(struct FloatQuat *qd, struct FloatRates *r, struct FloatQuat *q)
Quaternion derivative from rotational velocity.
#define FLOAT_EULERS_OF_QUAT(_e, _q)
Utility functions for fixed point AHRS implementations.
#define DefaultChannel
SITL.
#define VECT3_SMUL(_vo, _vi, _s)
#define FLOAT_QUAT_EXTRACT(_vo, _qi)
float cs
Estimates magnetometer sensitivity.
void ahrs_float_invariant_update_accel(struct Int32Vect3 *accel)
struct inv_measures meas
measurement vector
void int32_rmat_transp_vmult(struct Int32Vect3 *vb, struct Int32RMat *m_b2a, struct Int32Vect3 *va)
rotate 3D vector by transposed rotation matrix.
#define MAGS_FLOAT_OF_BFP(_ef, _ei)
#define RATES_COPY(_a, _b)
#define QUAT_ADD(_qo, _qi)
struct AhrsFloatInv ahrs_float_inv
Runge-Kutta library (float version)
void int32_rmat_transp_ratemult(struct Int32Rates *rb, struct Int32RMat *m_b2a, struct Int32Rates *ra)
rotate anglular rates by transposed rotation matrix.
struct inv_gains gains
tuning gains
static void error_output(struct AhrsFloatInv *_ins)
Compute correction vectors E = ( ŷ - y ) LE, ME, NE, OE : ( gain matrix * error ) ...
float as
Estimated accelerometer sensitivity.
struct inv_state state
state vector
Paparazzi fixed point algebra.
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.
void ahrs_float_invariant_update_mag(struct Int32Vect3 *mag)
void float_quat_vmul_right(struct FloatQuat *mright, const struct FloatQuat *q, struct FloatVect3 *vi)
Right multiplication by a quaternion.
Invariant filter structure.