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

Merge pull request #1495 from mikeller/fix_pid_scaling_for_servos

Changed scaling of axisPID to be local to mixer only, since the servos need unscaled axisPID.
This commit is contained in:
borisbstyle 2016-11-08 11:13:28 +01:00 committed by GitHub
commit 6dfa099f94

View file

@ -452,9 +452,10 @@ void mixTable(pidProfile_t *pidProfile)
throttle = constrainf((throttle - rxConfig->mincheck) / rcCommandThrottleRange, 0.0f, 1.0f); throttle = constrainf((throttle - rxConfig->mincheck) / rcCommandThrottleRange, 0.0f, 1.0f);
throttleRange = motorOutputMax - motorOutputMin; throttleRange = motorOutputMax - motorOutputMin;
float scaledAxisPIDf[3];
// Limit the PIDsum // Limit the PIDsum
for (int axis = 0; axis < 3; axis++) for (int axis = 0; axis < 3; axis++)
axisPIDf[axis] = constrainf(axisPIDf[axis] / PID_MIXER_SCALING, -pidProfile->pidSumLimit, pidProfile->pidSumLimit); scaledAxisPIDf[axis] = constrainf(axisPIDf[axis] / PID_MIXER_SCALING, -pidProfile->pidSumLimit, pidProfile->pidSumLimit);
// Calculate voltage compensation // Calculate voltage compensation
if (batteryConfig && pidProfile->vbatPidCompensation) vbatCompensationFactor = calculateVbatPidCompensation(); if (batteryConfig && pidProfile->vbatPidCompensation) vbatCompensationFactor = calculateVbatPidCompensation();
@ -462,9 +463,9 @@ void mixTable(pidProfile_t *pidProfile)
// Find roll/pitch/yaw desired output // Find roll/pitch/yaw desired output
for (i = 0; i < motorCount; i++) { for (i = 0; i < motorCount; i++) {
motorMix[i] = motorMix[i] =
axisPIDf[PITCH] * currentMixer[i].pitch + scaledAxisPIDf[PITCH] * currentMixer[i].pitch +
axisPIDf[ROLL] * currentMixer[i].roll + scaledAxisPIDf[ROLL] * currentMixer[i].roll +
-mixerConfig->yaw_motor_direction * axisPIDf[YAW] * currentMixer[i].yaw; -mixerConfig->yaw_motor_direction * scaledAxisPIDf[YAW] * currentMixer[i].yaw;
if (vbatCompensationFactor > 1.0f) motorMix[i] *= vbatCompensationFactor; // Add voltage compensation if (vbatCompensationFactor > 1.0f) motorMix[i] *= vbatCompensationFactor; // Add voltage compensation