1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

Changed AH to work with absolute instead of relative altitude

This commit is contained in:
Werner Backes 2013-06-29 12:18:29 +02:00 committed by Alessio Morale
parent aecc8543a5
commit 45ed66414f
2 changed files with 5 additions and 6 deletions

View File

@ -174,10 +174,6 @@ static void altitudeHoldTask(__attribute__((unused)) void *parameters)
error = 0;
velocity = 0;
running = true;
AltHoldSmoothedData altHold;
AltHoldSmoothedGet(&altHold);
starting_altitude = altHold.Altitude;
} else if (!altitudeHoldFlightMode) {
running = false;
lastAltitudeHoldDesiredUpdate = PIOS_DELAY_GetRaw();
@ -364,7 +360,7 @@ static void altitudeHoldTask(__attribute__((unused)) void *parameters)
}
// Compute the altitude error
error = (starting_altitude + altitudeHoldDesired.Altitude) - altHold.Altitude;
error = altitudeHoldDesired.Altitude - altHold.Altitude;
// Compute integral off altitude error
throttleIntegral += error * altitudeHoldSettings.Ki * dT;

View File

@ -38,6 +38,7 @@
#include "accessorydesired.h"
#include "actuatordesired.h"
#include "altitudeholddesired.h"
#include "altholdsmoothed.h
#include "flighttelemetrystats.h"
#include "flightstatus.h"
#include "sanitycheck.h"
@ -859,7 +860,9 @@ static void altitudeHoldDesired(ManualControlCommandData *cmd, bool changed)
PositionStateDownGet(&currentDown);
if (changed) {
// After not being in this mode for a while init at current height
altitudeHoldDesiredData.Altitude = 0;
AltHoldSmoothedData altHold;
AltHoldSmoothedGet(&altHold);
altitudeHoldDesiredData.Altitude = altHold.Altitude;
zeroed = false;
} else if (cmd->Throttle > DEADBAND_HIGH && zeroed) {
// being the two band symmetrical I can divide by DEADBAND_LOW to scale it to a value betweeon 0 and 1