From 0a72c2bbd5b04e58646e1ba724a40fdfb2e04c4c Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 23 Feb 2016 14:15:39 +1100 Subject: [PATCH] AP_Baro: prevent bad ground pressure from making a board unbootable --- libraries/AP_Baro/AP_Baro.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Baro/AP_Baro.cpp b/libraries/AP_Baro/AP_Baro.cpp index 20ea6c970e..5ad74c9fe4 100644 --- a/libraries/AP_Baro/AP_Baro.cpp +++ b/libraries/AP_Baro/AP_Baro.cpp @@ -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);