30#ifndef AHRS_FLOAT_UTILS_H
31#define AHRS_FLOAT_UTILS_H
44 const float phi =
atan2f(-accel->
y, -accel->
z);
45 const float cphi =
cosf(phi);
46 const float theta =
atan2f(cphi * accel->
x, -accel->
z);
50 const float sphi =
sinf(phi);
51 const float ctheta =
cosf(theta);
52 const float stheta =
sinf(theta);
53 const float mn = ctheta * mag->
x + sphi * stheta * mag->
y + cphi * stheta * mag->
z;
54 const float me = 0. * mag->
x + cphi * mag->
y - sphi * mag->
z;
static void ahrs_float_get_quat_from_accel_mag(struct FloatQuat *q, struct FloatVect3 *accel, struct FloatVect3 *mag)
static void ahrs_float_get_euler_from_accel_mag(struct FloatEulers *e, struct FloatVect3 *accel, struct FloatVect3 *mag)
Computer orientation in euler angles from accel and mag This is not working when the IMU is upside-do...
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.
static void float_quat_normalize(struct FloatQuat *q)
void float_quat_comp_norm_shortest(struct FloatQuat *a2c, struct FloatQuat *a2b, struct FloatQuat *b2c)
Composition (multiplication) of two quaternions with normalization.
void float_rmat_of_quat(struct FloatRMat *rm, struct FloatQuat *q)
void float_rmat_transp_vmult(struct FloatVect3 *vb, struct FloatRMat *m_b2a, struct FloatVect3 *va)
rotate 3D vector by transposed rotation matrix.
static void float_vect3_normalize(struct FloatVect3 *v)
normalize 3D vector in place
#define QUAT_ASSIGN(_q, _i, _x, _y, _z)
#define EULERS_ASSIGN(_e, _phi, _theta, _psi)
Paparazzi floating point algebra.