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++) {
149 float dp = 0, dq = 0, dr = 0;
171 static float last_gps_speed_3d = 0;
178 if (gps_s->
gspeed >= 500) {
198 accel_float.
x = -accel->
x;
199 accel_float.
y = -accel->
y;
200 accel_float.
z = -accel->
z;
205 #if USE_AHRS_GPS_ACCELERATIONS
224 MESSAGE(
"MAGNETOMETER FEEDBACK NOT TESTED YET")
238 MAG_Heading_X = mag->
x * cos_pitch + mag->
y * sin_roll * sin_pitch + mag->
z * cos_roll * sin_pitch;
261 #if FLOAT_DCM_SEND_DEBUG
274 #else // !USE_MAGNETOMETER
283 float temporary[3][3];
304 if (renorm < 1.5625f && renorm > 0.64f) {
305 renorm = .5 * (3 - renorm);
306 }
else if (renorm < 100.0f && renorm > 0.01f) {
307 renorm = 1. / sqrtf(renorm);
308 #if PERFORMANCE_REPORTING == 1
313 #if PERFORMANCE_REPORTING == 1
321 if (renorm < 1.5625f && renorm > 0.64f) {
322 renorm = .5 * (3 - renorm);
323 }
else if (renorm < 100.0f && renorm > 0.01f) {
324 renorm = 1. / sqrtf(renorm);
325 #if PERFORMANCE_REPORTING == 1
330 #if PERFORMANCE_REPORTING == 1
338 if (renorm < 1.5625f && renorm > 0.64f) {
339 renorm = .5 * (3 - renorm);
340 }
else if (renorm < 100.0f && renorm > 0.01f) {
341 renorm = 1. / sqrtf(renorm);
342 #if PERFORMANCE_REPORTING == 1
347 #if PERFORMANCE_REPORTING == 1
364 static float Scaled_Omega_P[3];
365 static float Scaled_Omega_I[3];
366 float Accel_magnitude;
368 float Integrator_magnitude;
371 float errorRollPitch[3];
378 Accel_magnitude = sqrtf(accel_float.
x * accel_float.
x + accel_float.
y * accel_float.
y + accel_float.
z * accel_float.
z);
379 Accel_magnitude = Accel_magnitude /
GRAVITY;
382 Accel_weight = Clip(1 - 2 * fabsf(1 - Accel_magnitude), 0, 1);
385 #if PERFORMANCE_REPORTING == 1
388 float tempfloat = ((Accel_weight - 0.5) * 256.0f);
418 #else // Use GPS Ground course to correct yaw gyro drift
422 float COGX = cosf(course);
423 float COGY = sinf(course);
435 #if USE_MAGNETOMETER_ONGROUND
436 PRINT_CONFIG_MSG(
"AHRS_FLOAT_DCM uses magnetometer prior to takeoff and GPS during flight")
449 #endif // USE_MAGNETOMETER_ONGROUND
454 if (Integrator_magnitude > RadOfDeg(300)) {
467 #if OUTPUTMODE==1 // With corrected data (drift correction)
477 #else // Uncorrected data (no drift correction)
491 for (
int x = 0;
x < 3;
x++) {
492 for (
int y = 0;
y < 3;
y++) {
500 #if (OUTPUTMODE==2) // Only accelerometer info (debugging purposes)
bool launch
request launch
static void orientationSetQuat_f(struct OrientationReps *orientation, struct FloatQuat *quat)
Set vehicle body attitude from quaternion (float).
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
#define float_rmat_of_eulers
bool ahrs_dcm_align(struct FloatRates *lp_gyro, struct FloatVect3 *lp_accel, struct FloatVect3 *lp_mag)
static void set_dcm_matrix_from_rmat(struct FloatRMat *rmat)
void Matrix_update(float dt)
struct FloatVect3 accel_float
#define FLOAT_EULERS_ZERO(_e)
static void Matrix_Multiply(float a[3][3], float b[3][3], float mat[3][3])
static struct FloatRMat * orientationGetRMat_f(struct OrientationReps *orientation)
Get vehicle body attitude rotation matrix (float).
void ahrs_dcm_update_mag(struct FloatVect3 *mag)
struct FloatVect3 mag_float
Utility functions for floating point AHRS implementations.
#define FLOAT_RATES_ZERO(_r)
static void Vector_Add(float vectorOut[3], float vectorIn1[3], float vectorIn2[3])
uint16_t speed_3d
norm of 3d speed in cm/s
void Drift_correction(void)
#define GPS_FIX_3D
3D GPS fix
#define RATES_DIFF(_c, _a, _b)
static void ahrs_float_get_euler_from_accel_mag(struct FloatEulers *e, struct FloatVect3 *accel, struct FloatVect3 *mag)
struct pprz_autopilot autopilot
Global autopilot structure.
float Update_Matrix[3][3]
struct FloatEulers ltp_to_imu_euler
static float Vector_Dot_Product(float vector1[3], float vector2[3])
Paparazzi floating point algebra.
data structure for GPS information
struct AhrsFloatDCM ahrs_dcm
Device independent GPS code (interface)
Algebra helper functions for DCM.
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
struct FloatRates gyro_bias
void ahrs_dcm_update_gps(struct GpsState *gps_s)
void ahrs_dcm_update_accel(struct FloatVect3 *accel)
enum AhrsDCMStatus status
Core autopilot interface common to all firmwares.
static void Vector_Cross_Product(float vectorOut[3], float v1[3], float v2[3])
struct OrientationReps body_to_imu
int32_t course
GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north)
static void Vector_Scale(float vectorOut[3], float vectorIn[3], float scale2)
#define RMAT_ELMT(_rm, _row, _col)
static struct FloatEulers * orientationGetEulers_f(struct OrientationReps *orientation)
Get vehicle body attitude euler angles (float).
float Temporary_Matrix[3][3]
void ahrs_dcm_set_body_to_imu_quat(struct FloatQuat *q_b2i)
Common code for AP and FBW telemetry.
arch independent LED (Light Emitting Diodes) API
uint16_t gspeed
norm of 2d ground speed in cm/s
void ahrs_dcm_propagate(struct FloatRates *gyro, float dt)
static struct OrientationReps body_to_imu
Attitude estimation for fixedwings based on the DCM.
static void compute_ahrs_representations(void)
void ahrs_dcm_set_body_to_imu(struct OrientationReps *body_to_imu)
struct FloatRates imu_rate
static struct FloatQuat * orientationGetQuat_f(struct OrientationReps *orientation)
Get vehicle body attitude quaternion (float).