45 #if FLOAT_DCM_SEND_DEBUG
48 #include "pprzlink/messages.h"
67 float DCM_Matrix[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
83 #if PERFORMANCE_REPORTING == 1
92 for (
int i = 0; i < 3; i++) {
93 for (
int j = 0; j < 3; j++) {
121 struct FloatVect3 *lp_mag __attribute__((unused)))
156 float dp = 0, dq = 0, dr = 0;
178 static float last_gps_speed_3d = 0;
212 #if USE_AHRS_GPS_ACCELERATIONS
231 MESSAGE(
"MAGNETOMETER FEEDBACK NOT TESTED YET")
245 MAG_Heading_X = mag->
x * cos_pitch + mag->
y * sin_roll * sin_pitch + mag->
z * cos_roll * sin_pitch;
268 #if FLOAT_DCM_SEND_DEBUG
290 float temporary[3][3];
311 if (renorm < 1.5625f && renorm > 0.64f) {
312 renorm = .5 * (3 - renorm);
313 }
else if (renorm < 100.0f && renorm > 0.01f) {
314 renorm = 1. / sqrtf(renorm);
315 #if PERFORMANCE_REPORTING == 1
320 #if PERFORMANCE_REPORTING == 1
328 if (renorm < 1.5625f && renorm > 0.64f) {
329 renorm = .5 * (3 - renorm);
330 }
else if (renorm < 100.0f && renorm > 0.01f) {
331 renorm = 1. / sqrtf(renorm);
332 #if PERFORMANCE_REPORTING == 1
337 #if PERFORMANCE_REPORTING == 1
345 if (renorm < 1.5625f && renorm > 0.64f) {
346 renorm = .5 * (3 - renorm);
347 }
else if (renorm < 100.0f && renorm > 0.01f) {
348 renorm = 1. / sqrtf(renorm);
349 #if PERFORMANCE_REPORTING == 1
354 #if PERFORMANCE_REPORTING == 1
371 #ifndef ACCEL_WEIGHT_FILTER
372 #define ACCEL_WEIGHT_FILTER 8
378 #ifndef ACCEL_WEIGHT_BAND
379 #define ACCEL_WEIGHT_BAND 1.f
385 static float Scaled_Omega_P[3];
386 static float Scaled_Omega_I[3];
387 static float Accel_filtered = 0.f;
388 float Accel_magnitude;
390 float Integrator_magnitude;
393 float errorRollPitch[3];
401 Accel_magnitude = Accel_magnitude /
GRAVITY;
402 #if ACCEL_WEIGHT_FILTER
405 Accel_filtered = Accel_magnitude;
409 Accel_weight = Clip(1.f - (2.f / Max(0.1f,
ACCEL_WEIGHT_BAND)) * fabsf(1.f - Accel_filtered), 0.f, 1.f);
412 #if PERFORMANCE_REPORTING == 1
415 float tempfloat = ((Accel_weight - 0.5) * 256.0f);
449 float COGX = cosf(
course);
450 float COGY = sinf(
course);
462 #if USE_MAGNETOMETER_ONGROUND
463 PRINT_CONFIG_MSG(
"AHRS_FLOAT_DCM uses magnetometer prior to takeoff and GPS during flight")
481 if (Integrator_magnitude > RadOfDeg(300)) {
518 for (
int x = 0; x < 3; x++) {
519 for (
int y = 0; y < 3; y++) {
void ahrs_dcm_propagate(struct FloatRates *gyro, float dt)
void Drift_correction(void)
void ahrs_dcm_update_gps(struct GpsState *gps_s UNUSED)
void ahrs_dcm_update_mag(struct FloatVect3 *mag)
static void compute_ahrs_representations(void)
float Temporary_Matrix[3][3]
void ahrs_dcm_update_accel(struct FloatVect3 *accel)
void Matrix_update(float dt)
static void set_dcm_matrix_from_rmat(struct FloatRMat *rmat)
#define ACCEL_WEIGHT_FILTER
struct AhrsFloatDCM ahrs_dcm
bool ahrs_dcm_align(struct FloatRates *lp_gyro, struct FloatVect3 *lp_accel, struct FloatVect3 *lp_mag)
#define ACCEL_WEIGHT_BAND
float Update_Matrix[3][3]
struct FloatVect3 accel_float
struct FloatVect3 mag_float
Attitude estimation for fixedwings based on the DCM.
#define AHRS_FLOAT_MIN_SPEED_GPS_COURSE
struct FloatRates body_rate
struct FloatEulers ltp_to_body_euler
struct FloatRates gyro_bias
enum AhrsDCMStatus status
Algebra helper functions for DCM.
static void Vector_Add(float vectorOut[3], float vectorIn1[3], float vectorIn2[3])
static void Matrix_Multiply(float a[3][3], float b[3][3], float mat[3][3])
static void Vector_Scale(float vectorOut[3], float vectorIn[3], float scale2)
static float Vector_Dot_Product(float vector1[3], float vector2[3])
static void Vector_Cross_Product(float vectorOut[3], float v1[3], float v2[3])
Utility functions for floating point AHRS implementations.
static void ahrs_float_get_quat_from_accel_mag(struct FloatQuat *q, struct FloatVect3 *accel, struct FloatVect3 *mag)
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.
struct pprz_autopilot autopilot
Global autopilot structure.
Core autopilot interface common to all firmwares.
bool launch
request launch
Common code for AP and FBW telemetry.
Device independent GPS code (interface)
#define GPS_FIX_3D
3D GPS fix
data structure for GPS information
#define FLOAT_EULERS_ZERO(_e)
static void float_rmat_identity(struct FloatRMat *rm)
initialises a rotation matrix to identity
void float_rmat_of_quat(struct FloatRMat *rm, struct FloatQuat *q)
void float_eulers_of_quat(struct FloatEulers *e, struct FloatQuat *q)
euler rotation 'ZYX'
#define FLOAT_RATES_ZERO(_r)
#define RMAT_ELMT(_rm, _row, _col)
#define RATES_DIFF(_c, _a, _b)
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
arch independent LED (Light Emitting Diodes) API
Paparazzi floating point algebra.
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.