From 67b466d807337d236fdf5acc83d7cd0eb6e391c8 Mon Sep 17 00:00:00 2001 From: bonchan Date: Sun, 20 Nov 2022 21:47:29 -0300 Subject: [PATCH 01/18] c --- index.html | 13 ++++++- js/flightlog.js | 60 ++++++++++++++++++++++++++++++++ js/flightlog_fields_presenter.js | 30 ++++++++++++++++ js/flightlog_index.js | 25 ++++++++++++- js/flightlog_parser.js | 1 + js/graph_config.js | 4 +++ js/grapher.js | 33 ++++++++++++++++-- 7 files changed, 162 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 32cc44cf..b8e252a1 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - Betaflight - Blackbox Explorer + Betaflight - Blackbox Explorer x @@ -493,6 +493,17 @@

Workspace

+ +
+ 123 +
+ +

Legend diff --git a/js/flightlog.js b/js/flightlog.js index 9e8fb994..d9497174 100644 --- a/js/flightlog.js +++ b/js/flightlog.js @@ -210,10 +210,12 @@ function FlightLog(logData) { function buildFieldNames() { // Make an independent copy + console.log("parser.frameDefs.I.name",parser.frameDefs.I.name) fieldNames = parser.frameDefs.I.name.slice(0); // Add names of slow fields which we'll merge into the main stream if (parser.frameDefs.S) { + console.log("parser.frameDefs.S.name",parser.frameDefs.S.name) for (let i = 0; i < parser.frameDefs.S.name.length; i++) { fieldNames.push(parser.frameDefs.S.name[i]); } @@ -241,6 +243,10 @@ function FlightLog(logData) { } } } + //maybe GPS + if (!that.isFieldDisabled().GPS) { + fieldNames.push("GPS_numSat", "GPS_altitude", "GPS_speed", "GPS_ground_course"); + } fieldNameToIndex = {}; for (let i = 0; i < fieldNames.length; i++) { @@ -450,6 +456,27 @@ function FlightLog(logData) { // TODO pending to do something with GPS frames // The frameValid can be false, when no GPS home (the G frames contains GPS position as diff of GPS Home position). // But other data from the G frame can be valid (time, num sats) + + //H Field G name:time,GPS_numSat,GPS_coord[0],GPS_coord[1],GPS_altitude,GPS_speed,GPS_ground_course + for (var i = 0; i < frame.length; i++) { + //console.log(`G frame[${i}] ${frame[i]}`); + + } + // document.getElementById('gps-table').innerText = frame[2] +" | "+ frame[3] + + +/// + if (!frame.time) { + eventNeedsTimestamp.push(frame); + } + chunk.events.push(frame); + ///// + + + + + + break; } } else { @@ -540,6 +567,11 @@ function FlightLog(logData) { let motor = [fieldNameToIndex["motor[0]"], fieldNameToIndex["motor[1]"], fieldNameToIndex["motor[2]"], fieldNameToIndex["motor[3]"], fieldNameToIndex["motor[4]"], fieldNameToIndex["motor[5]"], fieldNameToIndex["motor[6]"], fieldNameToIndex["motor[7]"]]; + + + let gps = [fieldNameToIndex["GPS_numSat"], fieldNameToIndex["GPS_altitude"], fieldNameToIndex["GPS_speed"], fieldNameToIndex["GPS_ground_course"]]; + console.log("gps",gps) + let sourceChunkIndex; let destChunkIndex; let attitude; @@ -579,6 +611,10 @@ function FlightLog(logData) { motor = false; } + if (!gps[0]) { + gps = false; + } + sourceChunkIndex = 0; destChunkIndex = 0; @@ -680,6 +716,30 @@ function FlightLog(logData) { } } + // GPS maybe "GPS_numSat"], fieldNameToIndex["GPS_altitude"], fieldNameToIndex["GPS_speed"], fieldNameToIndex["GPS_ground_course"]]; + if(gps){ + +console.log("srcFrame",srcFrame) +console.log("[gps[0]",gps[0]) +console.log("srcFrame[gps[0]",srcFrame[gps[0]]) + + + + +destFrame[fieldIndex++] = srcFrame[gps[0]]; +destFrame[fieldIndex++] = srcFrame[gps[1]]; +destFrame[fieldIndex++] = srcFrame[gps[2]]; +destFrame[fieldIndex++] = srcFrame[gps[3]]; + +// destFrame[fieldIndex++] = 10; +// destFrame[fieldIndex++] = 20; +// destFrame[fieldIndex++] = 30; +// destFrame[fieldIndex++] = 40; + } + + + + // Remove empty fields at the end destFrame.splice(fieldIndex); diff --git a/js/flightlog_fields_presenter.js b/js/flightlog_fields_presenter.js index 0568cf82..be5e3b54 100644 --- a/js/flightlog_fields_presenter.js +++ b/js/flightlog_fields_presenter.js @@ -106,6 +106,20 @@ function FlightLogFieldPresenter() { 'rxSignalReceived': 'RX Signal Received', 'rxFlightChannelsValid': 'RX Flight Ch. Valid', 'rssi': 'RSSI', + + // no clue how to process these, and HOME is likely a duplicate + 'GPS_home[all]': 'GPS_home[all]', + 'GPS_home[0]': 'GPS_home[0]', + 'GPS_home[1]': 'GPS_home[1]', + 'GPS_coord[all]': 'GPS_coord[all]', + 'GPS_coord[0]': 'GPS_coord[0]', + 'GPS_coord[1]': 'GPS_coord[0]', + 'GPS_numSat': 'GPS_numSat', + 'GPS_altitude': 'GPS_altitude', + 'GPS_speed': 'GPS_speed', + 'GPS_ground_course': 'GPS_ground_course', + + }; const DEBUG_FRIENDLY_FIELD_NAMES_INITIAL = { @@ -977,6 +991,22 @@ function FlightLogFieldPresenter() { case 'rssi': return (value / 1024 * 100).toFixed(2) + " %"; + //H Field G name:time,GPS_numSat,GPS_coord[0],GPS_coord[1],GPS_altitude,GPS_speed,GPS_ground_course + case 'GPSHOME[0]': + case 'GPSHOME[1]': + case 'GPS_HOME[0]': //duplicate variable + case 'GPS_HOME[1]': //duplicate variable + case 'GPS_coord[0]': + case 'GPS_coord[1]': + return value/1000000; + case 'GPS_numSat': + case 'GPS_altitude': + return value; + case 'GPS_speed': + return value/100; + case 'GPS_ground_course': + return value/10; + case 'debug[0]': case 'debug[1]': case 'debug[2]': diff --git a/js/flightlog_index.js b/js/flightlog_index.js index a6c836da..8d5b2358 100644 --- a/js/flightlog_index.js +++ b/js/flightlog_index.js @@ -83,7 +83,13 @@ function FlightLogIndex(logData) { magADC = [mainFrameDef.nameToIndex["magADC[0]"], mainFrameDef.nameToIndex["magADC[1]"], mainFrameDef.nameToIndex["magADC[2]"]], lastSlow = [], - lastGPSHome = []; + lastGPSHome = [], + + lastGPScoord = [], + lastGPSnumSat, + lastGPSaltitude, + lastGPSspeed, + lastGPSgroundCourse; // Identify motor fields so they can be used to show the activity summary bar for (var j = 0; j < 8; j++) { @@ -166,6 +172,23 @@ function FlightLogIndex(logData) { sawEndMarker = true; } break; + case 'G': + var frameTime = frame[0]; + //H Field G name:time,GPS_numSat,GPS_coord[0],GPS_coord[1],GPS_altitude,GPS_speed,GPS_ground_course + lastGPSnumSat = frame[1]; + lastGPScoord[0] = frame[2]; + lastGPScoord[1] = frame[3]; + lastGPSaltitude = frame[4]; + lastGPSspeed = frame[5]; + lastGPSgroundCourse = frame[6]; + // console.log(`full frame: ${frame}`); + // console.log(`frameTime ${frameTime} + // lastGPSnumSat ${lastGPSnumSat} + // lastGPScoord[all] ${lastGPScoord} (lastGPScoord[0] ${lastGPScoord[0]} / lastGPScoord[1] ${lastGPScoord[1]}) + // lastGPSaltitude ${lastGPSaltitude} + // lastGPSspeed ${lastGPSspeed} + // lastGPSgroundCourse ${lastGPSgroundCourse}`); + break; case 'S': lastSlow = frame.slice(0); break; diff --git a/js/flightlog_parser.js b/js/flightlog_parser.js index 9cbc8c2e..a0197cfe 100644 --- a/js/flightlog_parser.js +++ b/js/flightlog_parser.js @@ -1402,6 +1402,7 @@ var FlightLogParser = function(logData) { function parseGPSFrame(raw) { // Only parse a GPS frame if we have GPS header definitions if (that.frameDefs.G) { + console.log("that.frameDefs.G",that.frameDefs.G) parseFrame(that.frameDefs.G, lastGPS, null, null, 0, raw); } } diff --git a/js/graph_config.js b/js/graph_config.js index c155a920..744c1833 100644 --- a/js/graph_config.js +++ b/js/graph_config.js @@ -956,6 +956,10 @@ GraphConfig.load = function(config) { EXAMPLE_GRAPHS.push({label: "Debug",fields: ["debug[all]"]}); } + if (!flightLog.isFieldDisabled().GPS) { + EXAMPLE_GRAPHS.push({label: "GPS",fields: ["GPS_numSat", "GPS_altitude", "GPS_speed", "GPS_ground_course"]}); + } + for (i = 0; i < EXAMPLE_GRAPHS.length; i++) { var srcGraph = EXAMPLE_GRAPHS[i], diff --git a/js/grapher.js b/js/grapher.js index c76e1023..d9030ccf 100644 --- a/js/grapher.js +++ b/js/grapher.js @@ -179,13 +179,19 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, stickCanvas, craftCanv numCells:-1, baroField:-1, + gpsFields:[], + miscFields:[], //Synthetic fields: roll:-1, pitch:-1, heading:-1, - axisPIDSum:[] + axisPIDSum:[], + GPS_numSat:80, + GPS_altitude:70, + GPS_speed:60, + GPS_ground_course:50, }; for (fieldIndex = 0; fieldIndex < fieldNames.length; fieldIndex++) { @@ -193,6 +199,8 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, stickCanvas, craftCanv fieldName = fieldNames[fieldIndex], matches; + console.log("fieldName",fieldName) + if ((matches = fieldName.match(/^motor\[(\d+)]$/))) { var motorIndex = matches[1]; @@ -226,7 +234,12 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, stickCanvas, craftCanv idents.numServos++; idents.servoFields[servoIndex] = fieldIndex; - } else { + // } else if ((matches = fieldName.match(/^GPS_coord\[(\d+)]$/))) { + // console.log("MATCHES GPS") + // var axisIndex = matches[1]; + + // idents.gpsFields[axisIndex] = fieldIndex; + }else { switch (fieldName) { case "vbatLatest": idents.vbatField = fieldIndex; @@ -244,6 +257,22 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, stickCanvas, craftCanv case "heading": idents.heading = fieldIndex; break; + + case "GPS_numSat": + idents.GPS_numSat = fieldIndex; + break; + case "GPS_altitude": + idents.GPS_altitude = fieldIndex; + break; + case "GPS_speed": + idents.GPS_speed = fieldIndex; + break; + case "GPS_ground_course": + idents.GPS_ground_course = fieldIndex; + break; + + + default: idents.miscFields.push(fieldIndex); } From fd509562e617e45cbe80ca8e91682af3fc335287 Mon Sep 17 00:00:00 2001 From: bonchan Date: Sun, 20 Nov 2022 22:14:21 -0300 Subject: [PATCH 02/18] haslinghuis diff from 602#issuecomment-1320958859 --- js/flightlog.js | 8 +++++++- js/flightlog_fielddefs.js | 15 +++++++++++++++ js/flightlog_fields_presenter.js | 29 +++++++++++++++++++++++++++++ js/flightlog_index.js | 8 +++++++- 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/js/flightlog.js b/js/flightlog.js index 9e8fb994..25627f4a 100644 --- a/js/flightlog.js +++ b/js/flightlog.js @@ -375,7 +375,8 @@ function FlightLog(logData) { var mainFrameIndex = 0, slowFrameLength = parser.frameDefs.S ? parser.frameDefs.S.count : 0, - lastSlow = parser.frameDefs.S ? iframeDirectory.initialSlow[chunkIndex].slice(0) : []; + lastSlow = parser.frameDefs.S ? iframeDirectory.initialSlow[chunkIndex].slice(0) : [], + lastGPS = parser.frameDefs.G ? iframeDirectory.initialGPS[chunkIndex].slice(0) : []; parser.onFrameReady = function(frameValid, frame, frameType, frameOffset, frameSize) { var @@ -450,6 +451,11 @@ function FlightLog(logData) { // TODO pending to do something with GPS frames // The frameValid can be false, when no GPS home (the G frames contains GPS position as diff of GPS Home position). // But other data from the G frame can be valid (time, num sats) + + //H Field G name:time,GPS_numSat,GPS_coord[0],GPS_coord[1],GPS_altitude,GPS_speed,GPS_ground_course + for (let i = 0; i < frame.length; i++) { + lastGPS[i] = frame[i]; + } break; } } else { diff --git a/js/flightlog_fielddefs.js b/js/flightlog_fielddefs.js index eb793048..ef8fc591 100644 --- a/js/flightlog_fielddefs.js +++ b/js/flightlog_fielddefs.js @@ -541,9 +541,24 @@ function adjustFieldDefsList(firmwareType, firmwareVersion) { DEBUG_MODE.splice(DEBUG_MODE.indexOf('DUAL_GYRO'), 1); DEBUG_MODE.splice(DEBUG_MODE.indexOf('DUAL_GYRO_COMBINED'), 1); } + if (semver.gte(firmwareVersion, '4.2.0')) { + DEBUG_MODE.splice(DEBUG_MODE.indexOf('FF_INTERPOLATED'), 1); + } if (semver.gte(firmwareVersion, '4.3.0')) { DEBUG_MODE.splice(DEBUG_MODE.indexOf('FF_INTERPOLATED'), 1, 'FEEDFORWARD'); DEBUG_MODE.splice(DEBUG_MODE.indexOf('FF_LIMIT'), 1, 'FEEDFORWARD_LIMIT'); + DEBUG_MODE.splice(DEBUG_MODE.indexOf('DYN_IDLE'), 1); + DEBUG_MODE.splice(DEBUG_MODE.indexOf('FFT'), 1); + DEBUG_MODE.splice(DEBUG_MODE.indexOf('FFT_TIME'), 1); + DEBUG_MODE.splice(DEBUG_MODE.indexOf('FFT_FREQ'), 1); + DEBUG_MODE.splice(DEBUG_MODE.indexOf('GPS_RESCUE_THROTTLE_PID'), 1); + } + if (semver.gte(firmwareVersion, '4.4.0')) { + DEBUG_MODE.splice(DEBUG_MODE.indexOf('BARO'), 1); + DEBUG_MODE.splice(DEBUG_MODE.indexOf('RTH'), 1); + DEBUG_MODE.splice(DEBUG_MODE.indexOf('GPS_RESCUE_THROTTLE_PID'), 1); + DEBUG_MODE.splice(DEBUG_MODE.indexOf('VTX_MSP'), 1); + DEBUG_MODE.splice(DEBUG_MODE.indexOf('GPS_DOP'), 1); } DEBUG_MODE = makeReadOnly(DEBUG_MODE); diff --git a/js/flightlog_fields_presenter.js b/js/flightlog_fields_presenter.js index 0568cf82..9f4c152a 100644 --- a/js/flightlog_fields_presenter.js +++ b/js/flightlog_fields_presenter.js @@ -106,6 +106,16 @@ function FlightLogFieldPresenter() { 'rxSignalReceived': 'RX Signal Received', 'rxFlightChannelsValid': 'RX Flight Ch. Valid', 'rssi': 'RSSI', + + + 'lastGPS[all]': 'GPS Data', + 'lastGPS[0]': "GPS timeframe", + 'lastGPS[1]': "GPS Latitude", + 'lastGPS[2]': "GPS Longitude", + 'lastGPS[3]': "GPS NumSat", + 'lastGPS[4]': "GPS Altitude", + 'lastGPS[5]': "GPS Speed", + 'lastGPS[6]': "GPS Ground course", }; const DEBUG_FRIENDLY_FIELD_NAMES_INITIAL = { @@ -859,6 +869,9 @@ function FlightLogFieldPresenter() { const highResolutionScale = (flightLog && flightLog.getSysConfig().blackbox_high_resolution > 0) ? 10 : 1; const highResolutionAddPrecision = (flightLog && flightLog.getSysConfig().blackbox_high_resolution > 0) ? 1 : 0; + //if (fieldName.toUpperCase().includes("GPS")) + console.log(fieldName); + switch (fieldName) { case 'time': return formatTime(value / 1000, true); @@ -977,6 +990,22 @@ function FlightLogFieldPresenter() { case 'rssi': return (value / 1024 * 100).toFixed(2) + " %"; + //H Field G name:time,GPS_numSat,GPS_coord[0],GPS_coord[1],GPS_altitude,GPS_speed,GPS_ground_course + case 'lastGPS[0]': + case 'lastGPS[1]': + return `${value}`; + case 'lastGPS[2]': + return `${(value/1000000).toFixed(2)}`; + case 'lastGPS[3]': + return `${(value/10000000).toFixed(2)}`; + case 'lastGPS[4]': + return `${(value/10).toFixed(2)}`; + case 'lastGPS[5]': + return `${(value/100).toFixed(2)}`; + case 'lastGPS[6]': + return `${(value/10).toFixed(2)}`; + + case 'debug[0]': case 'debug[1]': case 'debug[2]': diff --git a/js/flightlog_index.js b/js/flightlog_index.js index a6c836da..29d06fc1 100644 --- a/js/flightlog_index.js +++ b/js/flightlog_index.js @@ -46,6 +46,7 @@ function FlightLogIndex(logData) { initialIMU: [], initialSlow: [], initialGPSHome: [], + initialGPS: [], hasEvent: [], minTime: false, maxTime: false @@ -83,7 +84,8 @@ function FlightLogIndex(logData) { magADC = [mainFrameDef.nameToIndex["magADC[0]"], mainFrameDef.nameToIndex["magADC[1]"], mainFrameDef.nameToIndex["magADC[2]"]], lastSlow = [], - lastGPSHome = []; + lastGPSHome = [], + lastGPS = [mainFrameDef.nameToIndex["lastGPS[0]"],mainFrameDef.nameToIndex["lastGPS[1]"], mainFrameDef.nameToIndex["lastGPS[2]"], mainFrameDef.nameToIndex["lastGPS[3]"], mainFrameDef.nameToIndex["lastGPS[4]"], mainFrameDef.nameToIndex["lastGPS[5]"], mainFrameDef.nameToIndex["lastGPS[6]"]]; // Identify motor fields so they can be used to show the activity summary bar for (var j = 0; j < 8; j++) { @@ -139,6 +141,7 @@ function FlightLogIndex(logData) { intraIndex.initialIMU.push(new IMU(imu)); intraIndex.initialSlow.push(lastSlow); intraIndex.initialGPSHome.push(lastGPSHome); + intraIndex.initialGPS.push(lastGPS); } iframeCount++; @@ -153,6 +156,9 @@ function FlightLogIndex(logData) { magADC ? [frame[magADC[0]], frame[magADC[1]], frame[magADC[2]]] : false ); break; + case 'G': + lastGPS = frame.slice(0); + break; case 'H': lastGPSHome = frame.slice(0); break; From 803b3b773b59fa5fc07914e967c33e8629cac914 Mon Sep 17 00:00:00 2001 From: bonchan Date: Mon, 21 Nov 2022 10:26:16 -0300 Subject: [PATCH 03/18] added check undefined returning undefined --- js/main.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index 48aae6ba..642ef8c2 100644 --- a/js/main.js +++ b/js/main.js @@ -166,7 +166,11 @@ function BlackboxLogViewer() { if (value === null) return "(absent)"; - + + if (typeof value == 'undefined') { + return "undefined"; + } + return value.toFixed(2); } From f8b175547cbc9825ea29238bf0df7adc2b4d9a12 Mon Sep 17 00:00:00 2001 From: Linus Thorsell Date: Mon, 21 Nov 2022 17:14:47 +0100 Subject: [PATCH 04/18] displays data in table and graph --- js/flightlog.js | 33 +++++++++++++++++++++++++++++++- js/flightlog_fields_presenter.js | 6 +++--- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/js/flightlog.js b/js/flightlog.js index a74c35da..bf4ff6ba 100644 --- a/js/flightlog.js +++ b/js/flightlog.js @@ -379,7 +379,7 @@ function FlightLog(logData) { mainFrameIndex = 0, slowFrameLength = parser.frameDefs.S ? parser.frameDefs.S.count : 0, lastSlow = parser.frameDefs.S ? iframeDirectory.initialSlow[chunkIndex].slice(0) : [], - lastGPSLength = 0,//parser.frameDefs.G ? parser.frameDefs.G.count : 0, Should I expand the outputFields? + lastGPSLength = 0, //parser.frameDefs.G ? parser.frameDefs.G.count : 0, //Should I expand the outputFields? lastGPS = parser.frameDefs.G ? iframeDirectory.initialGPS[chunkIndex].slice(0) : []; parser.onFrameReady = function(frameValid, frame, frameType, frameOffset, frameSize) { @@ -460,8 +460,33 @@ function FlightLog(logData) { for (let i = 0; i < frame.length; i++) { lastGPS[i] = frame[i]; } + console.log("frameValid: " + frameValid); + console.log("frame: " + frame); + console.log("frameType: " + frameType); + console.log("frameOffset: " + frameOffset); + console.log("frameSize: " + frameSize); + + //parser.onFrameReady = function(frameValid, frame, frameType, frameOffset, frameSize) { +// console.log("local frames", chunk.frames[chunk.frames.length - 1]); +// chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[0]')] = lastGPS[0]; +// chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[1]')] = lastGPS[1]; +// chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[2]')] = lastGPS[2]; +// chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[3]')] = lastGPS[3]; +// chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[4]')] = lastGPS[4]; +// chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[5]')] = lastGPS[5]; + //chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[6]')] = lastGPS[6]; + + //getMainFieldIndexByName break; } + // Logs gps values, but out of sync for some reason + console.log("local frames", chunk.frames[chunk.frames.length - 1]); + chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[0]')] = lastGPS[0]; + chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[1]')] = lastGPS[1]; + chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[2]')] = lastGPS[2]; + chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[3]')] = lastGPS[3]; + chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[4]')] = lastGPS[4]; + chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[5]')] = lastGPS[5]; } else { chunk.gapStartsHere[mainFrameIndex - 1] = true; } @@ -701,13 +726,19 @@ function FlightLog(logData) { } if(gps) { + console.log("GPS"); + console.log("destFrame", destFrame); + console.log("srcFrame", srcFrame); destFrame[fieldIndex++] = srcFrame[gps[0]]; + //destFrame[fieldIndex++] = 42069; destFrame[fieldIndex++] = srcFrame[gps[1]]; destFrame[fieldIndex++] = srcFrame[gps[2]]; destFrame[fieldIndex++] = srcFrame[gps[3]]; destFrame[fieldIndex++] = srcFrame[gps[4]]; destFrame[fieldIndex++] = srcFrame[gps[5]]; destFrame[fieldIndex++] = srcFrame[gps[6]]; + console.log("destFrame", destFrame); + console.log("srcFrame", srcFrame); } // Remove empty fields at the end destFrame.splice(fieldIndex); diff --git a/js/flightlog_fields_presenter.js b/js/flightlog_fields_presenter.js index b04acc9c..e7b35a38 100644 --- a/js/flightlog_fields_presenter.js +++ b/js/flightlog_fields_presenter.js @@ -110,9 +110,9 @@ function FlightLogFieldPresenter() { 'lastGPS[all]': 'GPS Data', 'lastGPS[0]': "GPS timeframe", - 'lastGPS[1]': "GPS Latitude", - 'lastGPS[2]': "GPS Longitude", - 'lastGPS[3]': "GPS NumSat", + 'lastGPS[1]': "GPS NumSat", + 'lastGPS[2]': "GPS Latitude", + 'lastGPS[3]': "GPS Longitude", 'lastGPS[4]': "GPS Altitude", 'lastGPS[5]': "GPS Speed", 'lastGPS[6]': "GPS Ground course", From 5bfad3f480a718f863c7140f523245e899fe12c1 Mon Sep 17 00:00:00 2001 From: Linus Thorsell Date: Mon, 21 Nov 2022 21:06:35 +0100 Subject: [PATCH 05/18] progress, table loads offset by 5, but works --- js/flightlog.js | 38 +++++++++++++++++++++++--------- js/flightlog_fields_presenter.js | 2 +- js/flightlog_index.js | 26 +++++++++++++--------- 3 files changed, 44 insertions(+), 22 deletions(-) diff --git a/js/flightlog.js b/js/flightlog.js index bf4ff6ba..aba205ce 100644 --- a/js/flightlog.js +++ b/js/flightlog.js @@ -218,6 +218,16 @@ function FlightLog(logData) { fieldNames.push(parser.frameDefs.S.name[i]); } } + // Add names of gps fields which we'll merfe into the main stream + if (parser.frameDefs.G) { + for (let i = 0; i < parser.frameDefs.G.name.length; i++) { + fieldNames.push(parser.frameDefs.G.name[i]); + } + } + + /*if (!that.isFieldDisabled().GPS) { + fieldNames.push("lastGPS[0]", "lastGPS[1]", "lastGPS[2]", "lastGPS[3]", "lastGPS[4]", "lastGPS[5]", "lastGPS[6]"); + }*/ // Add names for our ADDITIONAL_COMPUTED_FIELDS if (!that.isFieldDisabled().GYRO) { @@ -241,9 +251,6 @@ function FlightLog(logData) { } } } - if (!that.isFieldDisabled().GPS) { - fieldNames.push("lastGPS[0]", "lastGPS[1]", "lastGPS[2]", "lastGPS[3]", "lastGPS[4]", "lastGPS[5]", "lastGPS[6]"); - } fieldNameToIndex = {}; for (let i = 0; i < fieldNames.length; i++) { @@ -379,7 +386,7 @@ function FlightLog(logData) { mainFrameIndex = 0, slowFrameLength = parser.frameDefs.S ? parser.frameDefs.S.count : 0, lastSlow = parser.frameDefs.S ? iframeDirectory.initialSlow[chunkIndex].slice(0) : [], - lastGPSLength = 0, //parser.frameDefs.G ? parser.frameDefs.G.count : 0, //Should I expand the outputFields? + lastGPSLength = parser.frameDefs.G ? parser.frameDefs.G.count : 0, //Should I expand the outputFields? lastGPS = parser.frameDefs.G ? iframeDirectory.initialGPS[chunkIndex].slice(0) : []; parser.onFrameReady = function(frameValid, frame, frameType, frameOffset, frameSize) { @@ -415,9 +422,15 @@ function FlightLog(logData) { } // Then merge in the last seen slow-frame data + console.log(lastSlow) for (var i = 0; i < slowFrameLength; i++) { destFrame[i + frame.length] = lastSlow[i] === undefined ? null : lastSlow[i]; } + // Also merge last seen gps-frame data + console.log(lastGPS) + for (var i = 0; i < lastGPSLength; i++) { + destFrame[i + frame.length] = lastGPS[i] === undefined ? null : lastGPS[i]; + } for (var i = 0; i < eventNeedsTimestamp.length; i++) { eventNeedsTimestamp[i].time = frame[FlightLogParser.prototype.FLIGHT_LOG_FIELD_INDEX_TIME]; @@ -451,6 +464,9 @@ function FlightLog(logData) { } break; case 'H': + // TODO + // contains coordinates only + // should be handles separately case 'G': // TODO pending to do something with GPS frames // The frameValid can be false, when no GPS home (the G frames contains GPS position as diff of GPS Home position). @@ -480,6 +496,7 @@ function FlightLog(logData) { break; } // Logs gps values, but out of sync for some reason + /* console.log("local frames", chunk.frames[chunk.frames.length - 1]); chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[0]')] = lastGPS[0]; chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[1]')] = lastGPS[1]; @@ -487,6 +504,7 @@ function FlightLog(logData) { chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[3]')] = lastGPS[3]; chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[4]')] = lastGPS[4]; chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[5]')] = lastGPS[5]; + */ } else { chunk.gapStartsHere[mainFrameIndex - 1] = true; } @@ -578,8 +596,8 @@ function FlightLog(logData) { fieldNameToIndex["motor[4]"], fieldNameToIndex["motor[5]"], fieldNameToIndex["motor[6]"], fieldNameToIndex["motor[7]"]]; - let gps = [fieldNameToIndex["lastGPS[0]"], fieldNameToIndex["lastGPS[1]"], fieldNameToIndex["lastGPS[2]"], fieldNameToIndex["lastGPS[3]"], fieldNameToIndex["lastGPS[4]"], fieldNameToIndex["lastGPS[5]"], fieldNameToIndex["lastGPS[6]"]]; - console.log("gps",gps) + //TODO let gps = [fieldNameToIndex["lastGPS[0]"], fieldNameToIndex["lastGPS[1]"], fieldNameToIndex["lastGPS[2]"], fieldNameToIndex["lastGPS[3]"], fieldNameToIndex["lastGPS[4]"], fieldNameToIndex["lastGPS[5]"], fieldNameToIndex["lastGPS[6]"]]; + //console.log("gps",gps) let sourceChunkIndex; let destChunkIndex; @@ -620,9 +638,9 @@ function FlightLog(logData) { motor = false; } - if (!gps[0]) { + /*if (!gps[0]) { gps = false; - } + }*/ sourceChunkIndex = 0; destChunkIndex = 0; @@ -725,7 +743,7 @@ function FlightLog(logData) { } } - if(gps) { + /*if(gps) { console.log("GPS"); console.log("destFrame", destFrame); console.log("srcFrame", srcFrame); @@ -739,7 +757,7 @@ function FlightLog(logData) { destFrame[fieldIndex++] = srcFrame[gps[6]]; console.log("destFrame", destFrame); console.log("srcFrame", srcFrame); - } + }*/ // Remove empty fields at the end destFrame.splice(fieldIndex); diff --git a/js/flightlog_fields_presenter.js b/js/flightlog_fields_presenter.js index e7b35a38..02d1da21 100644 --- a/js/flightlog_fields_presenter.js +++ b/js/flightlog_fields_presenter.js @@ -869,7 +869,7 @@ function FlightLogFieldPresenter() { const highResolutionScale = (flightLog && flightLog.getSysConfig().blackbox_high_resolution > 0) ? 10 : 1; const highResolutionAddPrecision = (flightLog && flightLog.getSysConfig().blackbox_high_resolution > 0) ? 1 : 0; - if (fieldName.toUpperCase().includes("GPS")) console.log("GPSfieldName", fieldName); + //if (fieldName.toUpperCase().includes("GPS")) console.log("GPSfieldName", fieldName); switch (fieldName) { case 'time': diff --git a/js/flightlog_index.js b/js/flightlog_index.js index b6af71e1..2489d901 100644 --- a/js/flightlog_index.js +++ b/js/flightlog_index.js @@ -78,7 +78,8 @@ function FlightLogIndex(logData) { var sysConfig = parser.sysConfig, mainFrameDef = parser.frameDefs.I, - + + gyroADC = [mainFrameDef.nameToIndex["gyroADC[0]"], mainFrameDef.nameToIndex["gyroADC[1]"], mainFrameDef.nameToIndex["gyroADC[2]"]], accSmooth = [mainFrameDef.nameToIndex["accSmooth[0]"], mainFrameDef.nameToIndex["accSmooth[1]"], mainFrameDef.nameToIndex["accSmooth[2]"]], magADC = [mainFrameDef.nameToIndex["magADC[0]"], mainFrameDef.nameToIndex["magADC[1]"], mainFrameDef.nameToIndex["magADC[2]"]], @@ -88,19 +89,22 @@ function FlightLogIndex(logData) { lastGPS = [] // is this needed? - // gpsFrameDef = parser.frameDefs.G, - // lastGPS = [ - // gpsFrameDef.nameToIndex["time"], - // gpsFrameDef.nameToIndex["GPS_numSat"], - // gpsFrameDef.nameToIndex["GPS_coord[0]"], - // gpsFrameDef.nameToIndex["GPS_coord[1]"], - // gpsFrameDef.nameToIndex["GPS_altitude"], - // gpsFrameDef.nameToIndex["GPS_speed"], - // gpsFrameDef.nameToIndex["GPS_ground_course"] - // ] + //gpsFrameDef = parser.frameDefs.G, + /*lastGPS = [ + gpsFrameDef.nameToIndex["time"], + gpsFrameDef.nameToIndex["GPS_numSat"], + gpsFrameDef.nameToIndex["GPS_coord[0]"], + gpsFrameDef.nameToIndex["GPS_coord[1]"], + gpsFrameDef.nameToIndex["GPS_altitude"], + gpsFrameDef.nameToIndex["GPS_speed"], + gpsFrameDef.nameToIndex["GPS_ground_course"] + ]*/ ; + console.log("mainFrameDef: ", mainFrameDef); + + // Identify motor fields so they can be used to show the activity summary bar for (var j = 0; j < 8; j++) { if (mainFrameDef.nameToIndex["motor[" + j + "]"] !== undefined) { From 11ecff510e949eb0ef4fbe93e43838ca3937d889 Mon Sep 17 00:00:00 2001 From: Linus Thorsell Date: Mon, 21 Nov 2022 21:44:59 +0100 Subject: [PATCH 06/18] GPS G Frame logs successfully. --- js/flightlog.js | 10 ++++++---- js/grapher.js | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/js/flightlog.js b/js/flightlog.js index aba205ce..48242f63 100644 --- a/js/flightlog.js +++ b/js/flightlog.js @@ -207,7 +207,7 @@ function FlightLog(logData) { } else return false; }; - + function buildFieldNames() { // Make an independent copy fieldNames = parser.frameDefs.I.name.slice(0); @@ -218,10 +218,12 @@ function FlightLog(logData) { fieldNames.push(parser.frameDefs.S.name[i]); } } - // Add names of gps fields which we'll merfe into the main stream + // Add names of gps fields which we'll merge into the main stream + if (parser.frameDefs.G) { for (let i = 0; i < parser.frameDefs.G.name.length; i++) { fieldNames.push(parser.frameDefs.G.name[i]); + console.log("Adding GPS field: ", parser.frameDefs.G.name[i], " Index: ", fieldNames.length - 1); } } @@ -429,7 +431,7 @@ function FlightLog(logData) { // Also merge last seen gps-frame data console.log(lastGPS) for (var i = 0; i < lastGPSLength; i++) { - destFrame[i + frame.length] = lastGPS[i] === undefined ? null : lastGPS[i]; + destFrame[i + frame.length + slowFrameLength] = lastGPS[i] === undefined ? null : lastGPS[i]; } for (var i = 0; i < eventNeedsTimestamp.length; i++) { @@ -466,7 +468,7 @@ function FlightLog(logData) { case 'H': // TODO // contains coordinates only - // should be handles separately + // should be handled separately case 'G': // TODO pending to do something with GPS frames // The frameValid can be false, when no GPS home (the G frames contains GPS position as diff of GPS Home position). diff --git a/js/grapher.js b/js/grapher.js index c76e1023..bea3b1af 100644 --- a/js/grapher.js +++ b/js/grapher.js @@ -246,6 +246,7 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, stickCanvas, craftCanv break; default: idents.miscFields.push(fieldIndex); + console.log("miscFields", idents.miscFields); } } } From df6ee3ef24b685322bdbadb56fb2e547fe3a6143 Mon Sep 17 00:00:00 2001 From: Linus Thorsell Date: Mon, 21 Nov 2022 21:57:36 +0100 Subject: [PATCH 07/18] removed unecessary comments --- js/flightlog.js | 61 -------------------------------- js/flightlog_fields_presenter.js | 12 +++---- js/flightlog_index.js | 15 -------- js/grapher.js | 1 - 4 files changed, 6 insertions(+), 83 deletions(-) diff --git a/js/flightlog.js b/js/flightlog.js index 48242f63..27211840 100644 --- a/js/flightlog.js +++ b/js/flightlog.js @@ -219,18 +219,12 @@ function FlightLog(logData) { } } // Add names of gps fields which we'll merge into the main stream - if (parser.frameDefs.G) { for (let i = 0; i < parser.frameDefs.G.name.length; i++) { fieldNames.push(parser.frameDefs.G.name[i]); - console.log("Adding GPS field: ", parser.frameDefs.G.name[i], " Index: ", fieldNames.length - 1); } } - /*if (!that.isFieldDisabled().GPS) { - fieldNames.push("lastGPS[0]", "lastGPS[1]", "lastGPS[2]", "lastGPS[3]", "lastGPS[4]", "lastGPS[5]", "lastGPS[6]"); - }*/ - // Add names for our ADDITIONAL_COMPUTED_FIELDS if (!that.isFieldDisabled().GYRO) { fieldNames.push("heading[0]", "heading[1]", "heading[2]"); @@ -424,12 +418,10 @@ function FlightLog(logData) { } // Then merge in the last seen slow-frame data - console.log(lastSlow) for (var i = 0; i < slowFrameLength; i++) { destFrame[i + frame.length] = lastSlow[i] === undefined ? null : lastSlow[i]; } // Also merge last seen gps-frame data - console.log(lastGPS) for (var i = 0; i < lastGPSLength; i++) { destFrame[i + frame.length + slowFrameLength] = lastGPS[i] === undefined ? null : lastGPS[i]; } @@ -470,7 +462,6 @@ function FlightLog(logData) { // contains coordinates only // should be handled separately case 'G': - // TODO pending to do something with GPS frames // The frameValid can be false, when no GPS home (the G frames contains GPS position as diff of GPS Home position). // But other data from the G frame can be valid (time, num sats) @@ -478,35 +469,8 @@ function FlightLog(logData) { for (let i = 0; i < frame.length; i++) { lastGPS[i] = frame[i]; } - console.log("frameValid: " + frameValid); - console.log("frame: " + frame); - console.log("frameType: " + frameType); - console.log("frameOffset: " + frameOffset); - console.log("frameSize: " + frameSize); - - //parser.onFrameReady = function(frameValid, frame, frameType, frameOffset, frameSize) { -// console.log("local frames", chunk.frames[chunk.frames.length - 1]); -// chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[0]')] = lastGPS[0]; -// chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[1]')] = lastGPS[1]; -// chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[2]')] = lastGPS[2]; -// chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[3]')] = lastGPS[3]; -// chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[4]')] = lastGPS[4]; -// chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[5]')] = lastGPS[5]; - //chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[6]')] = lastGPS[6]; - - //getMainFieldIndexByName break; } - // Logs gps values, but out of sync for some reason - /* - console.log("local frames", chunk.frames[chunk.frames.length - 1]); - chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[0]')] = lastGPS[0]; - chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[1]')] = lastGPS[1]; - chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[2]')] = lastGPS[2]; - chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[3]')] = lastGPS[3]; - chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[4]')] = lastGPS[4]; - chunk.frames[chunk.frames.length - 1][that.getMainFieldIndexByName('lastGPS[5]')] = lastGPS[5]; - */ } else { chunk.gapStartsHere[mainFrameIndex - 1] = true; } @@ -527,8 +491,6 @@ function FlightLog(logData) { chunkCache.add(chunkIndex, chunk); } - console.log("chunk",chunk) - resultChunks.push(chunk); } @@ -597,10 +559,6 @@ function FlightLog(logData) { let motor = [fieldNameToIndex["motor[0]"], fieldNameToIndex["motor[1]"], fieldNameToIndex["motor[2]"], fieldNameToIndex["motor[3]"], fieldNameToIndex["motor[4]"], fieldNameToIndex["motor[5]"], fieldNameToIndex["motor[6]"], fieldNameToIndex["motor[7]"]]; - - //TODO let gps = [fieldNameToIndex["lastGPS[0]"], fieldNameToIndex["lastGPS[1]"], fieldNameToIndex["lastGPS[2]"], fieldNameToIndex["lastGPS[3]"], fieldNameToIndex["lastGPS[4]"], fieldNameToIndex["lastGPS[5]"], fieldNameToIndex["lastGPS[6]"]]; - //console.log("gps",gps) - let sourceChunkIndex; let destChunkIndex; let attitude; @@ -640,10 +598,6 @@ function FlightLog(logData) { motor = false; } - /*if (!gps[0]) { - gps = false; - }*/ - sourceChunkIndex = 0; destChunkIndex = 0; @@ -745,21 +699,6 @@ function FlightLog(logData) { } } - /*if(gps) { - console.log("GPS"); - console.log("destFrame", destFrame); - console.log("srcFrame", srcFrame); - destFrame[fieldIndex++] = srcFrame[gps[0]]; - //destFrame[fieldIndex++] = 42069; - destFrame[fieldIndex++] = srcFrame[gps[1]]; - destFrame[fieldIndex++] = srcFrame[gps[2]]; - destFrame[fieldIndex++] = srcFrame[gps[3]]; - destFrame[fieldIndex++] = srcFrame[gps[4]]; - destFrame[fieldIndex++] = srcFrame[gps[5]]; - destFrame[fieldIndex++] = srcFrame[gps[6]]; - console.log("destFrame", destFrame); - console.log("srcFrame", srcFrame); - }*/ // Remove empty fields at the end destFrame.splice(fieldIndex); diff --git a/js/flightlog_fields_presenter.js b/js/flightlog_fields_presenter.js index 02d1da21..dee12f30 100644 --- a/js/flightlog_fields_presenter.js +++ b/js/flightlog_fields_presenter.js @@ -991,17 +991,17 @@ function FlightLogFieldPresenter() { //H Field G name:time,GPS_numSat,GPS_coord[0],GPS_coord[1],GPS_altitude,GPS_speed,GPS_ground_course case 'lastGPS[0]': - case 'lastGPS[1]': + case 'lastGPS[1]': // GPS_numSat return `${value}`; - case 'lastGPS[2]': + case 'lastGPS[2]': // GPS_coord[0] return `${(value/1000000).toFixed(2)}`; - case 'lastGPS[3]': + case 'lastGPS[3]': // GPS_coord[1] return `${(value/10000000).toFixed(2)}`; - case 'lastGPS[4]': + case 'lastGPS[4]': // GPS_altitude return `${(value/10).toFixed(2)}`; - case 'lastGPS[5]': + case 'lastGPS[5]': // GPS_speed return `${(value/100).toFixed(2)}`; - case 'lastGPS[6]': + case 'lastGPS[6]': // GPS_ground_course return `${(value/10).toFixed(2)}`; diff --git a/js/flightlog_index.js b/js/flightlog_index.js index 2489d901..b90af326 100644 --- a/js/flightlog_index.js +++ b/js/flightlog_index.js @@ -87,23 +87,8 @@ function FlightLogIndex(logData) { lastSlow = [], lastGPSHome = [], lastGPS = [] - - // is this needed? - //gpsFrameDef = parser.frameDefs.G, - /*lastGPS = [ - gpsFrameDef.nameToIndex["time"], - gpsFrameDef.nameToIndex["GPS_numSat"], - gpsFrameDef.nameToIndex["GPS_coord[0]"], - gpsFrameDef.nameToIndex["GPS_coord[1]"], - gpsFrameDef.nameToIndex["GPS_altitude"], - gpsFrameDef.nameToIndex["GPS_speed"], - gpsFrameDef.nameToIndex["GPS_ground_course"] - ]*/ - ; - console.log("mainFrameDef: ", mainFrameDef); - // Identify motor fields so they can be used to show the activity summary bar for (var j = 0; j < 8; j++) { diff --git a/js/grapher.js b/js/grapher.js index bea3b1af..c76e1023 100644 --- a/js/grapher.js +++ b/js/grapher.js @@ -246,7 +246,6 @@ function FlightLogGrapher(flightLog, graphConfig, canvas, stickCanvas, craftCanv break; default: idents.miscFields.push(fieldIndex); - console.log("miscFields", idents.miscFields); } } } From b8778674897f2dd45a587b2c4735edd42cda6686 Mon Sep 17 00:00:00 2001 From: Linus Thorsell Date: Mon, 21 Nov 2022 22:20:13 +0100 Subject: [PATCH 08/18] fixed names in table --- js/flightlog.js | 8 ++++---- js/flightlog_fields_presenter.js | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/js/flightlog.js b/js/flightlog.js index 27211840..36f06b27 100644 --- a/js/flightlog.js +++ b/js/flightlog.js @@ -418,12 +418,12 @@ function FlightLog(logData) { } // Then merge in the last seen slow-frame data - for (var i = 0; i < slowFrameLength; i++) { - destFrame[i + frame.length] = lastSlow[i] === undefined ? null : lastSlow[i]; + for (let slowFrameIndex = 0; slowFrameIndex < slowFrameLength; slowFrameIndex++) { + destFrame[slowFrameIndex + frame.length] = lastSlow[slowFrameIndex] === undefined ? null : lastSlow[slowFrameIndex]; } // Also merge last seen gps-frame data - for (var i = 0; i < lastGPSLength; i++) { - destFrame[i + frame.length + slowFrameLength] = lastGPS[i] === undefined ? null : lastGPS[i]; + for (let gpsFrameIndex = 0; gpsFrameIndex < lastGPSLength; gpsFrameIndex++) { + destFrame[gpsFrameIndex + frame.length + slowFrameLength] = lastGPS[gpsFrameIndex] === undefined ? null : lastGPS[gpsFrameIndex]; } for (var i = 0; i < eventNeedsTimestamp.length; i++) { diff --git a/js/flightlog_fields_presenter.js b/js/flightlog_fields_presenter.js index dee12f30..9500e143 100644 --- a/js/flightlog_fields_presenter.js +++ b/js/flightlog_fields_presenter.js @@ -107,15 +107,15 @@ function FlightLogFieldPresenter() { 'rxFlightChannelsValid': 'RX Flight Ch. Valid', 'rssi': 'RSSI', - 'lastGPS[all]': 'GPS Data', - 'lastGPS[0]': "GPS timeframe", - 'lastGPS[1]': "GPS NumSat", - 'lastGPS[2]': "GPS Latitude", - 'lastGPS[3]': "GPS Longitude", - 'lastGPS[4]': "GPS Altitude", - 'lastGPS[5]': "GPS Speed", - 'lastGPS[6]': "GPS Ground course", + //'time': "GPS timeframe", can't change this one since + //it shares a name with the normal time field. + 'GPS_numSat': "GPS NumSat", + 'GPS_coord[0]': "GPS Latitude", + 'GPS_coord[1]': "GPS Longitude", + 'GPS_altitude': "GPS Altitude", + 'GPS_speed': "GPS Speed", + 'GPS_ground_course': "GPS Ground course", }; const DEBUG_FRIENDLY_FIELD_NAMES_INITIAL = { @@ -994,15 +994,15 @@ function FlightLogFieldPresenter() { case 'lastGPS[1]': // GPS_numSat return `${value}`; case 'lastGPS[2]': // GPS_coord[0] - return `${(value/1000000).toFixed(2)}`; + return `${value}`; case 'lastGPS[3]': // GPS_coord[1] - return `${(value/10000000).toFixed(2)}`; + return `${value}`; case 'lastGPS[4]': // GPS_altitude - return `${(value/10).toFixed(2)}`; + return `${value}`; case 'lastGPS[5]': // GPS_speed - return `${(value/100).toFixed(2)}`; + return `${value}`; case 'lastGPS[6]': // GPS_ground_course - return `${(value/10).toFixed(2)}`; + return `${value}`; case 'debug[0]': From 0dc32958676bc8f0dbfeb6d9f99d7032c00af048 Mon Sep 17 00:00:00 2001 From: Linus Thorsell Date: Mon, 21 Nov 2022 22:28:30 +0100 Subject: [PATCH 09/18] removed test code in main, remove whitespaces --- js/flightlog_fields_presenter.js | 2 -- js/flightlog_index.js | 5 +---- js/main.js | 4 ---- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/js/flightlog_fields_presenter.js b/js/flightlog_fields_presenter.js index 9500e143..819c295f 100644 --- a/js/flightlog_fields_presenter.js +++ b/js/flightlog_fields_presenter.js @@ -869,8 +869,6 @@ function FlightLogFieldPresenter() { const highResolutionScale = (flightLog && flightLog.getSysConfig().blackbox_high_resolution > 0) ? 10 : 1; const highResolutionAddPrecision = (flightLog && flightLog.getSysConfig().blackbox_high_resolution > 0) ? 1 : 0; - //if (fieldName.toUpperCase().includes("GPS")) console.log("GPSfieldName", fieldName); - switch (fieldName) { case 'time': return formatTime(value / 1000, true); diff --git a/js/flightlog_index.js b/js/flightlog_index.js index b90af326..1fe69d4d 100644 --- a/js/flightlog_index.js +++ b/js/flightlog_index.js @@ -78,7 +78,6 @@ function FlightLogIndex(logData) { var sysConfig = parser.sysConfig, mainFrameDef = parser.frameDefs.I, - gyroADC = [mainFrameDef.nameToIndex["gyroADC[0]"], mainFrameDef.nameToIndex["gyroADC[1]"], mainFrameDef.nameToIndex["gyroADC[2]"]], accSmooth = [mainFrameDef.nameToIndex["accSmooth[0]"], mainFrameDef.nameToIndex["accSmooth[1]"], mainFrameDef.nameToIndex["accSmooth[2]"]], @@ -86,9 +85,7 @@ function FlightLogIndex(logData) { lastSlow = [], lastGPSHome = [], - lastGPS = [] - ; - + lastGPS = []; // Identify motor fields so they can be used to show the activity summary bar for (var j = 0; j < 8; j++) { diff --git a/js/main.js b/js/main.js index 642ef8c2..17f86e7b 100644 --- a/js/main.js +++ b/js/main.js @@ -167,10 +167,6 @@ function BlackboxLogViewer() { if (value === null) return "(absent)"; - if (typeof value == 'undefined') { - return "undefined"; - } - return value.toFixed(2); } From cd08b16252619d503933549023a753db4f2afa6a Mon Sep 17 00:00:00 2001 From: bonchan Date: Mon, 21 Nov 2022 20:01:06 -0300 Subject: [PATCH 10/18] fixed GPS cases and added gps example graph --- js/flightlog_fields_presenter.js | 21 +++++++++------------ js/graph_config.js | 2 +- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/js/flightlog_fields_presenter.js b/js/flightlog_fields_presenter.js index 819c295f..6da0d850 100644 --- a/js/flightlog_fields_presenter.js +++ b/js/flightlog_fields_presenter.js @@ -107,7 +107,6 @@ function FlightLogFieldPresenter() { 'rxFlightChannelsValid': 'RX Flight Ch. Valid', 'rssi': 'RSSI', - 'lastGPS[all]': 'GPS Data', //'time': "GPS timeframe", can't change this one since //it shares a name with the normal time field. 'GPS_numSat': "GPS NumSat", @@ -988,18 +987,16 @@ function FlightLogFieldPresenter() { return (value / 1024 * 100).toFixed(2) + " %"; //H Field G name:time,GPS_numSat,GPS_coord[0],GPS_coord[1],GPS_altitude,GPS_speed,GPS_ground_course - case 'lastGPS[0]': - case 'lastGPS[1]': // GPS_numSat + case 'GPS_numSat': // GPS_numSat return `${value}`; - case 'lastGPS[2]': // GPS_coord[0] - return `${value}`; - case 'lastGPS[3]': // GPS_coord[1] - return `${value}`; - case 'lastGPS[4]': // GPS_altitude - return `${value}`; - case 'lastGPS[5]': // GPS_speed - return `${value}`; - case 'lastGPS[6]': // GPS_ground_course + case 'GPS_coord[0]': // GPS_coord[0] + case 'GPS_coord[1]': // GPS_coord[1] + return `${(value/10000000).toFixed(5)}`; + case 'GPS_altitude': // GPS_altitude + return `${(value/1000).toFixed(1)} m`; + case 'GPS_speed': // GPS_speed + return `${(value/100).toFixed(2)} m/s`; + case 'GPS_ground_course': // GPS_ground_course return `${value}`; diff --git a/js/graph_config.js b/js/graph_config.js index 5de1a0f7..d9eea373 100644 --- a/js/graph_config.js +++ b/js/graph_config.js @@ -957,7 +957,7 @@ GraphConfig.load = function(config) { } if (!flightLog.isFieldDisabled().GPS) { - EXAMPLE_GRAPHS.push({label: "GPS",fields: ["lastGPS[all]"]}); + EXAMPLE_GRAPHS.push({label: "GPS",fields: ["GPS_numSat", "GPS_altitude", "GPS_speed", "GPS_ground_course", "GPS_coord[all]"]}); } for (i = 0; i < EXAMPLE_GRAPHS.length; i++) { From cd5f0220aa3ac62702df8a6746d528bb0fd06491 Mon Sep 17 00:00:00 2001 From: Linus Thorsell <45761642+LinusThorsell@users.noreply.github.com> Date: Tue, 22 Nov 2022 09:12:45 +0100 Subject: [PATCH 11/18] using const name of, instead of normal for in flightlog as suggested by haslinghuis Co-authored-by: haslinghuis --- js/flightlog.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/flightlog.js b/js/flightlog.js index 36f06b27..01160ccd 100644 --- a/js/flightlog.js +++ b/js/flightlog.js @@ -220,8 +220,8 @@ function FlightLog(logData) { } // Add names of gps fields which we'll merge into the main stream if (parser.frameDefs.G) { - for (let i = 0; i < parser.frameDefs.G.name.length; i++) { - fieldNames.push(parser.frameDefs.G.name[i]); + for (const name of parser.frameDefs.G.name) { + fieldNames.push(name); } } From 3ac4278f04720cd828c7b07938d9bbee4d60230a Mon Sep 17 00:00:00 2001 From: Linus Thorsell Date: Tue, 22 Nov 2022 11:01:54 +0100 Subject: [PATCH 12/18] changes suggested by ctzsnooze (presentability) Changed GPS Ground Course to GPS Heading Changed GPS numSat to GPS Sat Count Changed gps heading to return from 180 to -180 degrees. --- js/flightlog_fields_presenter.js | 18 +++++++++--------- js/graph_config.js | 7 +++++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/js/flightlog_fields_presenter.js b/js/flightlog_fields_presenter.js index 6da0d850..3ede0a6d 100644 --- a/js/flightlog_fields_presenter.js +++ b/js/flightlog_fields_presenter.js @@ -109,12 +109,12 @@ function FlightLogFieldPresenter() { //'time': "GPS timeframe", can't change this one since //it shares a name with the normal time field. - 'GPS_numSat': "GPS NumSat", + 'GPS_numSat': "GPS Sat Count", 'GPS_coord[0]': "GPS Latitude", 'GPS_coord[1]': "GPS Longitude", 'GPS_altitude': "GPS Altitude", 'GPS_speed': "GPS Speed", - 'GPS_ground_course': "GPS Ground course", + 'GPS_ground_course': "GPS Heading", }; const DEBUG_FRIENDLY_FIELD_NAMES_INITIAL = { @@ -987,17 +987,17 @@ function FlightLogFieldPresenter() { return (value / 1024 * 100).toFixed(2) + " %"; //H Field G name:time,GPS_numSat,GPS_coord[0],GPS_coord[1],GPS_altitude,GPS_speed,GPS_ground_course - case 'GPS_numSat': // GPS_numSat + case 'GPS_numSat': return `${value}`; - case 'GPS_coord[0]': // GPS_coord[0] - case 'GPS_coord[1]': // GPS_coord[1] + case 'GPS_coord[0]': + case 'GPS_coord[1]': return `${(value/10000000).toFixed(5)}`; - case 'GPS_altitude': // GPS_altitude + case 'GPS_altitude': return `${(value/1000).toFixed(1)} m`; - case 'GPS_speed': // GPS_speed + case 'GPS_speed': return `${(value/100).toFixed(2)} m/s`; - case 'GPS_ground_course': // GPS_ground_course - return `${value}`; + case 'GPS_ground_course': + return `${(value/10).toFixed(1)} °`; case 'debug[0]': diff --git a/js/graph_config.js b/js/graph_config.js index d9eea373..4ea18b7d 100644 --- a/js/graph_config.js +++ b/js/graph_config.js @@ -353,6 +353,13 @@ GraphConfig.load = function(config) { inputRange: 512, outputRange: 1.0 }; + } else if (fieldName == 'GPS_ground_course') { + return { + offset: -1800, + power: 1.0, + inputRange: 1800, + outputRange: 1.0 + }; } else if (fieldName.match(/^debug.*/) && sysConfig.debug_mode!=null) { var debugModeName = DEBUG_MODE[sysConfig.debug_mode]; From 368711ca88a3c525ca34ee1b9d2f5ba7c86911d7 Mon Sep 17 00:00:00 2001 From: Linus Thorsell Date: Tue, 22 Nov 2022 11:09:20 +0100 Subject: [PATCH 13/18] readability changes --- js/flightlog.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/js/flightlog.js b/js/flightlog.js index 01160ccd..4b0dd137 100644 --- a/js/flightlog.js +++ b/js/flightlog.js @@ -387,7 +387,8 @@ function FlightLog(logData) { parser.onFrameReady = function(frameValid, frame, frameType, frameOffset, frameSize) { var - destFrame; + destFrame, + destFrame_currentIndex; // The G frames need to be processed always. They are "invalid" if not H (Home) has been detected // before, but if not processed the viewer shows cuts and gaps. This happens if the quad takes off before @@ -417,14 +418,18 @@ function FlightLog(logData) { destFrame[i] = frame[i]; } + destFrame_currentIndex = frame.length; // Keeps track of where to place direct data in the destFrame. // Then merge in the last seen slow-frame data for (let slowFrameIndex = 0; slowFrameIndex < slowFrameLength; slowFrameIndex++) { - destFrame[slowFrameIndex + frame.length] = lastSlow[slowFrameIndex] === undefined ? null : lastSlow[slowFrameIndex]; + destFrame[slowFrameIndex + destFrame_currentIndex] = lastSlow[slowFrameIndex] === undefined ? null : lastSlow[slowFrameIndex]; } + destFrame_currentIndex += slowFrameLength; + // Also merge last seen gps-frame data for (let gpsFrameIndex = 0; gpsFrameIndex < lastGPSLength; gpsFrameIndex++) { - destFrame[gpsFrameIndex + frame.length + slowFrameLength] = lastGPS[gpsFrameIndex] === undefined ? null : lastGPS[gpsFrameIndex]; + destFrame[gpsFrameIndex + destFrame_currentIndex] = lastGPS[gpsFrameIndex] === undefined ? null : lastGPS[gpsFrameIndex]; } + destFrame_currentIndex += lastGPSLength; for (var i = 0; i < eventNeedsTimestamp.length; i++) { eventNeedsTimestamp[i].time = frame[FlightLogParser.prototype.FLIGHT_LOG_FIELD_INDEX_TIME]; From f1bb6a430be48775069a80a6db5eb6033e109a29 Mon Sep 17 00:00:00 2001 From: Linus Thorsell Date: Tue, 22 Nov 2022 11:21:44 +0100 Subject: [PATCH 14/18] make numsat and speed start at bottom of graph --- js/graph_config.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/js/graph_config.js b/js/graph_config.js index 4ea18b7d..9e28e965 100644 --- a/js/graph_config.js +++ b/js/graph_config.js @@ -360,6 +360,20 @@ GraphConfig.load = function(config) { inputRange: 1800, outputRange: 1.0 }; + } else if (fieldName == 'GPS_numSat') { + return { + offset: -20, + power: 1.0, + inputRange: 20, + outputRange: 1.0 + }; + } else if (fieldName == 'GPS_speed') { + return { + offset: 0, + power: 1.0, + inputRange: 1000, + outputRange: 1.0 + }; } else if (fieldName.match(/^debug.*/) && sysConfig.debug_mode!=null) { var debugModeName = DEBUG_MODE[sysConfig.debug_mode]; From cabd414378f112a46fb499ea118a3400c7163666 Mon Sep 17 00:00:00 2001 From: Linus Thorsell Date: Tue, 22 Nov 2022 12:34:14 +0100 Subject: [PATCH 15/18] removed time field. refactored code --- js/flightlog.js | 13 ++++++++----- js/flightlog_index.js | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/js/flightlog.js b/js/flightlog.js index 4b0dd137..43423a03 100644 --- a/js/flightlog.js +++ b/js/flightlog.js @@ -214,14 +214,16 @@ function FlightLog(logData) { // Add names of slow fields which we'll merge into the main stream if (parser.frameDefs.S) { - for (let i = 0; i < parser.frameDefs.S.name.length; i++) { - fieldNames.push(parser.frameDefs.S.name[i]); + for (const name of parser.frameDefs.S.name) { + fieldNames.push(name); } } // Add names of gps fields which we'll merge into the main stream if (parser.frameDefs.G) { for (const name of parser.frameDefs.G.name) { - fieldNames.push(name); + if (name !== 'time') { // remove duplicate time field + fieldNames.push(name); + } } } @@ -382,7 +384,7 @@ function FlightLog(logData) { mainFrameIndex = 0, slowFrameLength = parser.frameDefs.S ? parser.frameDefs.S.count : 0, lastSlow = parser.frameDefs.S ? iframeDirectory.initialSlow[chunkIndex].slice(0) : [], - lastGPSLength = parser.frameDefs.G ? parser.frameDefs.G.count : 0, //Should I expand the outputFields? + lastGPSLength = parser.frameDefs.G ? parser.frameDefs.G.count-1 : 0, // -1 since we exclude the time field lastGPS = parser.frameDefs.G ? iframeDirectory.initialGPS[chunkIndex].slice(0) : []; parser.onFrameReady = function(frameValid, frame, frameType, frameOffset, frameSize) { @@ -429,7 +431,7 @@ function FlightLog(logData) { for (let gpsFrameIndex = 0; gpsFrameIndex < lastGPSLength; gpsFrameIndex++) { destFrame[gpsFrameIndex + destFrame_currentIndex] = lastGPS[gpsFrameIndex] === undefined ? null : lastGPS[gpsFrameIndex]; } - destFrame_currentIndex += lastGPSLength; + // destFrame_currentIndex += lastGPSLength; Add this line if you wish to add more fields. for (var i = 0; i < eventNeedsTimestamp.length; i++) { eventNeedsTimestamp[i].time = frame[FlightLogParser.prototype.FLIGHT_LOG_FIELD_INDEX_TIME]; @@ -471,6 +473,7 @@ function FlightLog(logData) { // But other data from the G frame can be valid (time, num sats) //H Field G name:time,GPS_numSat,GPS_coord[0],GPS_coord[1],GPS_altitude,GPS_speed,GPS_ground_course + frame.shift(); // remove time for (let i = 0; i < frame.length; i++) { lastGPS[i] = frame[i]; } diff --git a/js/flightlog_index.js b/js/flightlog_index.js index 1fe69d4d..b42f531e 100644 --- a/js/flightlog_index.js +++ b/js/flightlog_index.js @@ -158,6 +158,7 @@ function FlightLogIndex(logData) { break; case 'G': lastGPS = frame.slice(0); + lastGPS.shift(); // Remove the time field break; case 'H': lastGPSHome = frame.slice(0); From f2949e576687476e40bb772b0bf1db16687b38ed Mon Sep 17 00:00:00 2001 From: Linus Thorsell Date: Tue, 22 Nov 2022 12:38:27 +0100 Subject: [PATCH 16/18] cosmetic code changes --- js/flightlog_fields_presenter.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/js/flightlog_fields_presenter.js b/js/flightlog_fields_presenter.js index 3ede0a6d..07e04ca6 100644 --- a/js/flightlog_fields_presenter.js +++ b/js/flightlog_fields_presenter.js @@ -107,8 +107,6 @@ function FlightLogFieldPresenter() { 'rxFlightChannelsValid': 'RX Flight Ch. Valid', 'rssi': 'RSSI', - //'time': "GPS timeframe", can't change this one since - //it shares a name with the normal time field. 'GPS_numSat': "GPS Sat Count", 'GPS_coord[0]': "GPS Latitude", 'GPS_coord[1]': "GPS Longitude", @@ -999,7 +997,6 @@ function FlightLogFieldPresenter() { case 'GPS_ground_course': return `${(value/10).toFixed(1)} °`; - case 'debug[0]': case 'debug[1]': case 'debug[2]': From 44d91e26844832e4db6f3fb7b819c0bc829ceabe Mon Sep 17 00:00:00 2001 From: Linus Thorsell Date: Tue, 22 Nov 2022 12:44:10 +0100 Subject: [PATCH 17/18] changed live gps to GPS Reported Altitude --- js/flightlog_fields_presenter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/flightlog_fields_presenter.js b/js/flightlog_fields_presenter.js index 07e04ca6..429ad4e2 100644 --- a/js/flightlog_fields_presenter.js +++ b/js/flightlog_fields_presenter.js @@ -110,7 +110,7 @@ function FlightLogFieldPresenter() { 'GPS_numSat': "GPS Sat Count", 'GPS_coord[0]': "GPS Latitude", 'GPS_coord[1]': "GPS Longitude", - 'GPS_altitude': "GPS Altitude", + 'GPS_altitude': "GPS Reported Altitude", 'GPS_speed': "GPS Speed", 'GPS_ground_course': "GPS Heading", }; From b1bc7a51cbc49f8b2e62d3b01f2afa988f876ea3 Mon Sep 17 00:00:00 2001 From: Linus Thorsell Date: Wed, 23 Nov 2022 10:38:06 +0100 Subject: [PATCH 18/18] fixed gps ASL altitude scaling, changed reported gps alt to alt ASL --- js/flightlog_fields_presenter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/flightlog_fields_presenter.js b/js/flightlog_fields_presenter.js index 429ad4e2..d8011eb5 100644 --- a/js/flightlog_fields_presenter.js +++ b/js/flightlog_fields_presenter.js @@ -110,7 +110,7 @@ function FlightLogFieldPresenter() { 'GPS_numSat': "GPS Sat Count", 'GPS_coord[0]': "GPS Latitude", 'GPS_coord[1]': "GPS Longitude", - 'GPS_altitude': "GPS Reported Altitude", + 'GPS_altitude': "GPS Altitude ASL", 'GPS_speed': "GPS Speed", 'GPS_ground_course': "GPS Heading", }; @@ -991,7 +991,7 @@ function FlightLogFieldPresenter() { case 'GPS_coord[1]': return `${(value/10000000).toFixed(5)}`; case 'GPS_altitude': - return `${(value/1000).toFixed(1)} m`; + return `${(value/10).toFixed(2)} m`; case 'GPS_speed': return `${(value/100).toFixed(2)} m/s`; case 'GPS_ground_course':