From 9dcf985b0c0ff81a7e9cb21c7adcc77d0cffc003 Mon Sep 17 00:00:00 2001 From: Alexander van Saase Date: Sat, 18 Sep 2021 23:41:45 +0200 Subject: [PATCH 1/4] Don't change P, I and D during autotune --- docs/Settings.md | 30 ------------------------------ src/main/fc/settings.yaml | 18 ------------------ src/main/flight/pid_autotune.c | 13 ------------- 3 files changed, 61 deletions(-) diff --git a/docs/Settings.md b/docs/Settings.md index 4a5f68750b..6f1bbf7af5 100644 --- a/docs/Settings.md +++ b/docs/Settings.md @@ -1152,26 +1152,6 @@ D-Series telemetry only: Set to 1 to send raw VBat value in 0.1V resolution for --- -### fw_autotune_ff_to_i_tc - -FF to I time (defines time for I to reach the same level of response as FF) [ms] - -| Default | Min | Max | -| --- | --- | --- | -| 600 | 100 | 5000 | - ---- - -### fw_autotune_ff_to_p_gain - -FF to P gain (strength relationship) [%] - -| Default | Min | Max | -| --- | --- | --- | -| 10 | 0 | 100 | - ---- - ### fw_autotune_max_rate_deflection The target percentage of maximum mixer output used for determining the rates in `AUTO` and `LIMIT`. @@ -1192,16 +1172,6 @@ Minimum stick input [%], after applying deadband and expo, to start recording th --- -### fw_autotune_p_to_d_gain - -P to D gain (strength relationship) [%] - -| Default | Min | Max | -| --- | --- | --- | -| 0 | 0 | 200 | - ---- - ### fw_autotune_rate_adjustment `AUTO` and `LIMIT` adjust the rates to match the capabilities of the airplane, with `LIMIT` they are never increased above the starting rates setting. `FIXED` does not adjust the rates. Rates are not changed when tuning in `ANGLE` mode. diff --git a/src/main/fc/settings.yaml b/src/main/fc/settings.yaml index 37f7540f61..66633f3ec7 100644 --- a/src/main/fc/settings.yaml +++ b/src/main/fc/settings.yaml @@ -2263,24 +2263,6 @@ groups: field: fw_min_stick min: 0 max: 100 - - name: fw_autotune_ff_to_p_gain - description: "FF to P gain (strength relationship) [%]" - default_value: 10 - field: fw_ff_to_p_gain - min: 0 - max: 100 - - name: fw_autotune_p_to_d_gain - description: "P to D gain (strength relationship) [%]" - default_value: 0 - field: fw_p_to_d_gain - min: 0 - max: 200 - - name: fw_autotune_ff_to_i_tc - description: "FF to I time (defines time for I to reach the same level of response as FF) [ms]" - default_value: 600 - field: fw_ff_to_i_time_constant - min: 100 - max: 5000 - name: fw_autotune_rate_adjustment description: "`AUTO` and `LIMIT` adjust the rates to match the capabilities of the airplane, with `LIMIT` they are never increased above the starting rates setting. `FIXED` does not adjust the rates. Rates are not changed when tuning in `ANGLE` mode." default_value: "AUTO" diff --git a/src/main/flight/pid_autotune.c b/src/main/flight/pid_autotune.c index 151d23be05..0b479cc7e3 100755 --- a/src/main/flight/pid_autotune.c +++ b/src/main/flight/pid_autotune.c @@ -60,9 +60,6 @@ PG_REGISTER_WITH_RESET_TEMPLATE(pidAutotuneConfig_t, pidAutotuneConfig, PG_PID_A PG_RESET_TEMPLATE(pidAutotuneConfig_t, pidAutotuneConfig, .fw_min_stick = SETTING_FW_AUTOTUNE_MIN_STICK_DEFAULT, - .fw_ff_to_p_gain = SETTING_FW_AUTOTUNE_FF_TO_P_GAIN_DEFAULT, - .fw_ff_to_i_time_constant = SETTING_FW_AUTOTUNE_FF_TO_I_TC_DEFAULT, - .fw_p_to_d_gain = SETTING_FW_AUTOTUNE_P_TO_D_GAIN_DEFAULT, .fw_rate_adjustment = SETTING_FW_AUTOTUNE_RATE_ADJUSTMENT_DEFAULT, .fw_max_rate_deflection = SETTING_FW_AUTOTUNE_MAX_RATE_DEFLECTION_DEFAULT, ); @@ -246,16 +243,6 @@ void autotuneFixedWingUpdate(const flight_dynamics_index_t axis, float desiredRa } if (gainsUpdated) { - // Set P-gain to 10% of FF gain (quite agressive - FIXME) - tuneCurrent[axis].gainP = tuneCurrent[axis].gainFF * (pidAutotuneConfig()->fw_ff_to_p_gain / 100.0f); - tuneCurrent[axis].gainP = constrainf(tuneCurrent[axis].gainP, 1.0f, 20.0f); - - // Set D-gain relative to P-gain (0 for now) - tuneCurrent[axis].gainD = tuneCurrent[axis].gainP * (pidAutotuneConfig()->fw_p_to_d_gain / 100.0f); - - // Set integrator gain to reach the same response as FF gain in 0.667 second - tuneCurrent[axis].gainI = (tuneCurrent[axis].gainFF / FP_PID_RATE_FF_MULTIPLIER) * (1000.0f / pidAutotuneConfig()->fw_ff_to_i_time_constant) * FP_PID_RATE_I_MULTIPLIER; - tuneCurrent[axis].gainI = constrainf(tuneCurrent[axis].gainI, 2.0f, 30.0f); autotuneUpdateGains(tuneCurrent); switch (axis) { From 22ba20fbe6df3bdb708dcb6ef979d8bb4a3b1376 Mon Sep 17 00:00:00 2001 From: Alexander van Saase Date: Sat, 18 Sep 2021 23:56:35 +0200 Subject: [PATCH 2/4] remove P, I and D from struct --- src/main/flight/pid_autotune.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/main/flight/pid_autotune.c b/src/main/flight/pid_autotune.c index 0b479cc7e3..98ca4b9ba6 100755 --- a/src/main/flight/pid_autotune.c +++ b/src/main/flight/pid_autotune.c @@ -72,9 +72,6 @@ typedef enum { } pidAutotuneState_e; typedef struct { - float gainP; - float gainI; - float gainD; float gainFF; float rate; float initialRate; @@ -95,9 +92,6 @@ static timeMs_t lastGainsUpdateTime; void autotuneUpdateGains(pidAutotuneData_t * data) { for (int axis = 0; axis < XYZ_AXIS_COUNT; axis++) { - pidBankMutable()->pid[axis].P = lrintf(data[axis].gainP); - pidBankMutable()->pid[axis].I = lrintf(data[axis].gainI); - pidBankMutable()->pid[axis].D = lrintf(data[axis].gainD); pidBankMutable()->pid[axis].FF = lrintf(data[axis].gainFF); ((controlRateConfig_t *)currentControlRateProfile)->stabilized.rates[axis] = lrintf(data[axis].rate/10.0f); } @@ -121,9 +115,6 @@ void autotuneCheckUpdateGains(void) void autotuneStart(void) { for (int axis = 0; axis < XYZ_AXIS_COUNT; axis++) { - tuneCurrent[axis].gainP = pidBank()->pid[axis].P; - tuneCurrent[axis].gainI = pidBank()->pid[axis].I; - tuneCurrent[axis].gainD = pidBank()->pid[axis].D; tuneCurrent[axis].gainFF = pidBank()->pid[axis].FF; tuneCurrent[axis].rate = currentControlRateProfile->stabilized.rates[axis] * 10.0f; tuneCurrent[axis].initialRate = currentControlRateProfile->stabilized.rates[axis] * 10.0f; From 2d440dd57306759ce1c73e69f9d03006a6362fb3 Mon Sep 17 00:00:00 2001 From: Alexander van Saase Date: Sun, 19 Sep 2021 00:03:28 +0200 Subject: [PATCH 3/4] remove defines --- src/main/flight/pid_autotune.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/flight/pid_autotune.c b/src/main/flight/pid_autotune.c index 98ca4b9ba6..3f57480524 100755 --- a/src/main/flight/pid_autotune.c +++ b/src/main/flight/pid_autotune.c @@ -46,8 +46,6 @@ #include "flight/pid.h" -#define AUTOTUNE_FIXED_WING_MIN_FF 10 -#define AUTOTUNE_FIXED_WING_MAX_FF 255 #define AUTOTUNE_FIXED_WING_MIN_ROLL_PITCH_RATE 40 #define AUTOTUNE_FIXED_WING_MIN_YAW_RATE 10 #define AUTOTUNE_FIXED_WING_MAX_RATE 720 From b18d9ba8cada9069d285165677cf74a9d5a19496 Mon Sep 17 00:00:00 2001 From: Alexander van Saase Date: Sun, 19 Sep 2021 00:16:37 +0200 Subject: [PATCH 4/4] Revert "remove defines" This reverts commit 2d440dd57306759ce1c73e69f9d03006a6362fb3. --- src/main/flight/pid_autotune.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/flight/pid_autotune.c b/src/main/flight/pid_autotune.c index 3f57480524..98ca4b9ba6 100755 --- a/src/main/flight/pid_autotune.c +++ b/src/main/flight/pid_autotune.c @@ -46,6 +46,8 @@ #include "flight/pid.h" +#define AUTOTUNE_FIXED_WING_MIN_FF 10 +#define AUTOTUNE_FIXED_WING_MAX_FF 255 #define AUTOTUNE_FIXED_WING_MIN_ROLL_PITCH_RATE 40 #define AUTOTUNE_FIXED_WING_MIN_YAW_RATE 10 #define AUTOTUNE_FIXED_WING_MAX_RATE 720