|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
30 #include "generated/airframe.h"
34 #ifndef AHRS_MADGWICK_BETA
35 #define AHRS_MADGWICK_BETA 0.1f // 2 * proportional gain
119 const float s0 = _4q0 * q2q2 + _2q2 * a.
x + _4q0 * q1q1 - _2q1 * a.
y;
120 const float s1 = _4q1 * q3q3 - _2q3 * a.
x + 4.0f * q0q0 * q1 - _2q0 * a.
y - _4q1 + _8q1 * q1q1 + _8q1 * q2q2 + _4q1 * a.
z;
121 const float s2 = 4.0f * q0q0 * q2 + _2q0 * a.
x + _4q2 * q3q3 - _2q3 * a.
y - _4q2 + _8q2 * q1q1 + _8q2 * q2q2 + _4q2 * a.
z;
122 const float s3 = 4.0f * q1q1 * q3 - _2q1 * a.
x + 4.0f * q2q2 * q3 - _2q2 * a.
y;
126 qdot.
qi -= s0 * beta_inv_grad_norm;
127 qdot.
qx -=
s1 * beta_inv_grad_norm;
128 qdot.
qy -=
s2 * beta_inv_grad_norm;
129 qdot.
qz -=
s3 * beta_inv_grad_norm;
void ahrs_madgwick_init(void)
void ahrs_madgwick_set_body_to_imu_quat(struct FloatQuat *q_b2i)
static void float_quat_identity(struct FloatQuat *q)
initialises a quaternion to identity
#define FLOAT_RATES_ZERO(_r)
void ahrs_madgwick_update_accel(struct FloatVect3 *accel)
struct FloatRates bias
Gyro bias (from alignment)
#define VECT3_SDIV(_vo, _vi, _s)
Paparazzi floating point algebra.
struct AhrsMadgwick ahrs_madgwick
static struct FloatRMat * orientationGetRMat_f(struct OrientationReps *orientation)
Get vehicle body attitude rotation matrix (float).
static float float_vect3_norm(struct FloatVect3 *v)
struct FloatQuat quat
Estimated attitude (quaternion)
static void init_state(void)
#define RATES_DIFF(_c, _a, _b)
#define FLOAT_VECT3_ZERO(_v)
static void orientationSetQuat_f(struct OrientationReps *orientation, struct FloatQuat *quat)
Set vehicle body attitude from quaternion (float).
bool is_aligned
aligned flag
static void float_quat_normalize(struct FloatQuat *q)
uint16_t f
Camera baseline, in meters (i.e. horizontal distance between the two cameras of the stereo setup)
void ahrs_madgwick_align(struct FloatRates *lp_gyro, struct FloatVect3 *lp_accel)
struct OrientationReps body_to_imu
body_to_imu rotation
bool reset
flag to request reset/reinit the filter
static void ahrs_float_get_quat_from_accel(struct FloatQuat *q, struct FloatVect3 *accel)
Compute a quaternion representing roll and pitch from an accelerometer measurement.
void float_quat_derivative(struct FloatQuat *qd, struct FloatRates *r, struct FloatQuat *q)
Quaternion derivative from rotational velocity.
struct FloatRates rates
Measured gyro rates.
#define AHRS_MADGWICK_BETA
struct FloatVect3 accel
Measured accelerometers.
void float_rmat_transp_ratemult(struct FloatRates *rb, struct FloatRMat *m_b2a, struct FloatRates *ra)
rotate anglular rates by transposed rotation matrix.
void ahrs_madgwick_propagate(struct FloatRates *gyro, float dt)
Madgwick filter structure.