Skip to content

Commit eb13746

Browse files
Gary KeebleGary Keeble
authored andcommitted
Add Pitch/Roll and Yaw Rate Parameters
New feature : Adding pitch/roll and yaw rate parameters that were active when log was made will allow rcCommand to show actual deg/s value alongside raw input. This is then used to calculate new PID_Error values as deg/s
1 parent b90d0d6 commit eb13746

File tree

4 files changed

+197
-26
lines changed

4 files changed

+197
-26
lines changed

index.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ <h2>Legend <span class="log-close-legend-dialog glyphicon glyphicon-remove"></sp
235235
<div class="log-graph-legend">
236236
</div>
237237
<button type="button" class="btn btn-default btn-block hide-analyser-window">Hide Analyser</button>
238+
<button type="button" class="btn btn-default btn-block open-log-setup-dialog">Log Setup</button>
238239
<button type="button" class="btn btn-default btn-block open-graph-configuration-dialog">Graph setup</button>
239240
</div>
240241
</div>
@@ -287,6 +288,31 @@ <h4 class="modal-title">Configure graphs</h4>
287288
</div>
288289
</div>
289290

291+
<div class="modal fade" id="dlgFlightLogSetup">
292+
<div class="modal-dialog">
293+
<div class="modal-content">
294+
<div class="modal-header">
295+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
296+
<span aria-hidden="true">&times;</span>
297+
</button>
298+
<h4 class="modal-title">Setup Log Viewer</h4>
299+
</div>
300+
<div class="modal-body">
301+
<div class="btn-group">
302+
<ul class="dropdown-menu" role="menu">
303+
</ul>
304+
</div>
305+
<ul class="list-unstyled setup-flightlog-list">
306+
</ul>
307+
</div>
308+
<div class="modal-footer">
309+
<button type="button" class="btn btn-default flightlog-setup-dialog-cancel" data-dismiss="modal">Cancel</button>
310+
<button type="button" class="btn btn-primary flightlog-setup-dialog-save" data-dismiss="modal">Save changes</button>
311+
</div>
312+
</div>
313+
</div>
314+
</div>
315+
290316
<div class="modal fade" id="dlgVideoExport">
291317
<div class="modal-dialog">
292318
<div class="modal-content">
@@ -420,6 +446,7 @@ <h4 class="modal-title">Export video</h4>
420446
<script src="js/flightlog_fields_presenter.js"></script>
421447
<script src="js/flightlog_parser.js"></script>
422448
<script src="js/flightlog_index.js"></script>
449+
<script src="js/flightlog_setup_dialog.js"></script>
423450
<script src="js/flightlog.js"></script>
424451
<script src="js/grapher.js"></script>
425452
<script src="js/graph_config.js"></script>

js/flightlog.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,31 @@ function FlightLog(logData) {
3333
maxSmoothing = 0,
3434

3535
smoothedCache = new FIFOCache(2);
36+
3637

3738
//Public fields:
3839
this.parser = parser;
3940

41+
this.settings = [ // FlightLog Settings
42+
{ label: "Rates",
43+
parameters:
44+
[
45+
{ // Index 0
46+
label: "Roll Rate",
47+
value: 75
48+
},
49+
{ // Index 1
50+
label: "Pitch Rate",
51+
value: 75
52+
},
53+
{ // Index 2
54+
label: "Yaw Rate",
55+
value: 45
56+
}
57+
]
58+
},
59+
];
60+
4061
this.getMainFieldCount = function() {
4162
return fieldNames.length;
4263
};
@@ -898,34 +919,13 @@ FlightLog.prototype.rcCommandRawToDegreesPerSecond = function(value, axis) {
898919
// Axis 0,1 refers to Roll and Pitch
899920
// Axis 2 refers to Yaw.
900921

901-
var rRate = 65; // Roll Rate from configuration
902-
var pRate = 65; // Pitch Rate from configuration
903-
var yRate = 65; // Yaw Rate from configuration
904-
905-
var REWRITE = true; // Define that this is for the Rewrite Data - need to make dynamic!
922+
// ReWrite or LUXFloat only
906923

907-
if(REWRITE) // PID is ReWrite
908-
{
909-
if(axis==0 /*ROLL*/) {
910-
return ((rRate + 27) * value ) >> 6;
911-
}
912-
if(axis==1 /*PITCH*/) {
913-
return ((pRate + 27) * value ) >> 6;
914-
}
915-
if(axis==2 /*YAW*/) {
916-
return ((yRate + 27) * value ) >> 7;
924+
if(axis==2 /*YAW*/) {
925+
return ((this.settings[0].parameters[axis].value + 47) * value ) >> 7;
926+
} else { /*ROLL or PITCH */
927+
return ((this.settings[0].parameters[axis].value + 27) * value ) >> 6;
917928
}
918-
} else { // PID is Luxfloat
919-
if(axis==0 /*ROLL*/) {
920-
return ((rRate+20)*value) / 50;
921-
}
922-
if(axis==1 /*PITCH*/) {
923-
return ((pRate+20)*value) / 50;
924-
}
925-
if(axis==2 /*YAW*/) {
926-
return ((yRate+10)*value) / 50;
927-
}
928-
}
929929
};
930930

931931

js/flightlog_setup_dialog.js

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
"use strict";
2+
3+
function FlightLogSetupDialog(dialog, onSave) {
4+
5+
function renderParameter(parameter) {
6+
var
7+
elem = $(
8+
'<li class="setup-parameter">'
9+
+ '<label class="col-sm-2 control-label">' + parameter.label + '</label>'
10+
+ '<input class="form-control" type="text" placeholder="Enter the value">'
11+
+ '</li>'
12+
);
13+
14+
$("input", elem).val(parameter.value);
15+
16+
return elem;
17+
}
18+
19+
function renderParameters(setting) {
20+
var
21+
parametersElem = $(
22+
'<li class="setup-parameters">'
23+
+ '<dl>'
24+
+ '<dt><h4>' + setting.label + '</dt>'
25+
+ '<dd>'
26+
+ '<div class="form-horizontal">'
27+
+ '<div class="form-group form-group-sm">'
28+
+ '<ul class="setup-parameter-list form-inline list-unstyled"></ul>'
29+
+ '</div>'
30+
+ '</div>'
31+
+ '</dd>'
32+
+ '</dl>'
33+
+ '</li>'
34+
),
35+
parameterList = $(".setup-parameter-list", parametersElem);
36+
37+
for (var i = 0; i < setting.parameters.length; i++) {
38+
var
39+
parameter = setting.parameters[i],
40+
parameterElem = renderParameter(parameter);
41+
42+
parameterList.append(parameterElem);
43+
}
44+
45+
return parametersElem;
46+
}
47+
48+
function renderSettings(flightLog) {
49+
var
50+
settingsList = $(".setup-flightlog-list", dialog);
51+
52+
settingsList.empty();
53+
54+
for (var i = 0; i < flightLog.settings.length; i++) {
55+
settingsList.append(renderParameters(flightLog.settings[i]));
56+
}
57+
}
58+
59+
function convertUIToFlightLogSettings() {
60+
var
61+
settings = [],
62+
setting,
63+
parameter;
64+
65+
$(".setup-parameters", dialog).each(function() {
66+
setting = {
67+
label: '',
68+
parameters: []
69+
};
70+
71+
setting.label = $("h4", this).text();
72+
73+
$(".setup-parameter", this).each(function() {
74+
parameter = {
75+
label: $("label", this).text(),
76+
value: parseInt($("input[type='text']", this).val()),
77+
};
78+
setting.parameters.push(parameter);
79+
});
80+
81+
settings.push(setting);
82+
});
83+
84+
return settings;
85+
}
86+
87+
this.show = function(flightLog, settings) {
88+
dialog.modal('show');
89+
90+
// Assign the settings
91+
flightLog.settings = settings;
92+
93+
renderSettings(flightLog);
94+
};
95+
96+
$(".flightlog-setup-dialog-save").click(function(e) {
97+
onSave(convertUIToFlightLogSettings());
98+
});
99+
100+
101+
}

js/main.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ function BlackboxLogViewer() {
3838
// JSON graph configuration:
3939
graphConfig = {},
4040

41+
// JSON flightlog configuration
42+
flightLogSettings = {},
43+
4144
// Graph configuration which is currently in use, customised based on the current flight log from graphConfig
4245
activeGraphConfig = new GraphConfig(),
4346

@@ -548,6 +551,33 @@ function BlackboxLogViewer() {
548551
}
549552
});
550553

554+
prefs.get('flightLogSettings', function(item) {
555+
if(item) {
556+
flightLogSettings = item;
557+
} else {
558+
flightLogSettings = [ // FlightLog Default Settings
559+
{ label: "Rates",
560+
parameters:
561+
[
562+
{ // Index 0
563+
label: "Roll Rate",
564+
value: 75
565+
},
566+
{ // Index 1
567+
label: "Pitch Rate",
568+
value: 75
569+
},
570+
{ // Index 2
571+
label: "Yaw Rate",
572+
value: 45
573+
}
574+
]
575+
},
576+
];
577+
}
578+
});
579+
580+
551581
activeGraphConfig.addListener(function() {
552582
invalidateGraph();
553583
});
@@ -666,6 +696,13 @@ function BlackboxLogViewer() {
666696
prefs.set('graphConfig', graphConfig);
667697
}),
668698

699+
flightLogSetupDialog = new FlightLogSetupDialog($("#dlgFlightLogSetup"), function(newSettings) {
700+
flightLog.settings = newSettings; // Store the settings to the flightlog
701+
702+
flightLogSettings = newSettings; // Let's write this information to the local store
703+
prefs.set('flightLogSettings', flightLogSettings);
704+
}),
705+
669706
exportDialog = new VideoExportDialog($("#dlgVideoExport"), function(newConfig) {
670707
videoConfig = newConfig;
671708

@@ -679,6 +716,12 @@ function BlackboxLogViewer() {
679716
graphConfigDialog.show(flightLog, graphConfig);
680717
});
681718

719+
$(".open-log-setup-dialog").click(function(e) {
720+
e.preventDefault();
721+
722+
flightLogSetupDialog.show(flightLog, flightLogSettings);
723+
});
724+
682725
if (FlightLogVideoRenderer.isSupported()) {
683726
$(".btn-video-export").click(function(e) {
684727
setGraphState(GRAPH_STATE_PAUSED);

0 commit comments

Comments
 (0)