Move parameter from PID profile to rate profile
This commit is contained in:
parent
fc189e5850
commit
357d19aa05
|
@ -61,7 +61,8 @@ void pgResetFn_controlRateProfiles(controlRateConfig_t *controlRateConfig)
|
|||
.throttle_limit_percent = 100,
|
||||
.rate_limit[FD_ROLL] = CONTROL_RATE_CONFIG_RATE_LIMIT_MAX,
|
||||
.rate_limit[FD_PITCH] = CONTROL_RATE_CONFIG_RATE_LIMIT_MAX,
|
||||
.rate_limit[FD_YAW] = CONTROL_RATE_CONFIG_RATE_LIMIT_MAX
|
||||
.rate_limit[FD_YAW] = CONTROL_RATE_CONFIG_RATE_LIMIT_MAX,
|
||||
.tpaMode = TPA_MODE_PD,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,12 @@ typedef enum {
|
|||
THROTTLE_LIMIT_TYPE_CLIP,
|
||||
} throttleLimitType_e;
|
||||
|
||||
|
||||
typedef enum {
|
||||
TPA_MODE_PD,
|
||||
TPA_MODE_D
|
||||
} tpaMode_e;
|
||||
|
||||
typedef struct controlRateConfig_s {
|
||||
uint8_t thrMid8;
|
||||
uint8_t thrExpo8;
|
||||
|
@ -49,6 +55,7 @@ typedef struct controlRateConfig_s {
|
|||
uint8_t throttle_limit_type; // Sets the throttle limiting type - off, scale or clip
|
||||
uint8_t throttle_limit_percent; // Sets the maximum pilot commanded throttle limit
|
||||
uint16_t rate_limit[3]; // Sets the maximum rate for the axes
|
||||
uint8_t tpaMode; // Controls which PID terms TPA effects
|
||||
} controlRateConfig_t;
|
||||
|
||||
PG_DECLARE_ARRAY(controlRateConfig_t, CONTROL_RATE_PROFILE_COUNT, controlRateProfiles);
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "drivers/sound_beeper.h"
|
||||
#include "drivers/time.h"
|
||||
|
||||
#include "fc/controlrate_profile.h"
|
||||
#include "fc/core.h"
|
||||
#include "fc/rc.h"
|
||||
|
||||
|
@ -175,7 +176,6 @@ void resetPidProfile(pidProfile_t *pidProfile)
|
|||
.launchControlAngleLimit = 0,
|
||||
.launchControlGain = 40,
|
||||
.launchControlAllowTriggerReset = true,
|
||||
.tpaMode = TPA_MODE_PD,
|
||||
);
|
||||
#ifdef USE_DYN_LPF
|
||||
pidProfile->dterm_lowpass_hz = 120;
|
||||
|
@ -435,10 +435,6 @@ static FAST_RAM_ZERO_INIT uint8_t launchControlAngleLimit;
|
|||
static FAST_RAM_ZERO_INIT float launchControlKi;
|
||||
#endif
|
||||
|
||||
#ifdef USE_TPA_MODE
|
||||
static FAST_RAM_ZERO_INIT uint8_t tpaMode;
|
||||
#endif
|
||||
|
||||
void pidResetIterm(void)
|
||||
{
|
||||
for (int axis = 0; axis < 3; axis++) {
|
||||
|
@ -581,10 +577,6 @@ void pidInitConfig(const pidProfile_t *pidProfile)
|
|||
}
|
||||
launchControlKi = ITERM_SCALE * pidProfile->launchControlGain;
|
||||
#endif
|
||||
|
||||
#ifdef USE_TPA_MODE
|
||||
tpaMode = pidProfile->tpaMode;
|
||||
#endif
|
||||
}
|
||||
|
||||
void pidInit(const pidProfile_t *pidProfile)
|
||||
|
@ -1058,7 +1050,7 @@ void FAST_CODE pidController(const pidProfile_t *pidProfile, const rollAndPitchT
|
|||
const float tpaFactor = getThrottlePIDAttenuation();
|
||||
|
||||
#ifdef USE_TPA_MODE
|
||||
const float tpaFactorKp = (tpaMode == TPA_MODE_PD) ? tpaFactor : 1.0f;
|
||||
const float tpaFactorKp = (currentControlRateProfile->tpaMode == TPA_MODE_PD) ? tpaFactor : 1.0f;
|
||||
#else
|
||||
const float tpaFactorKp = tpaFactor;
|
||||
#endif
|
||||
|
|
|
@ -97,11 +97,6 @@ typedef enum {
|
|||
ITERM_RELAX_SETPOINT
|
||||
} itermRelaxType_e;
|
||||
|
||||
typedef enum {
|
||||
TPA_MODE_PD,
|
||||
TPA_MODE_D
|
||||
} tpaMode_e;
|
||||
|
||||
typedef struct pidProfile_s {
|
||||
uint16_t yaw_lowpass_hz; // Additional yaw filter when yaw axis too noisy
|
||||
uint16_t dterm_lowpass_hz; // Delta Filter in hz
|
||||
|
@ -161,7 +156,6 @@ typedef struct pidProfile_s {
|
|||
uint8_t launchControlAngleLimit; // Optional launch control angle limit (requires ACC)
|
||||
uint8_t launchControlGain; // Iterm gain used while launch control is active
|
||||
uint8_t launchControlAllowTriggerReset; // Controls trigger behavior and whether the trigger can be reset
|
||||
uint8_t tpaMode; // Controls which PID terms TPA effects
|
||||
} pidProfile_t;
|
||||
|
||||
PG_DECLARE_ARRAY(pidProfile_t, MAX_PROFILE_COUNT, pidProfiles);
|
||||
|
|
|
@ -787,6 +787,9 @@ const clivalue_t valueTable[] = {
|
|||
{ "yaw_srate", VAR_UINT8 | PROFILE_RATE_VALUE, .config.minmax = { 0, CONTROL_RATE_CONFIG_RATE_MAX }, PG_CONTROL_RATE_PROFILES, offsetof(controlRateConfig_t, rates[FD_YAW]) },
|
||||
{ "tpa_rate", VAR_UINT8 | PROFILE_RATE_VALUE, .config.minmax = { 0, CONTROL_RATE_CONFIG_TPA_MAX}, PG_CONTROL_RATE_PROFILES, offsetof(controlRateConfig_t, dynThrPID) },
|
||||
{ "tpa_breakpoint", VAR_UINT16 | PROFILE_RATE_VALUE, .config.minmax = { PWM_PULSE_MIN, PWM_PULSE_MAX }, PG_CONTROL_RATE_PROFILES, offsetof(controlRateConfig_t, tpa_breakpoint) },
|
||||
#ifdef USE_TPA_MODE
|
||||
{ "tpa_mode", VAR_UINT8 | PROFILE_RATE_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_TPA_MODE }, PG_CONTROL_RATE_PROFILES, offsetof(controlRateConfig_t, tpaMode) },
|
||||
#endif
|
||||
{ "throttle_limit_type", VAR_UINT8 | PROFILE_RATE_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_THROTTLE_LIMIT_TYPE }, PG_CONTROL_RATE_PROFILES, offsetof(controlRateConfig_t, throttle_limit_type) },
|
||||
{ "throttle_limit_percent", VAR_UINT8 | PROFILE_RATE_VALUE, .config.minmax = { 25, 100 }, PG_CONTROL_RATE_PROFILES, offsetof(controlRateConfig_t, throttle_limit_percent) },
|
||||
{ "roll_rate_limit", VAR_UINT16 | PROFILE_RATE_VALUE, .config.minmax = { CONTROL_RATE_CONFIG_RATE_LIMIT_MIN, CONTROL_RATE_CONFIG_RATE_LIMIT_MAX }, PG_CONTROL_RATE_PROFILES, offsetof(controlRateConfig_t, rate_limit[FD_ROLL]) },
|
||||
|
@ -938,10 +941,6 @@ const clivalue_t valueTable[] = {
|
|||
{ "launch_control_gain", VAR_UINT8 | PROFILE_VALUE, .config.minmax = { 0, 200 }, PG_PID_PROFILE, offsetof(pidProfile_t, launchControlGain) },
|
||||
#endif
|
||||
|
||||
#ifdef USE_TPA_MODE
|
||||
{ "tpa_mode", VAR_UINT8 | PROFILE_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_TPA_MODE }, PG_PID_PROFILE, offsetof(pidProfile_t, tpaMode) },
|
||||
#endif
|
||||
|
||||
// PG_TELEMETRY_CONFIG
|
||||
#ifdef USE_TELEMETRY
|
||||
{ "tlm_inverted", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_TELEMETRY_CONFIG, offsetof(telemetryConfig_t, telemetry_inverted) },
|
||||
|
|
Loading…
Reference in New Issue