mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 01:05:27 +03:00
Merge pull request #9482 from ctzsnooze/Revert-iTerm-Relax
Restore proper behaviour of iterm_relax_cutoff in setpoint mode
This commit is contained in:
commit
c984107291
4 changed files with 6 additions and 9 deletions
|
@ -1020,7 +1020,7 @@ const clivalue_t valueTable[] = {
|
|||
#if defined(USE_ITERM_RELAX)
|
||||
{ "iterm_relax", VAR_UINT8 | PROFILE_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_ITERM_RELAX }, PG_PID_PROFILE, offsetof(pidProfile_t, iterm_relax) },
|
||||
{ "iterm_relax_type", VAR_UINT8 | PROFILE_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_ITERM_RELAX_TYPE }, PG_PID_PROFILE, offsetof(pidProfile_t, iterm_relax_type) },
|
||||
{ "iterm_relax_cutoff", VAR_UINT8 | PROFILE_VALUE, .config.minmaxUnsigned = { 1, 100 }, PG_PID_PROFILE, offsetof(pidProfile_t, iterm_relax_cutoff) },
|
||||
{ "iterm_relax_cutoff", VAR_UINT8 | PROFILE_VALUE, .config.minmaxUnsigned = { 1, 50 }, PG_PID_PROFILE, offsetof(pidProfile_t, iterm_relax_cutoff) },
|
||||
#endif
|
||||
{ "iterm_windup", VAR_UINT8 | PROFILE_VALUE, .config.minmaxUnsigned = { 30, 100 }, PG_PID_PROFILE, offsetof(pidProfile_t, itermWindupPointPercent) },
|
||||
{ "iterm_limit", VAR_UINT16 | PROFILE_VALUE, .config.minmaxUnsigned = { 0, 500 }, PG_PID_PROFILE, offsetof(pidProfile_t, itermLimit) },
|
||||
|
|
|
@ -461,7 +461,7 @@ static const OSD_Entry cmsx_menuProfileOtherEntries[] = {
|
|||
#ifdef USE_ITERM_RELAX
|
||||
{ "I_RELAX", OME_TAB, NULL, &(OSD_TAB_t) { &cmsx_iterm_relax, ITERM_RELAX_COUNT - 1, lookupTableItermRelax }, 0 },
|
||||
{ "I_RELAX TYPE", OME_TAB, NULL, &(OSD_TAB_t) { &cmsx_iterm_relax_type, ITERM_RELAX_TYPE_COUNT - 1, lookupTableItermRelaxType }, 0 },
|
||||
{ "I_RELAX CUTOFF", OME_UINT8, NULL, &(OSD_UINT8_t) { &cmsx_iterm_relax_cutoff, 1, 100, 1 }, 0 },
|
||||
{ "I_RELAX CUTOFF", OME_UINT8, NULL, &(OSD_UINT8_t) { &cmsx_iterm_relax_cutoff, 1, 50, 1 }, 0 },
|
||||
#endif
|
||||
#ifdef USE_LAUNCH_CONTROL
|
||||
{"LAUNCH CONTROL", OME_Submenu, cmsMenuChange, &cmsx_menuLaunchControl, 0 },
|
||||
|
|
|
@ -283,7 +283,6 @@ static FAST_RAM_ZERO_INIT pt1Filter_t windupLpf[XYZ_AXIS_COUNT];
|
|||
static FAST_RAM_ZERO_INIT uint8_t itermRelax;
|
||||
static FAST_RAM_ZERO_INIT uint8_t itermRelaxType;
|
||||
static uint8_t itermRelaxCutoff;
|
||||
static FAST_RAM_ZERO_INIT float itermRelaxSetpointThreshold;
|
||||
#endif
|
||||
|
||||
#if defined(USE_ABSOLUTE_CONTROL)
|
||||
|
@ -668,8 +667,6 @@ void pidInitConfig(const pidProfile_t *pidProfile)
|
|||
itermRelax = pidProfile->iterm_relax;
|
||||
itermRelaxType = pidProfile->iterm_relax_type;
|
||||
itermRelaxCutoff = pidProfile->iterm_relax_cutoff;
|
||||
// adapt setpoint threshold to user changes from default cutoff value
|
||||
itermRelaxSetpointThreshold = ITERM_RELAX_SETPOINT_THRESHOLD * ITERM_RELAX_CUTOFF_DEFAULT / itermRelaxCutoff;
|
||||
#endif
|
||||
|
||||
#ifdef USE_ACRO_TRAINER
|
||||
|
@ -1166,7 +1163,7 @@ STATIC_UNIT_TESTED void applyItermRelax(const int axis, const float iterm,
|
|||
|
||||
if (itermRelax) {
|
||||
if (axis < FD_YAW || itermRelax == ITERM_RELAX_RPY || itermRelax == ITERM_RELAX_RPY_INC) {
|
||||
const float itermRelaxFactor = MAX(0, 1 - setpointHpf / itermRelaxSetpointThreshold);
|
||||
const float itermRelaxFactor = MAX(0, 1 - setpointHpf / ITERM_RELAX_SETPOINT_THRESHOLD);
|
||||
const bool isDecreasingI =
|
||||
((iterm > 0) && (*itermErrorRate < 0)) || ((iterm < 0) && (*itermErrorRate > 0));
|
||||
if ((itermRelax >= ITERM_RELAX_RP_INC) && isDecreasingI) {
|
||||
|
|
|
@ -542,9 +542,9 @@ TEST(pidControllerTest, testItermRelax) {
|
|||
EXPECT_NEAR(-8.16, itermErrorRate, calculateTolerance(-8.16));
|
||||
currentPidSetpoint += ITERM_RELAX_SETPOINT_THRESHOLD;
|
||||
applyItermRelax(FD_PITCH, pidData[FD_PITCH].I, gyroRate, &itermErrorRate, ¤tPidSetpoint);
|
||||
EXPECT_NEAR(-2.69, itermErrorRate, calculateTolerance(-2.69));
|
||||
EXPECT_NEAR(0, itermErrorRate, calculateTolerance(0));
|
||||
applyItermRelax(FD_PITCH, pidData[FD_PITCH].I, gyroRate, &itermErrorRate, ¤tPidSetpoint);
|
||||
EXPECT_NEAR(-0.84, itermErrorRate, calculateTolerance(-0.84));
|
||||
EXPECT_NEAR(0, itermErrorRate, calculateTolerance(0));
|
||||
|
||||
pidProfile->iterm_relax_type = ITERM_RELAX_GYRO;
|
||||
pidInit(pidProfile);
|
||||
|
@ -588,7 +588,7 @@ TEST(pidControllerTest, testItermRelax) {
|
|||
pidProfile->iterm_relax = ITERM_RELAX_RPY;
|
||||
pidInit(pidProfile);
|
||||
applyItermRelax(FD_YAW, pidData[FD_YAW].I, gyroRate, &itermErrorRate, ¤tPidSetpoint);
|
||||
EXPECT_NEAR(-6.46, itermErrorRate, calculateTolerance(-3.6));
|
||||
EXPECT_NEAR(-3.6, itermErrorRate, calculateTolerance(-3.6));
|
||||
}
|
||||
|
||||
// TODO - Add more tests
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue