mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Minor code improvements for iterm relax.
This commit is contained in:
parent
ac2f39a10c
commit
80acf5a53d
1 changed files with 3 additions and 1 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue