1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-23 16:25:26 +03:00

fixed bug in updateClimbRateToAltitudeController and added logging

This commit is contained in:
Pawel Spychalski (DzikuVx) 2017-05-22 11:44:46 +02:00
parent 1c218f2301
commit f0a95f3d22
3 changed files with 8 additions and 2 deletions

View file

@ -49,5 +49,6 @@ typedef enum {
DEBUG_GYRO,
DEBUG_NOTCH,
DEBUG_NAV_LANDING_DETECTOR,
DEBUG_FW_CLIMB_RATE_TO_ALTITUDE,
DEBUG_COUNT
} debugType_e;

View file

@ -324,7 +324,8 @@ static const char * const lookupTableDebug[DEBUG_COUNT] = {
"NONE",
"GYRO",
"NOTCH",
"NAV_LANDING"
"NAV_LANDING",
"FW_ALTITUDE"
};
#ifdef TELEMETRY_LTM

View file

@ -1871,8 +1871,12 @@ void updateClimbRateToAltitudeController(float desiredClimbRate, climbRateToAlti
if (STATE(FIXED_WING)) {
// Fixed wing climb rate controller is open-loop. We simply move the known altitude target
float timeDelta = US2S(currentTimeUs - lastUpdateTimeUs);
DEBUG_SET(DEBUG_FW_CLIMB_RATE_TO_ALTITUDE, 0, desiredClimbRate);
DEBUG_SET(DEBUG_FW_CLIMB_RATE_TO_ALTITUDE, 1, timeDelta * 1000);
if (timeDelta <= HZ2S(MIN_POSITION_UPDATE_RATE_HZ)) {
posControl.desiredState.pos.V.Z = desiredClimbRate * timeDelta;
posControl.desiredState.pos.V.Z += desiredClimbRate * timeDelta;
posControl.desiredState.pos.V.Z = constrainf(posControl.desiredState.pos.V.Z, // FIXME: calculate sanity limits in a smarter way
posControl.actualState.pos.V.Z - 500,
posControl.actualState.pos.V.Z + 500);