Merge pull request #6090 from mikeller/improve_iterm_relax
Minor code improvements for iterm relax.
This commit is contained in:
commit
b504a4869d
|
@ -56,6 +56,8 @@
|
||||||
#include "sensors/acceleration.h"
|
#include "sensors/acceleration.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define ITERM_RELAX_SETPOINT_THRESHOLD 30.0f
|
||||||
|
|
||||||
FAST_RAM_ZERO_INIT uint32_t targetPidLooptime;
|
FAST_RAM_ZERO_INIT uint32_t targetPidLooptime;
|
||||||
FAST_RAM_ZERO_INIT pidAxisData_t pidData[XYZ_AXIS_COUNT];
|
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)) {
|
if (itermRelax && (axis < FD_YAW || itermRelax == ITERM_RELAX_RPY || itermRelax == ITERM_RELAX_RPY_INC)) {
|
||||||
const float setpointLpf = pt1FilterApply(&windupLpf[axis], currentPidSetpoint);
|
const float setpointLpf = pt1FilterApply(&windupLpf[axis], currentPidSetpoint);
|
||||||
const float setpointHpf = fabsf(currentPidSetpoint - setpointLpf);
|
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));
|
const bool isDecreasingI = ((ITerm > 0) && (itermErrorRate < 0)) || ((ITerm < 0) && (itermErrorRate > 0));
|
||||||
if ((itermRelax >= ITERM_RELAX_RP_INC) && isDecreasingI) {
|
if ((itermRelax >= ITERM_RELAX_RP_INC) && isDecreasingI) {
|
||||||
|
|
Loading…
Reference in New Issue