Skip to content

Change RC Rate and RC Command #164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions js/flightlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
function FlightLog(logData) {
var
ADDITIONAL_COMPUTED_FIELD_COUNT = 15, /** attitude + PID_SUM + PID_ERROR + RCCOMMAND_SCALED + GYROADC_SCALED **/
ADDITIONAL_COMPUTED_FIELD_COUNT = 16, /** attitude + PID_SUM + PID_ERROR + RCCOMMAND_SCALED + GYROADC_SCALED **/

that = this,
logIndex = false,
Expand Down Expand Up @@ -226,7 +226,7 @@ function FlightLog(logData) {
fieldNames.push("heading[0]", "heading[1]", "heading[2]");
fieldNames.push("axisSum[0]", "axisSum[1]", "axisSum[2]");
fieldNames.push("axisError[0]", "axisError[1]", "axisError[2]"); // Custom calculated error field
fieldNames.push("rcCommands[0]", "rcCommands[1]", "rcCommands[2]"); // Custom calculated error field
fieldNames.push("rcCommands[0]", "rcCommands[1]", "rcCommands[2]", "rcCommands[3]"); // Custom calculated scaled rccommand
fieldNames.push("gyroADCs[0]", "gyroADCs[1]", "gyroADCs[2]"); // Custom calculated error field

fieldNameToIndex = {};
Expand Down Expand Up @@ -512,7 +512,7 @@ function FlightLog(logData) {
gyroADC = [fieldNameToIndex["gyroADC[0]"], fieldNameToIndex["gyroADC[1]"], fieldNameToIndex["gyroADC[2]"]],
accSmooth = [fieldNameToIndex["accSmooth[0]"], fieldNameToIndex["accSmooth[1]"], fieldNameToIndex["accSmooth[2]"]],
magADC = [fieldNameToIndex["magADC[0]"], fieldNameToIndex["magADC[1]"], fieldNameToIndex["magADC[2]"]],
rcCommand = [fieldNameToIndex["rcCommand[0]"], fieldNameToIndex["rcCommand[1]"], fieldNameToIndex["rcCommand[2]"]],
rcCommand = [fieldNameToIndex["rcCommand[0]"], fieldNameToIndex["rcCommand[1]"], fieldNameToIndex["rcCommand[2]"], fieldNameToIndex["rcCommand[3]"]],

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

Expand Down Expand Up @@ -590,11 +590,17 @@ function FlightLog(logData) {
(gyroADC[axis] !== undefined ? that.gyroRawToDegreesPerSecond(srcFrame[gyroADC[axis]]) : 0) -
(rcCommand[axis] !== undefined ? that.rcCommandRawToDegreesPerSecond(srcFrame[rcCommand[axis]], axis, currentFlightMode) : 0);
}
// Calculate the Scaled rcCommand (in deg/s)
for (var axis = 0; axis < 3; axis++) {
destFrame[fieldIndex++] =
(rcCommand[axis] !== undefined ? that.rcCommandRawToDegreesPerSecond(srcFrame[rcCommand[axis]], axis, currentFlightMode) : 0);

// Calculate the Scaled rcCommand (RC Rate)(in deg/s, % for throttle)
for (var axis = 0; axis < 4; axis++) {
if (axis <= AXIS.YAW) {
destFrame[fieldIndex++] =
(rcCommand[axis] !== undefined ? that.rcCommandRawToDegreesPerSecond(srcFrame[rcCommand[axis]], axis, currentFlightMode) : 0);
} else {
destFrame[fieldIndex++] =
(rcCommand[axis] !== undefined ? that.rcCommandRawToThrottle(srcFrame[rcCommand[axis]]) : 0);
}
}

// Calculate the scaled Gyro ADC
for (var axis = 0; axis < 3; axis++) {
Expand Down
31 changes: 16 additions & 15 deletions js/flightlog_fields_presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ function FlightLogFieldPresenter() {
'axisD[1]': 'PID_D[pitch]',
'axisD[2]': 'PID_D[yaw]',

'rcCommand[all]': 'rcCommand',
'rcCommand[0]': 'rcCommand[roll]',
'rcCommand[1]': 'rcCommand[pitch]',
'rcCommand[2]': 'rcCommand[yaw]',
'rcCommand[3]': 'rcCommand[throttle]',
'rcCommand[all]': 'RC Command',
'rcCommand[0]': 'RC Command[roll]',
'rcCommand[1]': 'RC Command[pitch]',
'rcCommand[2]': 'RC Command[yaw]',
'rcCommand[3]': 'RC Command[throttle]',

'gyroADC[all]': 'gyro',
'gyroADC[0]': 'gyro[roll]',
Expand Down Expand Up @@ -68,10 +68,11 @@ function FlightLogFieldPresenter() {
'axisError[2]' : 'PID_Error[yaw]',

//Virtual fields - add the Scaled rcCommands
'rcCommands[all]': 'setpointRates',
'rcCommands[0]' : 'setpointRate[roll]',
'rcCommands[1]' : 'setpointRate[pitch]',
'rcCommands[2]' : 'setpointRate[yaw]',
'rcCommands[all]': 'RC Rates',
'rcCommands[0]' : 'RC Rate[roll]',
'rcCommands[1]' : 'RC Rate[pitch]',
'rcCommands[2]' : 'RC Rate[yaw]',
'rcCommands[3]' : 'RC Rate[throttle]',

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

case 'rcCommand[0]':
return Math.round(flightLog.rcCommandRawToDegreesPerSecond(value,0), currentFlightMode) + " deg/s";
case 'rcCommand[1]':
return Math.round(flightLog.rcCommandRawToDegreesPerSecond(value,1), currentFlightMode) + " deg/s";
case 'rcCommand[2]':
return Math.round(flightLog.rcCommandRawToDegreesPerSecond(value,2), currentFlightMode) + " deg/s";

return (value + 1500).toFixed(0) + " us";
case 'rcCommand[3]':
return Math.round(flightLog.rcCommandRawToThrottle(value)) + " %";
return value.toFixed(0) + " us";

case 'motor[0]':
case 'motor[1]':
case 'motor[2]':
Expand All @@ -314,7 +313,9 @@ function FlightLogFieldPresenter() {
case 'rcCommands[1]':
case 'rcCommands[2]':
return value.toFixed(0) + " deg/s";

case 'rcCommands[3]':
return value.toFixed(0) + "%";

case 'axisSum[0]':
case 'axisSum[1]':
case 'axisSum[2]':
Expand Down
46 changes: 23 additions & 23 deletions js/graph_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ function GraphConfig(graphConfig) {

for (var k = 0; k < logFieldNames.length; k++) {
if (logFieldNames[k].match(nameRegex)) {
// add special condition for rcCommand as each of the fields requires a different scaling.
newGraph.fields.push(adaptField($.extend({}, field, {name: logFieldNames[k]}), colorIndexOffset, (nameRoot=='rcCommand')));
// add special condition for rcCommands as each of the fields requires a different scaling.
newGraph.fields.push(adaptField($.extend({}, field, {name: logFieldNames[k]}), colorIndexOffset, (nameRoot=='rcCommands')));
colorIndexOffset++;
}
}
Expand Down Expand Up @@ -181,7 +181,11 @@ GraphConfig.load = function(config) {
label: "Gyros",
fields: ["gyroADC[all]"]
},
{ /* Add custom graph configurations to the main menu ! */
{ /* Add custom graph configurations to the main menu ! */
label: "RC Rates",
fields: ["rcCommands[all]"]
},
{
label: "RC Command",
fields: ["rcCommand[all]"]
},
Expand Down Expand Up @@ -248,27 +252,30 @@ GraphConfig.load = function(config) {
inputRange: 500,
outputRange: 1.0
};
} else if (fieldName.match(/^gyroADC\[/)) {
return {
offset: 0,
power: 0.25, /* Make this 1.0 to scale linearly */
inputRange: (2.0e-3 * Math.PI/180) / sysConfig.gyroScale,
outputRange: 1.0
};
} else if (fieldName.match(/^accSmooth\[/)) {
return {
offset: 0,
power: 0.5,
inputRange: sysConfig.acc_1G * 16.0, /* Reasonable typical maximum for acc */
outputRange: 1.0
};
} else if (fieldName.match(/^axisError\[/) || // Custom Gyro, rcCommand and axisError Scaling
} else if (fieldName == "rcCommands[3]") { // Throttle scaled
return {
offset: -50,
power: 1.0, /* Make this 1.0 to scale linearly */
inputRange: 50,
outputRange: 1.0
};
} else if (fieldName.match(/^axisError\[/) || // Gyro, Gyro Scaled, RC Command Scaled and axisError
fieldName.match(/^rcCommands\[/) || // These use the same scaling as they are in the
fieldName.match(/^gyroADCs\[/) ) { // same range.
fieldName.match(/^gyroADCs\[/) || // same range.
fieldName.match(/^gyroADC\[/)) {
return {
offset: 0,
power: 0.25, /* Make this 1.0 to scale linearly */
inputRange: flightLog.gyroRawToDegreesPerSecond((2.0e-3 * Math.PI/180) / sysConfig.gyroScale),
inputRange: Math.max(flightLog.rcCommandRawToDegreesPerSecond(500,0) * 1.20,
flightLog.rcCommandRawToDegreesPerSecond(500,1) * 1.20,
flightLog.rcCommandRawToDegreesPerSecond(500,2) * 1.20), // Maximum grad/s + 20%
outputRange: 1.0
};
} else if (fieldName.match(/^axis.+\[/)) {
Expand All @@ -282,21 +289,14 @@ GraphConfig.load = function(config) {
return {
offset: -1500,
power: 1.0,
inputRange: 500,
outputRange: 1.0
};
} else if (fieldName == "rcCommand[2]") { // Yaw
return {
offset: 0,
power: 0.8,
inputRange: 500 * (sysConfig.rcYawRate ? sysConfig.rcYawRate : 100) / 100,
inputRange: 500,
outputRange: 1.0
};
} else if (fieldName.match(/^rcCommand\[/)) {
return {
offset: 0,
power: 0.8,
inputRange: 500 * (sysConfig.rcRate ? sysConfig.rcRate : 100) / 100,
power: 0.25,
inputRange: 500 * 1.20, // +20% to let compare in the same scale with the rccommands
outputRange: 1.0
};
} else if (fieldName == "heading[2]") {
Expand Down