|
|
|
@ -67,7 +67,7 @@ void AP_Baro::calibrate()
@@ -67,7 +67,7 @@ void AP_Baro::calibrate()
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
uint32_t tstart = hal.scheduler->millis(); |
|
|
|
|
while (ground_pressure == 0 || !healthy) { |
|
|
|
|
while (ground_pressure == 0 || !_flags.healthy) { |
|
|
|
|
read(); // Get initial data from absolute pressure sensor
|
|
|
|
|
if (hal.scheduler->millis() - tstart > 500) { |
|
|
|
|
hal.scheduler->panic(PSTR("PANIC: AP_Baro::read unsuccessful " |
|
|
|
@ -89,7 +89,7 @@ void AP_Baro::calibrate()
@@ -89,7 +89,7 @@ void AP_Baro::calibrate()
|
|
|
|
|
hal.scheduler->panic(PSTR("PANIC: AP_Baro::read unsuccessful " |
|
|
|
|
"for more than 500ms in AP_Baro::calibrate [2]\r\n")); |
|
|
|
|
} |
|
|
|
|
} while (!healthy); |
|
|
|
|
} while (!_flags.healthy); |
|
|
|
|
ground_pressure = get_pressure(); |
|
|
|
|
ground_temperature = get_temperature(); |
|
|
|
|
|
|
|
|
@ -106,7 +106,7 @@ void AP_Baro::calibrate()
@@ -106,7 +106,7 @@ void AP_Baro::calibrate()
|
|
|
|
|
hal.scheduler->panic(PSTR("PANIC: AP_Baro::read unsuccessful " |
|
|
|
|
"for more than 500ms in AP_Baro::calibrate [3]\r\n")); |
|
|
|
|
} |
|
|
|
|
} while (!healthy); |
|
|
|
|
} while (!_flags.healthy); |
|
|
|
|
ground_pressure = (ground_pressure * 0.8f) + (get_pressure() * 0.2f); |
|
|
|
|
ground_temperature = (ground_temperature * 0.8f) +
|
|
|
|
|
(get_temperature() * 0.2f); |
|
|
|
@ -168,10 +168,19 @@ float AP_Baro::get_altitude(void)
@@ -168,10 +168,19 @@ float AP_Baro::get_altitude(void)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
float pressure = get_pressure(); |
|
|
|
|
_altitude = get_altitude_difference(_ground_pressure, pressure); |
|
|
|
|
float alt = get_altitude_difference(_ground_pressure, pressure); |
|
|
|
|
|
|
|
|
|
// record that we have consumed latest data
|
|
|
|
|
_last_altitude_t = _last_update; |
|
|
|
|
|
|
|
|
|
// sanity check altitude
|
|
|
|
|
if (isnan(alt) || isinf(alt)) { |
|
|
|
|
_flags.alt_ok = false; |
|
|
|
|
} else { |
|
|
|
|
_altitude = alt; |
|
|
|
|
_flags.alt_ok = true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// ensure the climb rate filter is updated
|
|
|
|
|
_climb_rate_filter.update(_altitude, _last_update); |
|
|
|
|
|
|
|
|
|