@@ -1101,8 +1101,10 @@ AP_InertialSensor::init(uint16_t loop_rate)
1101
1101
/*
1102
1102
see if user has setup for on-boot enable of temperature learning
1103
1103
*/
1104
- if (temperature_cal_running ()) {
1105
- tcal_learning = true ;
1104
+ if (IsTempCalibrated == false ){
1105
+ if (temperature_cal_running ()) {
1106
+ tcal_learning = true ;
1107
+ }
1106
1108
}
1107
1109
#endif
1108
1110
}
@@ -1731,9 +1733,11 @@ AP_InertialSensor::_init_gyro()
1731
1733
// has just been powered on, so the temperature may be changing
1732
1734
// rapidly. We use the average between start and end temperature
1733
1735
// as the calibration temperature to minimise errors
1734
- for (uint8_t k=0 ; k<num_gyros; k++) {
1735
- start_temperature[k] = get_temperature (k);
1736
- }
1736
+ if (IsTempCalibrated == false ){
1737
+ for (uint8_t k=0 ; k<num_gyros; k++) {
1738
+ start_temperature[k] = get_temperature (k);
1739
+ }
1740
+ }
1737
1741
#endif
1738
1742
1739
1743
// the strategy is to average 50 points over 0.5 seconds, then do it
@@ -1821,7 +1825,9 @@ AP_InertialSensor::_init_gyro()
1821
1825
_gyro_cal_ok[k] = true ;
1822
1826
_gyro_offset (k).set (new_gyro_offset[k]);
1823
1827
#if HAL_INS_TEMPERATURE_CAL_ENABLE
1824
- caltemp_gyro (k).set (0.5 * (get_temperature (k) + start_temperature[k]));
1828
+ if (IsTempCalibrated == false ){
1829
+ caltemp_gyro (k).set (0.5 * (get_temperature (k) + start_temperature[k]));
1830
+ }
1825
1831
#endif
1826
1832
}
1827
1833
}
@@ -1844,14 +1850,18 @@ void AP_InertialSensor::_save_gyro_calibration()
1844
1850
_gyro_offset (i).save ();
1845
1851
_gyro_id (i).save ();
1846
1852
#if HAL_INS_TEMPERATURE_CAL_ENABLE
1847
- caltemp_gyro (i).save ();
1853
+ if (IsTempCalibrated == false ){
1854
+ caltemp_gyro (i).save ();
1855
+ }
1848
1856
#endif
1849
1857
}
1850
1858
for (uint8_t i=_gyro_count; i<INS_MAX_INSTANCES; i++) {
1851
1859
_gyro_offset (i).set_and_save (Vector3f ());
1852
1860
_gyro_id (i).set_and_save (0 );
1853
1861
#if HAL_INS_TEMPERATURE_CAL_ENABLE
1854
- caltemp_gyro (i).set_and_save_ifchanged (-300 );
1862
+ if (IsTempCalibrated == false ){
1863
+ caltemp_gyro (i).set_and_save_ifchanged (-300 );
1864
+ }
1855
1865
#endif
1856
1866
}
1857
1867
}
@@ -1978,12 +1988,14 @@ void AP_InertialSensor::update(void)
1978
1988
_have_sample = false ;
1979
1989
1980
1990
#if HAL_INS_TEMPERATURE_CAL_ENABLE
1981
- if (tcal_learning && !temperature_cal_running ()) {
1982
- AP_Notify::flags.temp_cal_running = false ;
1983
- AP_Notify::events.temp_cal_saved = 1 ;
1984
- tcal_learning = false ;
1985
- GCS_SEND_TEXT (MAV_SEVERITY_WARNING, " TCAL finished all IMUs" );
1986
- }
1991
+ if (IsTempCalibrated == false ){
1992
+ if (tcal_learning && !temperature_cal_running ()) {
1993
+ AP_Notify::flags.temp_cal_running = false ;
1994
+ AP_Notify::events.temp_cal_saved = 1 ;
1995
+ tcal_learning = false ;
1996
+ GCS_SEND_TEXT (MAV_SEVERITY_WARNING, " TCAL finished all IMUs" );
1997
+ }
1998
+ }
1987
1999
#endif
1988
2000
#if AP_SERIALMANAGER_IMUOUT_ENABLED
1989
2001
if (uart.imu_out_uart ) {
@@ -2292,11 +2304,13 @@ bool AP_InertialSensor::calibrating() const
2292
2304
bool AP_InertialSensor::temperature_cal_running () const
2293
2305
{
2294
2306
#if HAL_INS_TEMPERATURE_CAL_ENABLE
2295
- for (uint8_t i=0 ; i<INS_MAX_INSTANCES; i++) {
2296
- if (tcal (i).enable == AP_InertialSensor_TCal::Enable::LearnCalibration) {
2297
- return true ;
2307
+ if (IsTempCalibrated == false ){
2308
+ for (uint8_t i=0 ; i<INS_MAX_INSTANCES; i++) {
2309
+ if (tcal (i).enable == AP_InertialSensor_TCal::Enable::LearnCalibration) {
2310
+ return true ;
2311
+ }
2312
+ }
2298
2313
}
2299
- }
2300
2314
#endif
2301
2315
return false ;
2302
2316
}
@@ -2390,13 +2404,17 @@ void AP_InertialSensor::_acal_save_calibrations()
2390
2404
_accel_id (i).save ();
2391
2405
_accel_id_ok[i] = true ;
2392
2406
#if HAL_INS_TEMPERATURE_CAL_ENABLE
2393
- caltemp_accel (i).set_and_save (get_temperature (i));
2407
+ if (IsTempCalibrated == false ){
2408
+ caltemp_accel (i).set_and_save (get_temperature (i));
2409
+ }
2394
2410
#endif
2395
2411
} else {
2396
2412
_accel_offset (i).set_and_save (Vector3f ());
2397
2413
_accel_scale (i).set_and_save (Vector3f ());
2398
2414
#if HAL_INS_TEMPERATURE_CAL_ENABLE
2399
- caltemp_accel (i).set_and_save (-300 );
2415
+ if (IsTempCalibrated == false ){
2416
+ caltemp_accel (i).set_and_save (-300 );
2417
+ }
2400
2418
#endif
2401
2419
}
2402
2420
}
@@ -2407,7 +2425,9 @@ void AP_InertialSensor::_acal_save_calibrations()
2407
2425
_accel_offset (i).set_and_save (Vector3f ());
2408
2426
_accel_scale (i).set_and_save (Vector3f ());
2409
2427
#if HAL_INS_TEMPERATURE_CAL_ENABLE
2410
- caltemp_accel (i).set_and_save_ifchanged (-300 );
2428
+ if (IsTempCalibrated == false ){
2429
+ caltemp_accel (i).set_and_save_ifchanged (-300 );
2430
+ }
2411
2431
#endif
2412
2432
}
2413
2433
@@ -2660,7 +2680,9 @@ MAV_RESULT AP_InertialSensor::simple_accel_cal()
2660
2680
_accel_id (k).save ();
2661
2681
_accel_id_ok[k] = true ;
2662
2682
#if HAL_INS_TEMPERATURE_CAL_ENABLE
2663
- caltemp_accel (k).set_and_save (get_temperature (k));
2683
+ if (IsTempCalibrated == false ){
2684
+ caltemp_accel (k).set_and_save (get_temperature (k));
2685
+ }
2664
2686
#endif
2665
2687
}
2666
2688
for (uint8_t k=num_accels; k<INS_MAX_INSTANCES; k++) {
@@ -2791,6 +2813,10 @@ void AP_InertialSensor::send_uart_data(void)
2791
2813
#if AP_EXTERNAL_AHRS_ENABLED
2792
2814
void AP_InertialSensor::handle_external (const AP_ExternalAHRS::ins_data_message_t &pkt)
2793
2815
{
2816
+ TempCalibration = pkt.TempCalibration ;
2817
+ if (TempCalibration == AP_ExternalAHRS::TempCal::IsTempCalibrated){
2818
+ IsTempCalibrated = true ;
2819
+ }
2794
2820
for (uint8_t i = 0 ; i < _backend_count; i++) {
2795
2821
_backends[i]->handle_external (pkt);
2796
2822
}
0 commit comments