From 59fb1f3542ecc30d1949a25b046c4877e5ba559b Mon Sep 17 00:00:00 2001 From: Jason Short Date: Tue, 13 Mar 2012 21:31:16 -0700 Subject: [PATCH] ACM: Added constraints for invalid climb rates. Robert Lefebvre had a bad sonar and very invalid rates crept into the system. --- ArduCopter/ArduCopter.pde | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ArduCopter/ArduCopter.pde b/ArduCopter/ArduCopter.pde index 06a66a3b38..ff1e595f4a 100644 --- a/ArduCopter/ArduCopter.pde +++ b/ArduCopter/ArduCopter.pde @@ -1924,6 +1924,7 @@ static void update_altitude() // calc the vertical accel rate int temp = (baro_alt - old_baro_alt) * 10; baro_rate = (temp + baro_rate) >> 1; + baro_rate = constrain(baro_rate, -300, 300); old_baro_alt = baro_alt; // Note: sonar_alt is calculated in a faster loop and filtered with a mode filter @@ -1942,6 +1943,7 @@ static void update_altitude() // calc the vertical accel rate // positive = going up. sonar_rate = (sonar_alt - old_sonar_alt) * 10; + sonar_rate = constrain(sonar_rate, -150, 150); old_sonar_alt = sonar_alt; #endif