@@ -334,7 +334,7 @@ void imu_get_calibration(float yaw, float *imu_cal) {
334
334
roll_sample = roll_sample / 250 ;
335
335
336
336
// Set roll rotations to level out roll axis
337
- m_settings .rot_roll = - roll_sample * RAD2DEG_f ;
337
+ m_settings .rot_roll = - RAD2DEG_f ( roll_sample ) ;
338
338
339
339
// Rotate gyro offsets to match new IMU orientation
340
340
float rotation1 [3 ] = {m_settings .rot_roll , m_settings .rot_pitch , m_settings .rot_yaw };
@@ -353,7 +353,7 @@ void imu_get_calibration(float yaw, float *imu_cal) {
353
353
pitch_sample = pitch_sample / 250 ;
354
354
355
355
// Set pitch rotation to level out pitch axis
356
- m_settings .rot_pitch = pitch_sample * RAD2DEG_f ;
356
+ m_settings .rot_pitch = RAD2DEG_f ( pitch_sample ) ;
357
357
358
358
// Rotate imu offsets to match
359
359
float rotation2 [3 ] = {m_settings .rot_roll , m_settings .rot_pitch , m_settings .rot_yaw };
@@ -445,12 +445,12 @@ static void imu_read_callback(float *accel, float *gyro, float *mag) {
445
445
446
446
// Rotate axes (ZYX)
447
447
448
- float s1 = sinf (m_settings .rot_yaw * DEG2RAD_f );
449
- float c1 = cosf (m_settings .rot_yaw * DEG2RAD_f );
450
- float s2 = sinf (m_settings .rot_pitch * DEG2RAD_f );
451
- float c2 = cosf (m_settings .rot_pitch * DEG2RAD_f );
452
- float s3 = sinf (m_settings .rot_roll * DEG2RAD_f );
453
- float c3 = cosf (m_settings .rot_roll * DEG2RAD_f );
448
+ float s1 = sinf (DEG2RAD_f ( m_settings .rot_yaw ) );
449
+ float c1 = cosf (DEG2RAD_f ( m_settings .rot_yaw ) );
450
+ float s2 = sinf (DEG2RAD_f ( m_settings .rot_pitch ) );
451
+ float c2 = cosf (DEG2RAD_f ( m_settings .rot_pitch ) );
452
+ float s3 = sinf (DEG2RAD_f ( m_settings .rot_roll ) );
453
+ float c3 = cosf (DEG2RAD_f ( m_settings .rot_roll ) );
454
454
455
455
float m11 = c1 * c2 ; float m12 = c1 * s2 * s3 - c3 * s1 ; float m13 = s1 * s3 + c1 * c3 * s2 ;
456
456
float m21 = c2 * s1 ; float m22 = c1 * c3 + s1 * s2 * s3 ; float m23 = c3 * s1 * s2 - c1 * s3 ;
@@ -475,9 +475,9 @@ static void imu_read_callback(float *accel, float *gyro, float *mag) {
475
475
}
476
476
477
477
float gyro_rad [3 ];
478
- gyro_rad [0 ] = m_gyro [0 ] * DEG2RAD_f ;
479
- gyro_rad [1 ] = m_gyro [1 ] * DEG2RAD_f ;
480
- gyro_rad [2 ] = m_gyro [2 ] * DEG2RAD_f ;
478
+ gyro_rad [0 ] = DEG2RAD_f ( m_gyro [0 ]) ;
479
+ gyro_rad [1 ] = DEG2RAD_f ( m_gyro [1 ]) ;
480
+ gyro_rad [2 ] = DEG2RAD_f ( m_gyro [2 ]) ;
481
481
482
482
switch (m_settings .mode ) {
483
483
case AHRS_MODE_MADGWICK :
@@ -508,12 +508,12 @@ static void imu_read_callback(float *accel, float *gyro, float *mag) {
508
508
509
509
void rotate (float * input , float * rotation , float * output ) {
510
510
// Rotate imu offsets to match
511
- float s1 = sinf (rotation [2 ] * DEG2RAD_f );
512
- float c1 = cosf (rotation [2 ] * DEG2RAD_f );
513
- float s2 = sinf (rotation [1 ] * DEG2RAD_f );
514
- float c2 = cosf (rotation [1 ] * DEG2RAD_f );
515
- float s3 = sinf (rotation [0 ] * DEG2RAD_f );
516
- float c3 = cosf (rotation [0 ] * DEG2RAD_f );
511
+ float s1 = sinf (DEG2RAD_f ( rotation [2 ]) );
512
+ float c1 = cosf (DEG2RAD_f ( rotation [2 ]) );
513
+ float s2 = sinf (DEG2RAD_f ( rotation [1 ]) );
514
+ float c2 = cosf (DEG2RAD_f ( rotation [1 ]) );
515
+ float s3 = sinf (DEG2RAD_f ( rotation [0 ]) );
516
+ float c3 = cosf (DEG2RAD_f ( rotation [0 ]) );
517
517
518
518
float m11 = c1 * c2 ; float m12 = c1 * s2 * s3 - c3 * s1 ; float m13 = s1 * s3 + c1 * c3 * s2 ;
519
519
float m21 = c2 * s1 ; float m22 = c1 * c3 + s1 * s2 * s3 ; float m23 = c3 * s1 * s2 - c1 * s3 ;
0 commit comments