Skip to content

Commit

Permalink
Add AUTOPILOT_POSITION and OPTICALFLOW debug modes (betaflight#803)
Browse files Browse the repository at this point in the history
* The DEBUG modes list is updated. The OPTICALFLOW, AUTOPILOT_POSITION debugs are added

* added converters for OPTICALFLOW debug

* added converters for AUTOPILOT_POSITION debug
  • Loading branch information
demvlad authored Dec 23, 2024
1 parent f10ad5e commit 2769c28
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/flightlog_fielddefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,12 +530,14 @@ export function adjustFieldDefsList(firmwareType, firmwareVersion) {
if (semver.gte(firmwareVersion, "4.6.0")) {
DEBUG_MODE.splice(DEBUG_MODE.indexOf('GPS_RESCUE_THROTTLE_PID'), 1, 'AUTOPILOT_ALTITUDE');
DEBUG_MODE.splice(DEBUG_MODE.indexOf("GYRO_SCALED"), 1);
DEBUG_MODE.splice(DEBUG_MODE.indexOf("RANGEFINDER_QUALITY") + 1, 0, "OPTICALFLOW");
DEBUG_MODE.push('TPA');
DEBUG_MODE.push('S_TERM');
DEBUG_MODE.push('SPA');
DEBUG_MODE.push('TASK');
DEBUG_MODE.push('GIMBAL');
DEBUG_MODE.push('WING_SETPOINT');
DEBUG_MODE.push('AUTOPILOT_POSITION');
}

DEBUG_MODE = makeReadOnly(DEBUG_MODE);
Expand Down
70 changes: 67 additions & 3 deletions src/flightlog_fields_presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const FRIENDLY_FIELD_NAMES = {
"axisF[0]": "PID Feedforward [roll]",
"axisF[1]": "PID Feedforward [pitch]",
"axisF[2]": "PID Feedforward [yaw]",

"axisS[all]": "PID S",
"axisS[0]": "PID S [roll]",
"axisS[1]": "PID S [pitch]",
Expand Down Expand Up @@ -129,7 +129,7 @@ const FRIENDLY_FIELD_NAMES = {
GPS_altitude: "GPS Altitude ASL",
GPS_speed: "GPS Speed",
GPS_ground_course: "GPS Heading",

"gpsCartesianCoords[all]": "GPS Coords",
"gpsCartesianCoords[0]": "GPS Coords [X]",
"gpsCartesianCoords[1]": "GPS Coords [Y]",
Expand Down Expand Up @@ -1388,6 +1388,26 @@ FlightLogFieldPresenter.adjustDebugDefsList = function (
'debug[4]': 'Current Setpoint [yaw]',
'debug[5]': 'Adjusted Setpoint [yaw]',
};
DEBUG_FRIENDLY_FIELD_NAMES.OPTICALFLOW = {
'debug[all]': 'Optical Flow',
'debug[0]': 'Quality',
'debug[1]': 'Raw flow rates X',
'debug[2]': 'Raw flow rates Y',
'debug[3]': 'Processed flow rates X',
'debug[4]': 'Processed flow rates Y',
'debug[5]': 'Delta time',
};
DEBUG_FRIENDLY_FIELD_NAMES.AUTOPILOT_POSITION = {
'debug[all]': 'Autopilot Position',
'debug[0]': 'Distance',
'debug[1]': 'GPS Distance',
'debug[2]': 'PID Sum EF',
'debug[3]': 'Angle',
'debug[4]': 'pidP',
'debug[5]': 'pidI',
'debug[6]': 'pidD',
'debug[7]': 'pidA',
};
}
}
};
Expand Down Expand Up @@ -1728,7 +1748,7 @@ FlightLogFieldPresenter.decodeFieldToFriendly = function (
}
case "GPS_ground_course":
return `${(value / 10).toFixed(1)} °`;

case "gpsCartesianCoords[0]":
case "gpsCartesianCoords[1]":
case "gpsCartesianCoords[2]":
Expand Down Expand Up @@ -2151,6 +2171,28 @@ FlightLogFieldPresenter.decodeDebugFieldToFriendly = function (
return value.toFixed(0);
case "EZLANDING":
return `${(value / 100.0).toFixed(2)} %`;
case "OPTICALFLOW":
switch (fieldName) {
case "debug[1]":
case "debug[2]":
case "debug[3]":
case "debug[4]":
return `${(value / 1000).toFixed(1)}`;
default:
return value.toFixed(1);
}
case "AUTOPILOT_POSITION":
switch (fieldName) {
case "debug[2]":
case "debug[3]":
case "debug[4]":
case "debug[5]":
case "debug[6]":
case "debug[7]":
return `${(value / 10).toFixed(1)}`;
default:
return value.toFixed(1);
}
}
return value.toFixed(0);
}
Expand Down Expand Up @@ -2816,6 +2858,28 @@ FlightLogFieldPresenter.ConvertDebugFieldValue = function (
return value;
case "DSHOT_TELEMETRY_COUNTS":
return value;
case "OPTICALFLOW":
switch (fieldName) {
case "debug[1]":
case "debug[2]":
case "debug[3]":
case "debug[4]":
return toFriendly ? value / 1000 : value * 1000;
default:
return value;
}
case "AUTOPILOT_POSITION":
switch (fieldName) {
case "debug[2]":
case "debug[3]":
case "debug[4]":
case "debug[5]":
case "debug[6]":
case "debug[7]":
return toFriendly ? value / 10 : value * 10;
default:
return value;
}
}
}
return value;
Expand Down

0 comments on commit 2769c28

Please sign in to comment.