From fda4c134644b418a0bf63ef36eabf88bcde3f0af Mon Sep 17 00:00:00 2001 From: Randy Mackay <rmackay9@yahoo.com> Date: Fri, 5 Jul 2013 13:49:45 -1000 Subject: [PATCH] Copter: yaw limit fix to allow I to reduce We now allow the I term even if we've hit the yaw limits as long as updating the I term will reduce it --- ArduCopter/Attitude.pde | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ArduCopter/Attitude.pde b/ArduCopter/Attitude.pde index df00720b0..590a44730 100644 --- a/ArduCopter/Attitude.pde +++ b/ArduCopter/Attitude.pde @@ -522,12 +522,16 @@ get_rate_yaw(int32_t target_rate) // separately calculate p, i, d values for logging p = g.pid_rate_yaw.get_p(rate_error); - // freeze I term if we've breached yaw limits - if( motors.reached_limit(AP_MOTOR_YAW_LIMIT) ) { - i = g.pid_rate_yaw.get_integrator(); - }else{ + + // get i term + i = g.pid_rate_yaw.get_integrator(); + + // update i term as long as we haven't breached the limits or the I term will certainly reduce + if (!motors.reached_limit(AP_MOTOR_YAW_LIMIT) || ((i>0&&rate_error<0)||(i<0&&rate_error>0))) { i = g.pid_rate_yaw.get_i(rate_error, G_Dt); } + + // get d value d = g.pid_rate_yaw.get_d(rate_error, G_Dt); output = p+i+d; -- GitLab