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

LP-67 handle full PIDs terms with a single knob for each axis (roll/pitch).

The new setting will work this way:
- Input (knob) value is used straight as roll or pitch P term;
- P term is mutliplied by two configurable factors and used as D and I terms;
- (Optionally) Yaw P term is calculated from a mean of roll and pitch P terms multiplied by a configurable factor.
- yaw P term is multiplied by other two configurable factors and used as yaw D and I terms.
This commit is contained in:
Alessio Morale 2015-07-29 07:19:54 +02:00
parent faa5d0fb4a
commit ee461ff303
2 changed files with 23 additions and 2 deletions

View File

@ -253,6 +253,16 @@ static void updatePIDs(UAVObjEvent *ev)
case TXPIDSETTINGS_PIDS_ROLLRATEKP:
needsUpdateBank |= update(&bank.RollRatePID.Kp, value);
break;
case TXPIDSETTINGS_PIDS_ROLLRATEPID:
needsUpdateBank |= update(&bank.RollRatePID.Kp, value);
needsUpdateBank |= update(&bank.RollRatePID.Ki, value * inst.PitchRollRateFactors.I);
needsUpdateBank |= update(&bank.RollRatePID.Kd, value * inst.PitchRollRateFactors.D);
break;
case TXPIDSETTINGS_PIDS_PITCHRATEPID:
needsUpdateBank |= update(&bank.PitchRatePID.Kp, value);
needsUpdateBank |= update(&bank.PitchRatePID.Ki, value * inst.PitchRollRateFactors.I);
needsUpdateBank |= update(&bank.PitchRatePID.Kd, value * inst.PitchRollRateFactors.D);
break;
case TXPIDSETTINGS_PIDS_ROLLRATEKI:
needsUpdateBank |= update(&bank.RollRatePID.Ki, value);
break;
@ -437,6 +447,11 @@ static void updatePIDs(UAVObjEvent *ev)
}
#endif
if (needsUpdateBank) {
if(inst.RatePIDRecalculateYaw == TXPIDSETTINGS_RATEPIDRECALCULATEYAW_ENABLED){
update(&bank.YawRatePID.Kp, (bank.RollRatePID.Kp + bank.PitchRatePID.Kp) * .5f * inst.YawRateFactors.P);
update(&bank.YawRatePID.Ki, bank.YawRatePID.Kp * inst.YawRateFactors.I);
update(&bank.YawRatePID.Kd, bank.YawRatePID.Kp * inst.YawRateFactors.D);
}
switch (inst.BankNumber) {
case 0:
StabilizationSettingsBank1Set((StabilizationSettingsBank1Data *)&bank);

View File

@ -7,10 +7,11 @@
elementnames="Instance1,Instance2,Instance3"
options="Throttle,Accessory0,Accessory1,Accessory2,Accessory3,Accessory4,Accessory5"
defaultvalue="Throttle,Accessory0,Accessory1"/>
<field name="ThrottleRange" units="%" type="float" elements="2" elementnames="Min,Max" defaultvalue="0.20,0.80"/>
<field name="PIDs" units="option" type="enum"
<field name="ThrottleRange" units="%" type="float" elements="2" elementnames="Min,Max" defaultvalue="0.20,0.80"/>
<field name="PIDs" units="option" type="enum"
elementnames="Instance1,Instance2,Instance3"
options="Disabled,
PitchRatePID,RollRatePID,
Roll Rate.Kp, Roll Rate.Ki, Roll Rate.Kd, Roll Rate.ILimit, Roll Rate.Resp,
Pitch Rate.Kp, Pitch Rate.Ki, Pitch Rate.Kd, Pitch Rate.ILimit, Pitch Rate.Resp,
Roll+Pitch Rate.Kp, Roll+Pitch Rate.Ki, Roll+Pitch Rate.Kd, Roll+Pitch Rate.ILimit, Roll+Pitch Rate.Resp,
@ -23,9 +24,14 @@
GyroTau,Acro+ Roll Factor,Acro+ Pitch Factor,Acro+ Roll+Pitch Factor,Altitude Pos.Kp,Altitude Velocity.Kp,Altitude Velocity.Ki,Altitude Velocity.Kd,Altitude Velocity.Beta,
AccelTau, AccelKp, AccelKi"
defaultvalue="Disabled"/>
<field name="MinPID" units="" type="float" elementnames="Instance1,Instance2,Instance3" defaultvalue="0"/>
<field name="MaxPID" units="" type="float" elementnames="Instance1,Instance2,Instance3" defaultvalue="0"/>
<field name="PitchRollRateFactors" units="" type="float" elementnames="I,D" defaultvalue="3,0.0135"/>
<field name="YawRateFactors" units="" type="float" elementnames="P,I,D" defaultvalue="1.5,1.9,0.0085"/>
<field name="RatePIDRecalculateYaw" units="" type="enum" elements="1" options="Disabled,Enabled" defaultvalue="Disabled"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/>