36 #include "generated/airframe.h"
39 #define FACE_REINJ_1 1024
42 #ifndef AHRS_MAG_OFFSET
43 #define AHRS_MAG_OFFSET 0.
55 #define PI_INTEG_EULER (INT32_ANGLE_PI * F_UPDATE)
56 #define TWO_PI_INTEG_EULER (INT32_ANGLE_2_PI * F_UPDATE)
57 #define INTEG_EULER_NORMALIZE(_a) { \
58 while (_a > PI_INTEG_EULER) _a -= TWO_PI_INTEG_EULER; \
59 while (_a < -PI_INTEG_EULER) _a += TWO_PI_INTEG_EULER; \
104 #define NOISE_FILTER_GAIN 50
112 if (diff.
p < -threshold || diff.
p > threshold ||
113 diff.
q < -threshold || diff.
q > threshold ||
114 diff.
r < -threshold || diff.
r > threshold) {
120 #define RATE_CUT_THRESHOLD RATE_BFP_OF_REAL(1)
126 if (diff.x < -threshold || diff.x > threshold ||
127 diff.y < -threshold || diff.y > threshold ||
128 diff.z < -threshold || diff.z > threshold) {
136 #define ACCEL_CUT_THRESHOLD ACCEL_BFP_OF_REAL(20)
161 static struct Int32Rates last_uf_rate = { 0, 0, 0 };
162 if (!cut_rates(uf_rate, last_uf_rate, RATE_CUT_THRESHOLD)) {
205 #if USE_NOISE_CUT || USE_NOISE_FILTER
206 static struct Int32Vect3 last_accel = { 0, 0, 0 };
209 if (!cut_accel(*accel, last_accel, ACCEL_CUT_THRESHOLD)) {
266 const int32_t mn = ctheta * mag->x + sphi_stheta * mag->y + cphi_stheta * mag->z;
267 const int32_t me = 0 * mag->x + cphi * mag->y - sphi * mag->z;
272 float m_psi = -atan2(me, mn);
int32_t psi
in rad with INT32_ANGLE_FRAC
#define RATES_SDIV(_ro, _ri, _s)
void ahrs_ice_set_body_to_imu(struct OrientationReps *body_to_imu)
struct Int32Eulers ltp_to_imu_euler
static void orientationSetQuat_f(struct OrientationReps *orientation, struct FloatQuat *quat)
Set vehicle body attitude from quaternion (float).
void ahrs_ice_propagate(struct Int32Rates *gyro)
static void get_phi_theta_measurement_fom_accel(int32_t *phi_meas, int32_t *theta_meas, struct Int32Vect3 *accel)
Complementary filter in euler representation (fixed-point).
#define RATES_ADD(_a, _b)
int32_t theta
in rad with INT32_ANGLE_FRAC
#define INTEG_EULER_NORMALIZE(_a)
#define INT_RATES_ZERO(_e)
static struct Int32Eulers * orientationGetEulers_i(struct OrientationReps *orientation)
Get vehicle body attitude euler angles (int).
#define int32_eulers_dot_of_rates
#define VECT3_COPY(_a, _b)
#define VECT3_DIFF(_c, _a, _b)
void ahrs_ice_set_body_to_imu_quat(struct FloatQuat *q_b2i)
#define VECT3_SUM_SCALED(_c, _a, _b, _s)
Paparazzi fixed point trig functions.
struct AhrsIntCmplEuler ahrs_ice
#define RATES_DIFF(_c, _a, _b)
void ahrs_ice_update_mag(struct Int32Vect3 *mag)
int32_t r
in rad/s with INT32_RATE_FRAC
#define PPRZ_ITRIG_SIN(_s, _a)
struct Int32Eulers measurement
#define VECT3_SDIV(_vo, _vi, _s)
struct Int32Eulers measure
struct Int32Eulers hi_res_euler
static void get_psi_measurement_from_mag(int32_t *psi_meas, int32_t phi_est, int32_t theta_est, struct Int32Vect3 *mag)
bool_t ahrs_ice_align(struct Int32Rates *lp_gyro, struct Int32Vect3 *lp_accel, struct Int32Vect3 *lp_mag)
struct OrientationReps body_to_imu
int32_t phi
in rad with INT32_ANGLE_FRAC
#define NOISE_FILTER_GAIN
#define INT_EULERS_ZERO(_e)
struct Int32Rates imu_rate
#define INT_MULT_RSHIFT(_a, _b, _r)
void ahrs_ice_update_accel(struct Int32Vect3 *accel)
#define EULERS_DIFF(_c, _a, _b)
enum AhrsICEStatus status
#define EULERS_COPY(_a, _b)
int32_t p
in rad/s with INT32_RATE_FRAC
arch independent LED (Light Emitting Diodes) API
#define EULERS_ADD(_a, _b)
static struct OrientationReps body_to_imu
#define RATES_COPY(_a, _b)
#define RATES_SUM_SCALED(_c, _a, _b, _s)
struct Int32Rates gyro_bias
#define EULERS_SDIV(_eo, _ei, _s)
int32_t q
in rad/s with INT32_RATE_FRAC
struct Int32Eulers residual
static struct FloatQuat * orientationGetQuat_f(struct OrientationReps *orientation)
Get vehicle body attitude quaternion (float).
#define PPRZ_ITRIG_COS(_c, _a)
int32_t int32_atan2(int32_t y, int32_t x)
Paparazzi fixed point algebra.