diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index 078a8b247e..17f002bc00 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -140,7 +140,7 @@ void resetPidProfile(pidProfile_t *pidProfile) .throttle_boost_cutoff = 15, .iterm_rotation = false, .smart_feedforward = false, - .iterm_relax = false, + .iterm_relax = ITERM_RELAX_OFF, .iterm_relax_cutoff_low = 3, .iterm_relax_cutoff_high = 15, ); @@ -202,7 +202,7 @@ static FAST_RAM_ZERO_INIT pt1Filter_t dtermLowpass2[2]; static FAST_RAM_ZERO_INIT filterApplyFnPtr ptermYawLowpassApplyFn; static FAST_RAM_ZERO_INIT pt1Filter_t ptermYawLowpass; static FAST_RAM_ZERO_INIT pt1Filter_t windupLpf[3][2]; -static FAST_RAM_ZERO_INIT uint8_t itermRelax; +static FAST_RAM_ZERO_INIT itermRelax_e itermRelax; static FAST_RAM_ZERO_INIT uint8_t itermRelaxCutoffLow; static FAST_RAM_ZERO_INIT uint8_t itermRelaxCutoffHigh; @@ -628,7 +628,7 @@ void FAST_CODE pidController(const pidProfile_t *pidProfile, const rollAndPitchT // -----calculate I component float itermErrorRate; - if (itermRelax && (axis < FD_YAW || itermRelax == 2 )) { + if (itermRelax && (axis < FD_YAW || itermRelax == ITERM_RELAX_RPY )) { const float gyroTargetLow = pt1FilterApply(&windupLpf[axis][0], currentPidSetpoint); const float gyroTargetHigh = pt1FilterApply(&windupLpf[axis][1], currentPidSetpoint); if (axis < FD_YAW) { diff --git a/src/main/flight/pid.h b/src/main/flight/pid.h index 56d00a9aa6..71852390e2 100644 --- a/src/main/flight/pid.h +++ b/src/main/flight/pid.h @@ -76,6 +76,15 @@ typedef struct pid8_s { uint8_t D; } pid8_t; +typedef enum +{ + ITERM_RELAX_OFF, + ITERM_RELAX_RP, + ITERM_RELAX_RPY +} itermRelax_e; + + + typedef struct pidProfile_s { pid8_t pid[PID_ITEM_COUNT]; @@ -118,7 +127,7 @@ typedef struct pidProfile_s { uint8_t smart_feedforward; // takes only the larger of P and the D weight feed forward term if they have the same sign. uint8_t iterm_relax_cutoff_low; // Slowest setpoint response to prevent iterm accumulation uint8_t iterm_relax_cutoff_high; // Fastest setpoint response to prevent iterm accumulation - uint8_t iterm_relax; // Enable iterm suppression during stick input + itermRelax_e iterm_relax; // Enable iterm suppression during stick input } pidProfile_t;