From 51ff905ba84cb8b54629a0c30c4440e3e2012251 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 14 Aug 2015 13:31:59 +1000 Subject: [PATCH] Plane: make TRAINING mode obey stall prevention roll limits Fixes issue#2014 --- ArduPlane/ArduPlane.cpp | 1 + ArduPlane/Attitude.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/ArduPlane/ArduPlane.cpp b/ArduPlane/ArduPlane.cpp index 5783542980..eac7b98acd 100644 --- a/ArduPlane/ArduPlane.cpp +++ b/ArduPlane/ArduPlane.cpp @@ -552,6 +552,7 @@ void Plane::update_flight_mode(void) case TRAINING: { training_manual_roll = false; training_manual_pitch = false; + update_load_factor(); // if the roll is past the set roll limit, then // we set target roll to the limit diff --git a/ArduPlane/Attitude.cpp b/ArduPlane/Attitude.cpp index 1ca5ddeb4f..e6a581d1a8 100644 --- a/ArduPlane/Attitude.cpp +++ b/ArduPlane/Attitude.cpp @@ -1082,6 +1082,7 @@ void Plane::update_load_factor(void) // our airspeed is below the minimum airspeed. Limit roll to // 25 degrees nav_roll_cd = constrain_int32(nav_roll_cd, -2500, 2500); + roll_limit_cd = constrain_int32(roll_limit_cd, -2500, 2500); } else if (max_load_factor < aerodynamic_load_factor) { // the demanded nav_roll would take us past the aerodymamic // load limit. Limit our roll to a bank angle that will keep @@ -1094,5 +1095,6 @@ void Plane::update_load_factor(void) roll_limit = 2500; } nav_roll_cd = constrain_int32(nav_roll_cd, -roll_limit, roll_limit); + roll_limit_cd = constrain_int32(roll_limit_cd, -roll_limit, roll_limit); } }