From 95d52c6b08b3f580e9ca8e2f83c4b2fa09504fd7 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Sun, 8 Dec 2013 14:00:18 +0100 Subject: [PATCH] fixed signs in control loop --- flight/modules/AltitudeHold/altitudehold.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flight/modules/AltitudeHold/altitudehold.c b/flight/modules/AltitudeHold/altitudehold.c index c92014b97..153ffcf24 100644 --- a/flight/modules/AltitudeHold/altitudehold.c +++ b/flight/modules/AltitudeHold/altitudehold.c @@ -149,10 +149,10 @@ static void altitudeHoldTask(void) VelocityStateDownGet(&velocityStateDown); // altitude control loop - altitudeHoldStatus.VelocityDesired = altitudeHoldSettings.AltitudeP * (positionStateDown - altitudeHoldDesired.Altitude) + altitudeHoldDesired.Velocity; + altitudeHoldStatus.VelocityDesired = altitudeHoldSettings.AltitudeP * (altitudeHoldDesired.Altitude - positionStateDown) + altitudeHoldDesired.Velocity; // velocity control loop - altitudeHoldStatus.AccelerationDesired = altitudeHoldSettings.VelocityP * (velocityStateDown - altitudeHoldStatus.VelocityDesired) - 9.81f; + altitudeHoldStatus.AccelerationDesired = altitudeHoldSettings.VelocityP * (altitudeHoldStatus.VelocityDesired - velocityStateDown) - 9.81f; altitudeHoldStatus.AccelerationFiltered = accelStateDown;