AP_Baro: prevent bad ground pressure from making a board unbootable

This commit is contained in:
Andrew Tridgell 2016-02-23 14:15:39 +11:00
parent 1df2512935
commit 0a72c2bbd5

View File

@ -363,7 +363,8 @@ void AP_Baro::update(void)
for (uint8_t i=0; i<_num_sensors; i++) {
if (sensors[i].healthy) {
// update altitude calculation
if (is_zero(sensors[i].ground_pressure)) {
float ground_pressure = sensors[i].ground_pressure;
if (is_zero(ground_pressure) || isnan(ground_pressure) || isinf(ground_pressure)) {
sensors[i].ground_pressure = sensors[i].pressure;
}
float altitude = get_altitude_difference(sensors[i].ground_pressure, sensors[i].pressure);