45 #if FLOAT_DCM_SEND_DEBUG
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++) {
155 float dp = 0, dq = 0, dr = 0;
177 static float last_gps_speed_3d = 0;
184 if (gps_s->
gspeed >= 500) {
206 accel_float.
x = -accel_float.
x;
207 accel_float.
y = -accel_float.
y;
208 accel_float.
z = -accel_float.
z;
213 #if USE_AHRS_GPS_ACCELERATIONS
232 #warning MAGNETOMETER FEEDBACK NOT TESTED YET
248 MAG_Heading_X = mag->
x * cos_pitch + mag->
y * sin_roll * sin_pitch + mag->
z * cos_roll * sin_pitch;
276 #if FLOAT_DCM_SEND_DEBUG
284 #else // !USE_MAGNETOMETER
293 float temporary[3][3];
314 if (renorm < 1.5625f && renorm > 0.64f) {
315 renorm = .5 * (3 - renorm);
316 }
else if (renorm < 100.0f && renorm > 0.01f) {
317 renorm = 1. / sqrt(renorm);
318 #if PERFORMANCE_REPORTING == 1
323 #if PERFORMANCE_REPORTING == 1
331 if (renorm < 1.5625f && renorm > 0.64f) {
332 renorm = .5 * (3 - renorm);
333 }
else if (renorm < 100.0f && renorm > 0.01f) {
334 renorm = 1. / sqrt(renorm);
335 #if PERFORMANCE_REPORTING == 1
340 #if PERFORMANCE_REPORTING == 1
348 if (renorm < 1.5625f && renorm > 0.64f) {
349 renorm = .5 * (3 - renorm);
350 }
else if (renorm < 100.0f && renorm > 0.01f) {
351 renorm = 1. / sqrt(renorm);
352 #if PERFORMANCE_REPORTING == 1
357 #if PERFORMANCE_REPORTING == 1
374 static float Scaled_Omega_P[3];
375 static float Scaled_Omega_I[3];
376 float Accel_magnitude;
378 float Integrator_magnitude;
381 float errorRollPitch[3];
388 Accel_magnitude = sqrt(accel_float.
x * accel_float.
x + accel_float.
y * accel_float.
y + accel_float.
z * accel_float.
z);
389 Accel_magnitude = Accel_magnitude /
GRAVITY;
392 Accel_weight = Chop(1 - 2 * fabs(1 - Accel_magnitude), 0, 1);
395 #if PERFORMANCE_REPORTING == 1
398 float tempfloat = ((Accel_weight - 0.5) * 256.0f);
428 #else // Use GPS Ground course to correct yaw gyro drift
432 float COGX = cosf(course);
433 float COGY = sinf(course);
445 #if USE_MAGNETOMETER_ONGROUND == 1
446 PRINT_CONFIG_MSG(
"AHRS_FLOAT_DCM uses magnetometer prior to takeoff and GPS during flight")
448 float COGX = mag_float.
x;
449 float COGY = mag_float.
y;
459 #endif // USE_MAGNETOMETER_ONGROUND
464 if (Integrator_magnitude > RadOfDeg(300)) {
477 #if OUTPUTMODE==1 // With corrected data (drift correction)
487 #else // Uncorrected data (no drift correction)
501 for (
int x = 0;
x < 3;
x++) {
502 for (
int y = 0;
y < 3;
y++) {
510 #if (OUTPUTMODE==2) // Only accelerometer info (debugging purposes)
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
bool_t ahrs_dcm_align(struct Int32Rates *lp_gyro, struct Int32Vect3 *lp_accel, struct Int32Vect3 *lp_mag)
#define float_rmat_of_eulers
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).
struct FloatVect3 mag_float
Utility functions for floating point AHRS implementations.
#define FLOAT_RATES_ZERO(_r)
#define MAG_FLOAT_OF_BFP(_ai)
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)
float Update_Matrix[3][3]
struct FloatEulers ltp_to_imu_euler
static float Vector_Dot_Product(float vector1[3], float vector2[3])
#define RATES_FLOAT_OF_BFP(_rf, _ri)
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_mag(struct Int32Vect3 *mag)
#define ACCELS_FLOAT_OF_BFP(_ef, _ei)
enum AhrsDCMStatus status
#define DefaultChannel
SITL.
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
static struct OrientationReps body_to_imu
#define RATES_COPY(_a, _b)
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)
static void ahrs_float_get_euler_from_accel_mag(struct FloatEulers *e, struct Int32Vect3 *accel, struct Int32Vect3 *mag)
void ahrs_dcm_update_accel(struct Int32Vect3 *accel)
struct FloatRates imu_rate
void ahrs_dcm_propagate(struct Int32Rates *gyro, float dt)
static struct FloatQuat * orientationGetQuat_f(struct OrientationReps *orientation)
Get vehicle body attitude quaternion (float).
Fixedwing autopilot modes.