Skip to content

Commit

Permalink
Fix TTA headroom calculation in Gov Passthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
pmattila committed Mar 25, 2024
1 parent aaa8e19 commit b081b56
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/flight/governor.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,13 @@ static void govUpdateData(void)
if (mixerMotorizedTail() && gov.TTAGain != 0) {
float YAW = mixerGetInput(MIXER_IN_STABILIZED_YAW);
float TTA = filterApply(&gov.TTAFilter, YAW) * getSpoolUpRatio() * gov.TTAGain;
float headroom = 2 * fmaxf(gov.TTALimit - gov.fullHeadSpeedRatio, 0);
float headroom = 0;

if (gov.mode > GM_PASSTHROUGH)
headroom = 2 * fmaxf(1.0f + gov.TTALimit - gov.fullHeadSpeedRatio, 0);
else
headroom = gov.TTALimit;

gov.TTAAdd = constrainf(TTA, 0, headroom);

DEBUG(TTA, 0, YAW * 1000);
Expand Down Expand Up @@ -1009,7 +1015,7 @@ void governorInitProfile(const pidProfile_t *pidProfile)
gov.Kf = pidProfile->governor.f_gain / 100.0f;

gov.TTAGain = mixerRotationSign() * pidProfile->governor.tta_gain / -125.0f;
gov.TTALimit = pidProfile->governor.tta_limit / 100.0f + 1.0f;
gov.TTALimit = pidProfile->governor.tta_limit / 100.0f;

if (gov.mode >= GM_STANDARD)
gov.TTAGain /= gov.K * gov.Kp;
Expand Down

0 comments on commit b081b56

Please sign in to comment.