1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

LP-411 AutoTune limit outer PID - dRonin PR 1283

This commit is contained in:
Cliff Geerdes 2016-09-26 15:33:25 -04:00 committed by Laurent Lalanne
parent 47bbf2cd33
commit 27d6b04b58
2 changed files with 22 additions and 3 deletions

View File

@ -948,8 +948,26 @@ static void ComputeStabilizationAndSetPidsFromDampAndNoise(float dampRate, float
// inner loop as a single order lpf. Set the outer loop to be
// critically damped;
const float zeta_o = 1.3f;
const float kp_o = 1.0f / 4.0f / (zeta_o * zeta_o) / (1.0f / wn);
const float ki_o = 0.75f * kp_o / (2.0f * M_PI_F * tau * 10.0f);
float kp_o = 1.0f / 4.0f / (zeta_o * zeta_o) / (1.0f / wn);
// Except, if this is very high, we may be slew rate limited and pick
// up oscillation that way. Fix it with very soft clamping.
// (dRonin) MaximumRate defaults to 350, 6.5 corresponds to where we begin
// clamping rate ourselves. ESCs, etc, it depends upon gains
// and any pre-emphasis they do. Still give ourselves partial credit
// for inner loop bandwidth.
// In dRonin, MaximumRate defaults to 350 and they begin clamping at outer Kp 6.5
// To avoid oscillation, find the minimum rate, calculate the ratio of that to 350,
// and scale (linearly) with that. Skip yaw. There is no outer yaw in the GUI.
const uint16_t minRate = MIN(stabSettingsBank.MaximumRate.Roll, stabSettingsBank.MaximumRate.Pitch);
const float kp_o_clamp = systemIdentSettings.OuterLoopKpSoftClamp * ((float)minRate / 350.0f);
if (kp_o > kp_o_clamp) {
kp_o = kp_o_clamp - sqrtf(kp_o_clamp) + sqrtf(kp_o);
}
kp_o *= 0.95f; // Pick up some margin.
// Add a zero at 1/15th the innermost bandwidth.
const float ki_o = 0.75f * kp_o / (2.0f * M_PI_F * tau * 15.0f);
float kpMax = 0.0f;
float betaMinLn = 1000.0f;

View File

@ -54,7 +54,8 @@
<!-- Cliff sluggish 500 quad thinks that yaw P should be about 5.8 times roll/pitch P, but can easily (and better) live with 2.6 -->
<field name="YawToRollPitchPIDRatioMin" units="" type="float" elements="1" defaultvalue="1.0" description="Setting: Yaw PID will be at least this times Pitch PID (if enabled)"/>
<field name="YawToRollPitchPIDRatioMax" units="" type="float" elements="1" defaultvalue="2.5" description="Setting: Yaw PID will be at most this times Pitch PID (if enabled)"/>
<field name="DerivativeFactor" units="" type="float" elements="1" defaultvalue="1.0" limits="%BE:0:1" description="Setting: Reduce this toward zero if you have D term oscillations, it will reduce PID D terms"/>
<field name="DerivativeFactor" units="" type="float" elements="1" defaultvalue="1.0" limits="%BE:0:1" description="Setting: Multiplicative factor. If you have D term oscillations, reduce it toward zero and it will reduce PID D terms."/>
<field name="OuterLoopKpSoftClamp" units="" type="float" elements="1" defaultvalue="6.5" limits="%BE:0:100" description="Setting: Change this to change the outer loop Kp and Ki limiting"/>
<field name="DestinationPidBank" units="bank#" type="uint8" elements="1" defaultvalue="3" limits="%BE:1:3" description="Setting: Which bank the calculated PIDs will be stored in after tuning"/>
<field name="TuningDuration" units="s" type="uint8" elements="1" defaultvalue="60" limits="%BI:0" description="Setting: Duration of the tuning motions (expert)"/>
<!-- SmoothQuickSource: the smooth vs. quick PID selector -->