1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-24 00:35:39 +03:00

iTermRelaxFactor now only attenuates amount added

The original setpoint based iTerm Relax code attenuated the amount of iTerm added per loop by a relax factor based on an HPF of setpoint.
At some point the code was re-factored and the relax factor multiplied the accumulating iterm error itself, such that almost any relax factor below 1.0 would quickly zero out iTerm.
This was bad for racing because when making sustained tight turns, I would abrubtly be zeroed when the setpoint for the starting of some relax was close to the threshold.
This was never the intent of the original proposal, which was for a smoother attenuation of iTerm, and for retention of some accumulation of iTerm during spirals around poles etc.
This PR fixes that error.
It also changes the default threshold up from 30 deg/s to 40 deg/s which better suits racing.
Also included us a form of simple cutoff independence. In the initial form, lowering cutoff would reduce the effectiveness but draw out the duration.  Now cutoff only really affects duration.
Lower cutoff values are better for quads with greater motor delay, faster values are better for quicker quads. For most of my quads a cutoff of 30 works best.
I've also removed newlines.

set to current cutoff maybe fix unit test

default cutoff set to current value

in unit test add itermRelaxSetpointThreshold as float

in unit test add itermRelaxSetpointThreshold as float, because ITERM_RELAX_SETPOINT_THRESHOLD doesn't exist any more

Move itermRelaxFactor limit, remove from fast ram

remove unncessary max, revert unit test changes, restore original defaults.

remove max from debug
restore old defaults and revert unit test changes temporarily to see if will pass unit test with defaults

whoops

lets see if unit test passes when cutoff is 20

lets see if unit test passes when cutoff is 20
This commit is contained in:
ctzsnooze 2019-02-26 12:23:21 +11:00 committed by mikeller
parent 750e7c30cf
commit 1d998ea404
3 changed files with 9 additions and 8 deletions

View file

@ -129,7 +129,7 @@ void setDefaultTestSettings(void) {
pidProfile->iterm_rotation = false;
pidProfile->smart_feedforward = false,
pidProfile->iterm_relax = ITERM_RELAX_OFF,
pidProfile->iterm_relax_cutoff = 11,
pidProfile->iterm_relax_cutoff = 20,
pidProfile->iterm_relax_type = ITERM_RELAX_SETPOINT,
pidProfile->abs_control_gain = 0,
pidProfile->launchControlMode = LAUNCH_CONTROL_MODE_NORMAL,