1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-25 01:05:27 +03:00

adjust pids and smoothing; smoothing cutoff to settings

This commit is contained in:
ctzsnooze 2024-10-12 12:00:11 +11:00
parent 9b76715835
commit 996d6ee379
5 changed files with 10 additions and 9 deletions

View file

@ -1859,6 +1859,7 @@ const clivalue_t valueTable[] = {
{ PARAM_NAME_POSITION_I, VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 200 }, PG_AUTOPILOT, offsetof(autopilotConfig_t, position_I) },
{ PARAM_NAME_POSITION_D, VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 200 }, PG_AUTOPILOT, offsetof(autopilotConfig_t, position_D) },
{ PARAM_NAME_POSITION_J, VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 200 }, PG_AUTOPILOT, offsetof(autopilotConfig_t, position_J) },
{ PARAM_NAME_POSITION_CUTOFF, VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 10, 250 }, PG_AUTOPILOT, offsetof(autopilotConfig_t, position_cutoff) },
// PG_MODE_ACTIVATION_CONFIG
#if defined(USE_CUSTOM_BOX_NAMES)

View file

@ -172,6 +172,7 @@
#define PARAM_NAME_POSITION_I "autopilot_position_I"
#define PARAM_NAME_POSITION_D "autopilot_position_D"
#define PARAM_NAME_POSITION_J "autopilot_position_J"
#define PARAM_NAME_POSITION_CUTOFF "autopilot_position_cutoff"
#define PARAM_NAME_AP_DEADBAND "autopilot_deadband" // from rcControlsConfig
#define PARAM_NAME_ANGLE_FEEDFORWARD "angle_feedforward"

View file

@ -37,10 +37,10 @@
#define ALTITUDE_I_SCALE 0.003f
#define ALTITUDE_D_SCALE 0.01f
#define ALTITUDE_F_SCALE 0.01f
#define POSITION_P_SCALE 0.001f
#define POSITION_I_SCALE 0.0003f
#define POSITION_D_SCALE 0.005f
#define POSITION_J_SCALE 0.005f
#define POSITION_P_SCALE 0.003f
#define POSITION_I_SCALE 0.0f
#define POSITION_D_SCALE 0.003f
#define POSITION_J_SCALE 0.002f
static pidCoefficient_t altitudePidCoeffs;
static float altitudeI = 0.0f;
@ -70,8 +70,7 @@ void autopilotInit(const autopilotConfig_t *config)
positionPidCoeffs.Ki = config->position_I * POSITION_I_SCALE;
positionPidCoeffs.Kd = config->position_D * POSITION_D_SCALE;
positionPidCoeffs.Kf = config->position_J * POSITION_J_SCALE; // Kf used for acceleration
positionLpfCutoffHz = config->position_filter_hz / 100.0f;
positionLpfCutoffHz = config->position_cutoff / 100.0f;
const float gain = pt1FilterGain(positionLpfCutoffHz, 0.1f); // assume 10Hz GPS connection at start
pt1FilterInit(&velocityPitchLpf, gain);
pt1FilterInit(&accelerationPitchLpf, gain);

View file

@ -39,8 +39,8 @@ PG_RESET_TEMPLATE(autopilotConfig_t, autopilotConfig,
.altitude_D = 15,
.altitude_F = 15,
.position_P = 15,
.position_I = 15,
.position_I = 0,
.position_D = 15,
.position_J = 15,
.position_filter_hz = 75,
.position_cutoff = 100,
);

View file

@ -37,7 +37,7 @@ typedef struct autopilotConfig_s {
uint8_t position_I;
uint8_t position_D;
uint8_t position_J;
uint8_t position_filter_hz;
uint8_t position_cutoff;
} autopilotConfig_t;
PG_DECLARE(autopilotConfig_t, autopilotConfig);