From 9b6e8feeea5f7d16ab84d019b3c76de86316a2d2 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Fri, 6 Jun 2014 20:06:14 +0100 Subject: [PATCH] Ensure that Lux's pid controller observes the max_angle_inclination setting. --- src/main/flight/flight.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/flight/flight.c b/src/main/flight/flight.c index 369f268e2b..5344d54198 100644 --- a/src/main/flight/flight.c +++ b/src/main/flight/flight.c @@ -101,8 +101,9 @@ static void pidBaseflight(pidProfile_t *pidProfile, controlRateConfig_t *control // YAW is always gyro-controlled (MAG correction is applied to rcCommand) 100dps to 1100dps max yaw rate AngleRate = (float)((controlRateConfig->yawRate + 10) * rcCommand[YAW]) / 50.0f; } else { - // calculate error and limit the angle to 50 degrees max inclination - errorAngle = (constrain(rcCommand[axis] + GPS_angle[axis], -500, +500) - inclination.raw[axis] + angleTrim->raw[axis]) / 10.0f; // 16 bits is ok here + // calculate error and limit the angle to the max inclination + errorAngle = (constrain(rcCommand[axis] + GPS_angle[axis], -((int) max_angle_inclination), + +max_angle_inclination) - inclination.raw[axis] + angleTrim->raw[axis]) / 10.0f; // 16 bits is ok here if (shouldAutotune()) { errorAngle = autotune(rcAliasToAngleIndexMap[axis], &inclination, errorAngle);