Skip to content

Commit f312980

Browse files
committed
Add feedforward component of pidf
1 parent 7f7726f commit f312980

File tree

7 files changed

+116
-61
lines changed

7 files changed

+116
-61
lines changed

css/header_dialog.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,10 @@ input[type="number"]::-webkit-inner-spin-button {
265265
border-right: 0 solid #ccc;
266266
}
267267

268-
.header-dialog table td {
268+
.header-dialog table td,
269+
.header-dialog .pid_titlebar th {
269270
padding: 1px;
270-
width: 25%;
271+
width: 20%;
271272
border-right: 1px solid #ccc;
272273
}
273274

index.html

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -664,11 +664,12 @@ <h5 class="modal-title-craft"></h5>
664664
<th class="proportional">Proportional</th>
665665
<th class="integral">Integral</th>
666666
<th class="derivative">Derivative</th>
667+
<th class="feedforward">Feedforward</th>
667668
</tr>
668669
</table>
669670
<table id="pid_main" class="pid_tuning">
670671
<tr>
671-
<th colspan="4">
672+
<th colspan="5">
672673
<div class="pid_mode">Basic/Acro</div>
673674
</th>
674675
</tr>
@@ -684,6 +685,9 @@ <h5 class="modal-title-craft"></h5>
684685
<td>
685686
<input type="number" name="d" step="1" min="0" max="255" />
686687
</td>
688+
<td>
689+
<input type="number" name="f" step="1" min="0" max="255" />
690+
</td>
687691
</tr>
688692
<tr class="pitchPID">
689693
<!-- 1 -->
@@ -697,6 +701,9 @@ <h5 class="modal-title-craft"></h5>
697701
<td>
698702
<input type="number" name="d" step="1" min="0" max="255" />
699703
</td>
704+
<td>
705+
<input type="number" name="f" step="1" min="0" max="255" />
706+
</td>
700707
</tr>
701708
<tr class="yawPID">
702709
<!-- 2 -->
@@ -710,11 +717,14 @@ <h5 class="modal-title-craft"></h5>
710717
<td>
711718
<input type="number" name="d" step="1" min="0" max="255" />
712719
</td>
720+
<td>
721+
<input type="number" name="f" step="1" min="0" max="255" />
722+
</td>
713723
</tr>
714724
</table>
715725
<table id="pid_baro" class="pid_tuning">
716726
<tr>
717-
<th colspan="4">
727+
<th colspan="5">
718728
<div class="pid_mode">Barometer & Sonar/Altitude</div>
719729
</th>
720730
</tr>
@@ -730,6 +740,7 @@ <h5 class="modal-title-craft"></h5>
730740
<td>
731741
<input type="number" name="d" step="1" min="0" max="255" />
732742
</td>
743+
<td></td>
733744
</tr>
734745
<tr class="velPID">
735746
<!-- 9 -->
@@ -743,11 +754,12 @@ <h5 class="modal-title-craft"></h5>
743754
<td>
744755
<input type="number" name="d" step="1" min="0" max="255" />
745756
</td>
757+
<td></td>
746758
</tr>
747759
</table>
748760
<table id="pid_mag" class="pid_tuning">
749761
<tr>
750-
<th colspan="4">
762+
<th colspan="5">
751763
<div class="pid_mode">Heading</div>
752764
</th>
753765
</tr>
@@ -759,11 +771,12 @@ <h5 class="modal-title-craft"></h5>
759771
</td>
760772
<td></td>
761773
<td></td>
774+
<td></td>
762775
</tr>
763776
</table>
764777
<table id="pid_gps" class="pid_tuning">
765778
<tr>
766-
<th colspan="4">
779+
<th colspan="5">
767780
<div class="pid_mode">GPS</div>
768781
</th>
769782
</tr>
@@ -777,6 +790,7 @@ <h5 class="modal-title-craft"></h5>
777790
<input type="number" name="i" step="0.01" min="0" max="2.55" />
778791
</td>
779792
<td></td>
793+
<td></td>
780794
</tr>
781795
<tr class="posrPID">
782796
<!-- 5 -->
@@ -790,6 +804,7 @@ <h5 class="modal-title-craft"></h5>
790804
<td>
791805
<input type="number" name="d" step="0.001" min="0" max="0.255" />
792806
</td>
807+
<td></td>
793808
</tr>
794809
<tr class="navrPID">
795810
<!-- 6 -->
@@ -803,6 +818,7 @@ <h5 class="modal-title-craft"></h5>
803818
<td>
804819
<input type="number" name="d" step="0.001" min="0" max="0.255" />
805820
</td>
821+
<td></td>
806822
</tr>
807823
</table>
808824
<table id="pid_accel" class="pid_tuning">
@@ -848,6 +864,12 @@ <h5 class="modal-title-craft"></h5>
848864
<br/>&nbsp;</label>
849865
<input type="number" step="0.01" min="0" max="999" />
850866
</td>
867+
<td name="feedforward_transition" class="bf-only">
868+
<label>Feedforward
869+
<br>Transition
870+
<br/>&nbsp;</label>
871+
<input type="number" step="0.01" min="0" max="999" />
872+
</td>
851873
<td name="setpointRelaxRatio" class="bf-only">
852874
<label>Setpoint Relax
853875
<br>Ratio

js/flightlog.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,9 @@ function FlightLog(logData) {
521521
sysConfig,
522522
attitude,
523523

524-
axisPID = [[fieldNameToIndex["axisP[0]"], fieldNameToIndex["axisI[0]"], fieldNameToIndex["axisD[0]"]],
525-
[fieldNameToIndex["axisP[1]"], fieldNameToIndex["axisI[1]"], fieldNameToIndex["axisD[1]"]],
526-
[fieldNameToIndex["axisP[2]"], fieldNameToIndex["axisI[2]"], fieldNameToIndex["axisD[2]"]]];
524+
axisPID = [[fieldNameToIndex["axisP[0]"], fieldNameToIndex["axisI[0]"], fieldNameToIndex["axisD[0]"], fieldNameToIndex["axisF[0]"]],
525+
[fieldNameToIndex["axisP[1]"], fieldNameToIndex["axisI[1]"], fieldNameToIndex["axisD[1]"], fieldNameToIndex["axisF[1]"]],
526+
[fieldNameToIndex["axisP[2]"], fieldNameToIndex["axisI[2]"], fieldNameToIndex["axisD[2]"], fieldNameToIndex["axisF[2]"]]];
527527

528528
if (destChunks.length === 0) {
529529
return;
@@ -573,12 +573,13 @@ function FlightLog(logData) {
573573
destFrame[fieldIndex++] = attitude.pitch;
574574
destFrame[fieldIndex++] = attitude.heading;
575575

576-
// Add the PID sum
576+
// Add the PIDF sum (P+I+D+F)
577577
for (var axis = 0; axis < 3; axis++) {
578578
destFrame[fieldIndex++] =
579579
(axisPID[axis][0] !== undefined ? srcFrame[axisPID[axis][0]] : 0) +
580580
(axisPID[axis][1] !== undefined ? srcFrame[axisPID[axis][1]] : 0) +
581-
(axisPID[axis][2] !== undefined ? srcFrame[axisPID[axis][2]] : 0);
581+
(axisPID[axis][2] !== undefined ? srcFrame[axisPID[axis][2]] : 0) +
582+
(axisPID[axis][3] !== undefined ? srcFrame[axisPID[axis][3]] : 0);
582583
}
583584

584585
// Check the current flightmode (we need to know this so that we can correctly calculate the rates)

js/flightlog_fields_presenter.js

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,37 @@ function FlightLogFieldPresenter() {
66
(function() {
77
var FRIENDLY_FIELD_NAMES = {
88

9-
'axisP[all]': 'PID P',
10-
'axisP[0]': 'PID P [roll]',
11-
'axisP[1]': 'PID P [pitch]',
12-
'axisP[2]': 'PID P [yaw]',
9+
'axisP[all]': 'PIDF P',
10+
'axisP[0]': 'PIDF P [roll]',
11+
'axisP[1]': 'PIDF P [pitch]',
12+
'axisP[2]': 'PIDF P [yaw]',
1313

14-
'axisI[all]': 'PID I',
15-
'axisI[0]': 'PID I [roll]',
16-
'axisI[1]': 'PID I [pitch]',
17-
'axisI[2]': 'PID I [yaw]',
14+
'axisI[all]': 'PIDF I',
15+
'axisI[0]': 'PIDF I [roll]',
16+
'axisI[1]': 'PIDF I [pitch]',
17+
'axisI[2]': 'PIDF I [yaw]',
1818

19-
'axisD[all]': 'PID D',
20-
'axisD[0]': 'PID D [roll]',
21-
'axisD[1]': 'PID D [pitch]',
22-
'axisD[2]': 'PID D [yaw]',
19+
'axisD[all]': 'PIDF D',
20+
'axisD[0]': 'PIDF D [roll]',
21+
'axisD[1]': 'PIDF D [pitch]',
22+
'axisD[2]': 'PIDF D [yaw]',
23+
24+
'axisF[all]': 'PIDF F',
25+
'axisF[0]': 'PIDF F [roll]',
26+
'axisF[1]': 'PIDF F [pitch]',
27+
'axisF[2]': 'PIDF F [yaw]',
2328

2429
//Virtual field
25-
'axisSum[all]': 'PID Sum',
26-
'axisSum[0]' : 'PID Sum [roll]',
27-
'axisSum[1]' : 'PID Sum [pitch]',
28-
'axisSum[2]' : 'PID Sum [yaw]',
30+
'axisSum[all]': 'PIDF Sum',
31+
'axisSum[0]' : 'PIDF Sum [roll]',
32+
'axisSum[1]' : 'PIDF Sum [pitch]',
33+
'axisSum[2]' : 'PIDF Sum [yaw]',
2934

3035
//Virtual field
31-
'axisError[all]': 'PID Error',
32-
'axisError[0]' : 'PID Error [roll]',
33-
'axisError[1]' : 'PID Error [pitch]',
34-
'axisError[2]' : 'PID Error [yaw]',
36+
'axisError[all]': 'PIDF Error',
37+
'axisError[0]' : 'PIDF Error [roll]',
38+
'axisError[1]' : 'PIDF Error [pitch]',
39+
'axisError[2]' : 'PIDF Error [yaw]',
3540

3641
//Virtual field
3742
'rcCommands[all]': 'RC Rates',
@@ -357,6 +362,9 @@ function FlightLogFieldPresenter() {
357362
case 'axisD[0]':
358363
case 'axisD[1]':
359364
case 'axisD[2]':
365+
case 'axisF[0]':
366+
case 'axisF[1]':
367+
case 'axisF[2]':
360368
return flightLog.getPIDPercentage(value).toFixed(1) + "%";
361369

362370
case 'accSmooth[0]':

js/flightlog_parser.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ var FlightLogParser = function(logData) {
215215
rollPID:[null, null, null], // Roll [P, I, D]
216216
pitchPID:[null, null, null], // Pitch[P, I, D]
217217
yawPID:[null, null, null], // Yaw [P, I, D]
218+
feedforward_transition:null, // Feedforward transition
218219
altPID:[null, null, null], // Altitude Hold [P, I, D]
219220
posPID:[null, null, null], // Position Hold [P, I, D]
220221
posrPID:[null, null, null], // Position Rate [P, I, D]
@@ -271,7 +272,7 @@ var FlightLogParser = function(logData) {
271272
},
272273

273274
// Translation of the field values name to the sysConfig var where it must be stored
274-
translationValues = {
275+
translationValues = {
275276
acc_limit_yaw : "yawRateAccelLimit",
276277
accel_limit : "rateAccelLimit",
277278
acc_limit : "rateAccelLimit",
@@ -545,6 +546,7 @@ var FlightLogParser = function(logData) {
545546
case "itermWindupPointPercent":
546547
case "ptermSRateWeight":
547548
case "setpointRelaxRatio":
549+
case "feedforward_transition":
548550
case "dtermSetpointWeight":
549551
case "gyro_soft_type":
550552
case "gyro_soft2_type":
@@ -643,6 +645,14 @@ var FlightLogParser = function(logData) {
643645
case "magPID":
644646
that.sysConfig.magPID = parseCommaSeparatedString(fieldValue,3); //[parseInt(fieldValue, 10), null, null];
645647
break;
648+
649+
case "feedforward_weight":
650+
// Add it to the end of the rollPID, pitchPID and yawPID
651+
var ffValues = parseCommaSeparatedString(fieldValue);
652+
that.sysConfig["rollPID"].push(ffValues[0]);
653+
that.sysConfig["pitchPID"].push(ffValues[1]);
654+
that.sysConfig["yawPID"].push(ffValues[2]);
655+
break;
646656
/* End of CSV packed values */
647657

648658
case "vbatcellvoltage":

js/graph_config.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,24 +191,24 @@ GraphConfig.load = function(config) {
191191
fields: ["rcCommand[all]"]
192192
},
193193
{
194-
label: "PIDs",
194+
label: "PIDFs",
195195
fields: ["axisSum[all]"]
196196
},
197197
{
198-
label: "PID Error",
198+
label: "PIDF Error",
199199
fields: ["axisError[all]"]
200200
},
201201
{
202-
label: "Gyro + PID roll",
203-
fields: ["axisP[0]", "axisI[0]", "axisD[0]", "gyroADC[0]"]
202+
label: "Gyro + PIDF roll",
203+
fields: ["axisP[0]", "axisI[0]", "axisD[0]", "axisF[0]", "gyroADC[0]"]
204204
},
205205
{
206-
label: "Gyro + PID pitch",
207-
fields: ["axisP[1]", "axisI[1]", "axisD[1]", "gyroADC[1]"]
206+
label: "Gyro + PIDF pitch",
207+
fields: ["axisP[1]", "axisI[1]", "axisD[1]", "axisF[1]", "gyroADC[1]"]
208208
},
209209
{
210-
label: "Gyro + PID yaw",
211-
fields: ["axisP[2]", "axisI[2]", "axisD[2]", "gyroADC[2]"]
210+
label: "Gyro + PIDF yaw",
211+
fields: ["axisP[2]", "axisI[2]", "axisD[2]", "axisF[2]", "gyroADC[2]"]
212212
},
213213
{
214214
label: "Accelerometers",

0 commit comments

Comments
 (0)