Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
11 changes: 9 additions & 2 deletions src/flightlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
* Window based smoothing of fields is offered.
*/
export function FlightLog(logData) {
let ADDITIONAL_COMPUTED_FIELD_COUNT = 19 /** attitude + PID_SUM + PID_ERROR + RCCOMMAND_SCALED + GPS coord**/,
let ADDITIONAL_COMPUTED_FIELD_COUNT = 20 /** attitude + PID_SUM + PID_ERROR + RCCOMMAND_SCALED + GPS coord**/,
that = this,
logIndex = 0,
logIndexes = new FlightLogIndex(logData),
Expand Down Expand Up @@ -284,7 +284,7 @@ export function FlightLog(logData) {
fieldNames.push("axisError[0]", "axisError[1]", "axisError[2]"); // Custom calculated error field
}
if (!that.isFieldDisabled().GPS) {
fieldNames.push("gpsCartesianCoords[0]", "gpsCartesianCoords[1]", "gpsCartesianCoords[2]", "gpsDistance"); // GPS coords in cartesian system
fieldNames.push("gpsCartesianCoords[0]", "gpsCartesianCoords[1]", "gpsCartesianCoords[2]", "gpsDistance", "gpsHomeAzimuth"); // GPS coords in cartesian system
}

fieldNameToIndex = {};
Expand Down Expand Up @@ -854,11 +854,18 @@ export function FlightLog(logData) {
destFrame[fieldIndex++] = gpsCartesianCoords.y;
destFrame[fieldIndex++] = gpsCartesianCoords.z;
destFrame[fieldIndex++] = Math.sqrt(gpsCartesianCoords.x * gpsCartesianCoords.x + gpsCartesianCoords.z * gpsCartesianCoords.z);

let homeAzimuth = Math.atan2(-gpsCartesianCoords.z, -gpsCartesianCoords.x) * 180 / Math.PI;
if (homeAzimuth < 0) {
homeAzimuth += 360;
}
destFrame[fieldIndex++] = homeAzimuth;
} else {
destFrame[fieldIndex++] = 0;
destFrame[fieldIndex++] = 0;
destFrame[fieldIndex++] = 0;
destFrame[fieldIndex++] = 0;
destFrame[fieldIndex++] = 0;
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/flightlog_fields_presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ const FRIENDLY_FIELD_NAMES = {
"gpsCartesianCoords[1]": "GPS Coords [Y]",
"gpsCartesianCoords[2]": "GPS Coords [Z]",
gpsDistance: "GPS Home distance",
gpsHomeAzimuth: "GPS Home azimuth",
};

const DEBUG_FRIENDLY_FIELD_NAMES_INITIAL = {
Expand Down Expand Up @@ -1651,6 +1652,8 @@ FlightLogFieldPresenter.decodeFieldToFriendly = function (
case "gpsCartesianCoords[2]":
case "gpsDistance":
return `${value.toFixed(0)} m`;
case "gpsHomeAzimuth":
return `${value.toFixed(1)} °`;

case "debug[0]":
case "debug[1]":
Expand Down
9 changes: 9 additions & 0 deletions src/graph_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,14 @@ GraphConfig.getDefaultCurveForField = function (flightLog, fieldName) {
max: 100,
},
};
} else if (fieldName == "gpsHomeAzimuth") {
return {
power: 1.0,
MinMax: {
min: 0,
max: 360,
},
};
} else if (fieldName.match(/^debug.*/) && sysConfig.debug_mode != null) {
const debugModeName = DEBUG_MODE[sysConfig.debug_mode];
switch (debugModeName) {
Expand Down Expand Up @@ -1542,6 +1550,7 @@ GraphConfig.getExampleGraphConfigs = function (flightLog, graphNames) {
fields: [
"gpsCartesianCoords[all]",
"gpsDistance",
"gpsHomeAzimuth",
],
});
}
Expand Down