Skip to content

Commit 2ec67e8

Browse files
committed
Change RC Rate and RC Command
Change the meaning of this graphs to more useful values. The RC Command now shows the input of the sticks in us, and the RC Rate the deg/s of this input.
1 parent b4932bf commit 2ec67e8

File tree

3 files changed

+52
-45
lines changed

3 files changed

+52
-45
lines changed

js/flightlog.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212
function FlightLog(logData) {
1313
var
14-
ADDITIONAL_COMPUTED_FIELD_COUNT = 15, /** attitude + PID_SUM + PID_ERROR + RCCOMMAND_SCALED + GYROADC_SCALED **/
14+
ADDITIONAL_COMPUTED_FIELD_COUNT = 16, /** attitude + PID_SUM + PID_ERROR + RCCOMMAND_SCALED + GYROADC_SCALED **/
1515

1616
that = this,
1717
logIndex = false,
@@ -226,7 +226,7 @@ function FlightLog(logData) {
226226
fieldNames.push("heading[0]", "heading[1]", "heading[2]");
227227
fieldNames.push("axisSum[0]", "axisSum[1]", "axisSum[2]");
228228
fieldNames.push("axisError[0]", "axisError[1]", "axisError[2]"); // Custom calculated error field
229-
fieldNames.push("rcCommands[0]", "rcCommands[1]", "rcCommands[2]"); // Custom calculated error field
229+
fieldNames.push("rcCommands[0]", "rcCommands[1]", "rcCommands[2]", "rcCommands[3]"); // Custom calculated scaled rccommand
230230
fieldNames.push("gyroADCs[0]", "gyroADCs[1]", "gyroADCs[2]"); // Custom calculated error field
231231

232232
fieldNameToIndex = {};
@@ -512,7 +512,7 @@ function FlightLog(logData) {
512512
gyroADC = [fieldNameToIndex["gyroADC[0]"], fieldNameToIndex["gyroADC[1]"], fieldNameToIndex["gyroADC[2]"]],
513513
accSmooth = [fieldNameToIndex["accSmooth[0]"], fieldNameToIndex["accSmooth[1]"], fieldNameToIndex["accSmooth[2]"]],
514514
magADC = [fieldNameToIndex["magADC[0]"], fieldNameToIndex["magADC[1]"], fieldNameToIndex["magADC[2]"]],
515-
rcCommand = [fieldNameToIndex["rcCommand[0]"], fieldNameToIndex["rcCommand[1]"], fieldNameToIndex["rcCommand[2]"]],
515+
rcCommand = [fieldNameToIndex["rcCommand[0]"], fieldNameToIndex["rcCommand[1]"], fieldNameToIndex["rcCommand[2]"], fieldNameToIndex["rcCommand[3]"]],
516516

517517
flightModeFlagsIndex = fieldNameToIndex["flightModeFlags"], // This points to the flightmode data
518518

@@ -590,11 +590,17 @@ function FlightLog(logData) {
590590
(gyroADC[axis] !== undefined ? that.gyroRawToDegreesPerSecond(srcFrame[gyroADC[axis]]) : 0) -
591591
(rcCommand[axis] !== undefined ? that.rcCommandRawToDegreesPerSecond(srcFrame[rcCommand[axis]], axis, currentFlightMode) : 0);
592592
}
593-
// Calculate the Scaled rcCommand (in deg/s)
594-
for (var axis = 0; axis < 3; axis++) {
595-
destFrame[fieldIndex++] =
596-
(rcCommand[axis] !== undefined ? that.rcCommandRawToDegreesPerSecond(srcFrame[rcCommand[axis]], axis, currentFlightMode) : 0);
593+
594+
// Calculate the Scaled rcCommand (RC Rate)(in deg/s, % for throttle)
595+
for (var axis = 0; axis < 4; axis++) {
596+
if (axis <= AXIS.YAW) {
597+
destFrame[fieldIndex++] =
598+
(rcCommand[axis] !== undefined ? that.rcCommandRawToDegreesPerSecond(srcFrame[rcCommand[axis]], axis, currentFlightMode) : 0);
599+
} else {
600+
destFrame[fieldIndex++] =
601+
(rcCommand[axis] !== undefined ? that.rcCommandRawToThrottle(srcFrame[rcCommand[axis]]) : 0);
597602
}
603+
}
598604

599605
// Calculate the scaled Gyro ADC
600606
for (var axis = 0; axis < 3; axis++) {

js/flightlog_fields_presenter.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ function FlightLogFieldPresenter() {
1818
'axisD[1]': 'PID_D[pitch]',
1919
'axisD[2]': 'PID_D[yaw]',
2020

21-
'rcCommand[all]': 'rcCommand',
22-
'rcCommand[0]': 'rcCommand[roll]',
23-
'rcCommand[1]': 'rcCommand[pitch]',
24-
'rcCommand[2]': 'rcCommand[yaw]',
25-
'rcCommand[3]': 'rcCommand[throttle]',
21+
'rcCommand[all]': 'RC Command',
22+
'rcCommand[0]': 'RC Command[roll]',
23+
'rcCommand[1]': 'RC Command[pitch]',
24+
'rcCommand[2]': 'RC Command[yaw]',
25+
'rcCommand[3]': 'RC Command[throttle]',
2626

2727
'gyroADC[all]': 'gyro',
2828
'gyroADC[0]': 'gyro[roll]',
@@ -68,10 +68,11 @@ function FlightLogFieldPresenter() {
6868
'axisError[2]' : 'PID_Error[yaw]',
6969

7070
//Virtual fields - add the Scaled rcCommands
71-
'rcCommands[all]': 'setpointRates',
72-
'rcCommands[0]' : 'setpointRate[roll]',
73-
'rcCommands[1]' : 'setpointRate[pitch]',
74-
'rcCommands[2]' : 'setpointRate[yaw]',
71+
'rcCommands[all]': 'RC Rates',
72+
'rcCommands[0]' : 'RC Rate[roll]',
73+
'rcCommands[1]' : 'RC Rate[pitch]',
74+
'rcCommands[2]' : 'RC Rate[yaw]',
75+
'rcCommands[3]' : 'RC Rate[throttle]',
7576

7677
//Virtual fields - add the Scaled gyros
7778
'gyroADCs[all]': 'gyros',
@@ -292,14 +293,12 @@ function FlightLogFieldPresenter() {
292293
return Math.round(value) + " deg/s";
293294

294295
case 'rcCommand[0]':
295-
return Math.round(flightLog.rcCommandRawToDegreesPerSecond(value,0), currentFlightMode) + " deg/s";
296296
case 'rcCommand[1]':
297-
return Math.round(flightLog.rcCommandRawToDegreesPerSecond(value,1), currentFlightMode) + " deg/s";
298297
case 'rcCommand[2]':
299-
return Math.round(flightLog.rcCommandRawToDegreesPerSecond(value,2), currentFlightMode) + " deg/s";
300-
298+
return (value + 1500).toFixed(0) + " us";
301299
case 'rcCommand[3]':
302-
return Math.round(flightLog.rcCommandRawToThrottle(value)) + " %";
300+
return value.toFixed(0) + " us";
301+
303302
case 'motor[0]':
304303
case 'motor[1]':
305304
case 'motor[2]':
@@ -314,7 +313,9 @@ function FlightLogFieldPresenter() {
314313
case 'rcCommands[1]':
315314
case 'rcCommands[2]':
316315
return value.toFixed(0) + " deg/s";
317-
316+
case 'rcCommands[3]':
317+
return value.toFixed(0) + "%";
318+
318319
case 'axisSum[0]':
319320
case 'axisSum[1]':
320321
case 'axisSum[2]':

js/graph_config.js

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ function GraphConfig(graphConfig) {
107107

108108
for (var k = 0; k < logFieldNames.length; k++) {
109109
if (logFieldNames[k].match(nameRegex)) {
110-
// add special condition for rcCommand as each of the fields requires a different scaling.
111-
newGraph.fields.push(adaptField($.extend({}, field, {name: logFieldNames[k]}), colorIndexOffset, (nameRoot=='rcCommand')));
110+
// add special condition for rcCommands as each of the fields requires a different scaling.
111+
newGraph.fields.push(adaptField($.extend({}, field, {name: logFieldNames[k]}), colorIndexOffset, (nameRoot=='rcCommands')));
112112
colorIndexOffset++;
113113
}
114114
}
@@ -181,7 +181,11 @@ GraphConfig.load = function(config) {
181181
label: "Gyros",
182182
fields: ["gyroADC[all]"]
183183
},
184-
{ /* Add custom graph configurations to the main menu ! */
184+
{ /* Add custom graph configurations to the main menu ! */
185+
label: "RC Rates",
186+
fields: ["rcCommands[all]"]
187+
},
188+
{
185189
label: "RC Command",
186190
fields: ["rcCommand[all]"]
187191
},
@@ -248,27 +252,30 @@ GraphConfig.load = function(config) {
248252
inputRange: 500,
249253
outputRange: 1.0
250254
};
251-
} else if (fieldName.match(/^gyroADC\[/)) {
252-
return {
253-
offset: 0,
254-
power: 0.25, /* Make this 1.0 to scale linearly */
255-
inputRange: (2.0e-3 * Math.PI/180) / sysConfig.gyroScale,
256-
outputRange: 1.0
257-
};
258255
} else if (fieldName.match(/^accSmooth\[/)) {
259256
return {
260257
offset: 0,
261258
power: 0.5,
262259
inputRange: sysConfig.acc_1G * 16.0, /* Reasonable typical maximum for acc */
263260
outputRange: 1.0
264261
};
265-
} else if (fieldName.match(/^axisError\[/) || // Custom Gyro, rcCommand and axisError Scaling
262+
} else if (fieldName == "rcCommands[3]") { // Throttle scaled
263+
return {
264+
offset: -50,
265+
power: 1.0, /* Make this 1.0 to scale linearly */
266+
inputRange: 50,
267+
outputRange: 1.0
268+
};
269+
} else if (fieldName.match(/^axisError\[/) || // Gyro, Gyro Scaled, RC Command Scaled and axisError
266270
fieldName.match(/^rcCommands\[/) || // These use the same scaling as they are in the
267-
fieldName.match(/^gyroADCs\[/) ) { // same range.
271+
fieldName.match(/^gyroADCs\[/) || // same range.
272+
fieldName.match(/^gyroADC\[/)) {
268273
return {
269274
offset: 0,
270275
power: 0.25, /* Make this 1.0 to scale linearly */
271-
inputRange: flightLog.gyroRawToDegreesPerSecond((2.0e-3 * Math.PI/180) / sysConfig.gyroScale),
276+
inputRange: Math.max(flightLog.rcCommandRawToDegreesPerSecond(500,0) * 1.20,
277+
flightLog.rcCommandRawToDegreesPerSecond(500,1) * 1.20,
278+
flightLog.rcCommandRawToDegreesPerSecond(500,2) * 1.20), // Maximum grad/s + 20%
272279
outputRange: 1.0
273280
};
274281
} else if (fieldName.match(/^axis.+\[/)) {
@@ -282,21 +289,14 @@ GraphConfig.load = function(config) {
282289
return {
283290
offset: -1500,
284291
power: 1.0,
285-
inputRange: 500,
286-
outputRange: 1.0
287-
};
288-
} else if (fieldName == "rcCommand[2]") { // Yaw
289-
return {
290-
offset: 0,
291-
power: 0.8,
292-
inputRange: 500 * (sysConfig.rcYawRate ? sysConfig.rcYawRate : 100) / 100,
292+
inputRange: 500,
293293
outputRange: 1.0
294294
};
295295
} else if (fieldName.match(/^rcCommand\[/)) {
296296
return {
297297
offset: 0,
298-
power: 0.8,
299-
inputRange: 500 * (sysConfig.rcRate ? sysConfig.rcRate : 100) / 100,
298+
power: 0.25,
299+
inputRange: 500 * 1.20, // +20% to let compare in the same scale with the rccommands
300300
outputRange: 1.0
301301
};
302302
} else if (fieldName == "heading[2]") {

0 commit comments

Comments
 (0)