Merge pull request #6090 from mikeller/improve_iterm_relax

Minor code improvements for iterm relax.
This commit is contained in:
Michael Keller 2018-07-15 12:13:00 +12:00 committed by GitHub
commit b504a4869d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -56,6 +56,8 @@
#include "sensors/acceleration.h"
#define ITERM_RELAX_SETPOINT_THRESHOLD 30.0f
FAST_RAM_ZERO_INIT uint32_t targetPidLooptime;
FAST_RAM_ZERO_INIT pidAxisData_t pidData[XYZ_AXIS_COUNT];
@ -833,7 +835,7 @@ void FAST_CODE pidController(const pidProfile_t *pidProfile, const rollAndPitchT
if (itermRelax && (axis < FD_YAW || itermRelax == ITERM_RELAX_RPY || itermRelax == ITERM_RELAX_RPY_INC)) {
const float setpointLpf = pt1FilterApply(&windupLpf[axis], currentPidSetpoint);
const float setpointHpf = fabsf(currentPidSetpoint - setpointLpf);
const float itermRelaxFactor = 1 - setpointHpf / 30.0f;
const float itermRelaxFactor = 1 - setpointHpf / ITERM_RELAX_SETPOINT_THRESHOLD;
const bool isDecreasingI = ((ITerm > 0) && (itermErrorRate < 0)) || ((ITerm < 0) && (itermErrorRate > 0));
if ((itermRelax >= ITERM_RELAX_RP_INC) && isDecreasingI) {