1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-27 16:54:15 +01:00

Yaw stabilisation for the simple algorithm was calculating the error and not taking into account that 350º error is the same as -10º error.

The resultant error could range from -360º -> +360º
Since this is only used for Helicopters / multi rotors, and the aircraft can rotate in any direction, I added the modulo logic so that it is now from -180º -> +180º this should now take quickest path to correct the error.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1464 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
andrew 2010-08-30 01:20:43 +00:00 committed by andrew
parent 3c6d9d6976
commit 65dc5e9b04

View File

@ -133,6 +133,9 @@ static void stabilizationTask(void* parameters)
if (( systemSettings.AirframeType == SYSTEMSETTINGS_AIRFRAMETYPE_VTOL )||( systemSettings.AirframeType == SYSTEMSETTINGS_AIRFRAMETYPE_HELICP))
{
yawError = attitudeDesired.Yaw - attitudeActual.Yaw;
//this should make it take the quickest path to reach the desired yaw
if (yawError>180.0)yawError -= 360;
if (yawError<-180.0)yawError += 360;
yawDerivative = yawError - yawErrorLast;
yawIntegralLimit = YAW_INTEGRAL_LIMIT / stabSettings.YawKi;
yawIntegral = bound(yawIntegral+yawError*stabSettings.UpdatePeriod, -yawIntegralLimit, yawIntegralLimit);