From 1ecca36dd0af6a6c77f03643784a8a4e0fc8cc1f Mon Sep 17 00:00:00 2001 From: Jason Short Date: Fri, 16 Mar 2012 13:32:18 -0700 Subject: [PATCH] Fixed Scaling bug in Sonar mixing --- ArduCopter/ArduCopter.pde | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ArduCopter/ArduCopter.pde b/ArduCopter/ArduCopter.pde index b8d73ca4f2..d85e280076 100644 --- a/ArduCopter/ArduCopter.pde +++ b/ArduCopter/ArduCopter.pde @@ -1955,9 +1955,8 @@ static void update_altitude() sonar_alt = (float)sonar_alt * temp; #endif - scale = (sonar_alt - 400) / 200; - scale = constrain(scale, 0, 1); - + scale = (float)(sonar_alt - 400) / 200.0; + scale = constrain(scale, 0.0, 1.0); // solve for a blended altitude current_loc.alt = ((float)sonar_alt * (1.0 - scale)) + ((float)baro_alt * scale) + home.alt;