From 3638bfb614e39f06f608c7eb6e6901dceb3f35d9 Mon Sep 17 00:00:00 2001 From: Randy Mackay Date: Tue, 21 Oct 2014 11:32:20 +0900 Subject: [PATCH] AC_PosControl: bug fix dt calculation fixes issue in which now could be earlier than _last_update_xy_ms leading to a large dt value and a sudden lean on takeoff --- libraries/AC_AttitudeControl/AC_PosControl.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/AC_AttitudeControl/AC_PosControl.cpp b/libraries/AC_AttitudeControl/AC_PosControl.cpp index cb10749842..37714efaac 100644 --- a/libraries/AC_AttitudeControl/AC_PosControl.cpp +++ b/libraries/AC_AttitudeControl/AC_PosControl.cpp @@ -551,6 +551,7 @@ void AC_PosControl::update_xy_controller(bool use_desired_velocity) uint32_t now = hal.scheduler->millis(); if ((now - _last_update_xy_ms) >= POSCONTROL_ACTIVE_TIMEOUT_MS) { init_xy_controller(); + now = _last_update_xy_ms; } // check if xy leash needs to be recalculated