@@ -298,7 +298,7 @@ AHRS_type::update_diff_GNSS (const float3vector &gyro,
298298
299299 // when circling is finished eventually update the magnetic calibration
300300 if (automatic_magnetic_calibration && (old_circle_state == CIRCLING) && (circling_state == TRANSITION))
301- handle_magnetic_calibration ( ' s ' );
301+ handle_magnetic_calibration ( );
302302}
303303
304304/* *
@@ -384,7 +384,7 @@ AHRS_type::update_compass (const float3vector &gyro, const float3vector &acc,
384384
385385 // when circling is finished eventually update the magnetic calibration
386386 if (automatic_magnetic_calibration && (old_circle_state == CIRCLING) && (circling_state == TRANSITION))
387- handle_magnetic_calibration (' m ' );
387+ handle_magnetic_calibration ();
388388}
389389
390390void AHRS_type::write_calibration_into_EEPROM ( void )
@@ -400,18 +400,18 @@ void AHRS_type::write_calibration_into_EEPROM( void)
400400 lock_EEPROM ( true );
401401}
402402
403- void AHRS_type::handle_magnetic_calibration ( char type )
403+ void AHRS_type::handle_magnetic_calibration ( void )
404404{
405405 bool calibration_changed = compass_calibration.set_calibration_if_changed ( mag_calibration_data_collector_right_turn, mag_calibration_data_collector_left_turn, MAG_SCALE);
406406
407407#if REPORT_MAGNETIC_CALIBRATION == 1
408+
408409 if ( calibration_changed)
409410 {
410411 magnetic_induction_report_t magnetic_induction_report;
411412 for ( unsigned i=0 ; i<3 ; ++i)
412413 magnetic_induction_report.calibration [i] = (compass_calibration.get_calibration ())[i];
413414
414- report_magnetic_calibration_has_changed ( &magnetic_induction_report, type);
415415 magnetic_calibration_updated = true ;
416416 }
417417#else
@@ -424,14 +424,5 @@ void AHRS_type::filter_magnetic_induction( const float3vector &gyro, float3vecto
424424{
425425 float absolute_rotation = gyro.abs ();
426426 for ( unsigned i=0 ; i<3 ; ++i)
427- {
428- float max_expected_slope;
429- if ( mag[i] > 0 .95f )
430- max_expected_slope = 0 .3124f ; // = sqrt( 1 - 0.95^2)
431- else
432- max_expected_slope = SQRT ( 1 .0f - SQR ( mag[i]));
433- mag[i] = mag_filter[i].respond (mag[i], absolute_rotation * Ts * max_expected_slope);
434- }
427+ mag[i] = mag_filter[i].respond (mag[i], absolute_rotation * Ts * MAX_EXPECTED_INDUCTION_SLOPE);
435428}
436-
437-
0 commit comments