mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 13:25:30 +03:00
Merge pull request #3832 from martinbudden/bf_pidsum_limits
PID sum limits applied before scaling
This commit is contained in:
commit
39c02c083e
3 changed files with 4 additions and 16 deletions
|
@ -117,9 +117,6 @@ float motor_disarmed[MAX_SUPPORTED_MOTORS];
|
|||
mixerMode_e currentMixerMode;
|
||||
static motorMixer_t currentMixer[MAX_SUPPORTED_MOTORS];
|
||||
|
||||
float pidSumLimit;
|
||||
float pidSumLimitYaw;
|
||||
|
||||
|
||||
static const motorMixer_t mixerQuadX[] = {
|
||||
{ 1.0f, -1.0f, 1.0f, -1.0f }, // REAR_R
|
||||
|
@ -409,12 +406,6 @@ void mixerInit(mixerMode_e mixerMode)
|
|||
initEscEndpoints();
|
||||
}
|
||||
|
||||
void pidInitMixer(const struct pidProfile_s *pidProfile)
|
||||
{
|
||||
pidSumLimit = CONVERT_PARAMETER_TO_FLOAT(pidProfile->pidSumLimit);
|
||||
pidSumLimitYaw = CONVERT_PARAMETER_TO_FLOAT(pidProfile->pidSumLimitYaw);
|
||||
}
|
||||
|
||||
#ifndef USE_QUAD_MIXER_ONLY
|
||||
|
||||
void mixerConfigureOutput(void)
|
||||
|
@ -680,17 +671,17 @@ void mixTable(uint8_t vbatPidCompensation)
|
|||
|
||||
// Calculate and Limit the PIDsum
|
||||
float scaledAxisPidRoll =
|
||||
constrainf((axisPID_P[FD_ROLL] + axisPID_I[FD_ROLL] + axisPID_D[FD_ROLL]) / PID_MIXER_SCALING, -pidSumLimit, pidSumLimit);
|
||||
constrainf(axisPID_P[FD_ROLL] + axisPID_I[FD_ROLL] + axisPID_D[FD_ROLL], -currentPidProfile->pidSumLimit, currentPidProfile->pidSumLimit) / PID_MIXER_SCALING;
|
||||
float scaledAxisPidPitch =
|
||||
constrainf((axisPID_P[FD_PITCH] + axisPID_I[FD_PITCH] + axisPID_D[FD_PITCH]) / PID_MIXER_SCALING, -pidSumLimit, pidSumLimit);
|
||||
constrainf(axisPID_P[FD_PITCH] + axisPID_I[FD_PITCH] + axisPID_D[FD_PITCH], -currentPidProfile->pidSumLimit, currentPidProfile->pidSumLimit) / PID_MIXER_SCALING;
|
||||
float scaledAxisPidYaw =
|
||||
-constrainf((axisPID_P[FD_YAW] + axisPID_I[FD_YAW]) / PID_MIXER_SCALING, -pidSumLimitYaw, pidSumLimitYaw);
|
||||
constrainf(axisPID_P[FD_YAW] + axisPID_I[FD_YAW], -currentPidProfile->pidSumLimitYaw, currentPidProfile->pidSumLimitYaw) / PID_MIXER_SCALING;
|
||||
if (isMotorsReversed()) {
|
||||
scaledAxisPidRoll = -scaledAxisPidRoll;
|
||||
scaledAxisPidPitch = -scaledAxisPidPitch;
|
||||
scaledAxisPidYaw = -scaledAxisPidYaw;
|
||||
}
|
||||
if (mixerConfig()->yaw_motors_reversed) {
|
||||
if (!mixerConfig()->yaw_motors_reversed) {
|
||||
scaledAxisPidYaw = -scaledAxisPidYaw;
|
||||
}
|
||||
|
||||
|
|
|
@ -115,8 +115,6 @@ bool mixerIsOutputSaturated(int axis, float errorRate);
|
|||
|
||||
void mixerLoadMix(int index, motorMixer_t *customMixers);
|
||||
void mixerInit(mixerMode_e mixerMode);
|
||||
struct pidProfile_s;
|
||||
void pidInitMixer(const struct pidProfile_s *pidProfile);
|
||||
|
||||
void mixerConfigureOutput(void);
|
||||
|
||||
|
|
|
@ -297,7 +297,6 @@ void pidInit(const pidProfile_t *pidProfile)
|
|||
pidSetTargetLooptime(gyro.targetLooptime * pidConfig()->pid_process_denom); // Initialize pid looptime
|
||||
pidInitFilters(pidProfile);
|
||||
pidInitConfig(pidProfile);
|
||||
pidInitMixer(pidProfile);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue