From 8744e1a5669c5c14cf89ea8d1a8fc2cfd6c52e27 Mon Sep 17 00:00:00 2001 From: Willian Galvani Date: Sun, 6 Sep 2020 16:27:58 -0300 Subject: [PATCH] DataflashParser: fix applying multipliers --- src/tools/dataflashDataExtractor.js | 24 ++++++++++++------------ src/tools/parsers/dataflashParser.js | 15 +++++++-------- src/tools/parsers/mavlinkParser.js | 2 +- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/tools/dataflashDataExtractor.js b/src/tools/dataflashDataExtractor.js index a38963e7..1969aa40 100644 --- a/src/tools/dataflashDataExtractor.js +++ b/src/tools/dataflashDataExtractor.js @@ -260,15 +260,15 @@ export class DataflashDataExtractor { } trajectory.push( [ - gpsData.Lng[i] / 1e7, - gpsData.Lat[i] / 1e7, + gpsData.Lng[i], + gpsData.Lat[i], gpsData.Alt[i] - startAltitude, gpsData.time_boot_ms[i] ] ) timeTrajectory[gpsData.time_boot_ms[i]] = [ - gpsData.Lng[i] / 1e7, - gpsData.Lat[i] / 1e7, + gpsData.Lng[i], + gpsData.Lat[i], (gpsData.Alt[i] - startAltitude) / 1000, gpsData.time_boot_ms[i]] } @@ -293,15 +293,15 @@ export class DataflashDataExtractor { } trajectory.push( [ - gpsData.Lng[i] * 1e-7, - gpsData.Lat[i] * 1e-7, + gpsData.Lng[i], + gpsData.Lat[i], gpsData.Alt[i] - startAltitude, gpsData.time_boot_ms[i] ] ) timeTrajectory[gpsData.time_boot_ms[i]] = [ - gpsData.Lng[i] * 1e-7, - gpsData.Lat[i] * 1e-7, + gpsData.Lng[i], + gpsData.Lat[i], (gpsData.Alt[i] - startAltitude) / 1000, gpsData.time_boot_ms[i]] } @@ -326,15 +326,15 @@ export class DataflashDataExtractor { } trajectory.push( [ - gpsData.Lng[i] / 1e7, - gpsData.Lat[i] / 1e7, + gpsData.Lng[i], + gpsData.Lat[i], gpsData.Alt[i] - startAltitude, gpsData.time_boot_ms[i] ] ) timeTrajectory[gpsData.time_boot_ms[i]] = [ - gpsData.Lng[i] / 1e7, - gpsData.Lat[i] / 1e7, + gpsData.Lng[i], + gpsData.Lat[i], gpsData.Alt[i] - startAltitude, gpsData.time_boot_ms[i]] } diff --git a/src/tools/parsers/dataflashParser.js b/src/tools/parsers/dataflashParser.js index 62e8dfe0..dd830282 100644 --- a/src/tools/parsers/dataflashParser.js +++ b/src/tools/parsers/dataflashParser.js @@ -563,13 +563,12 @@ export class DataflashParser { fixDataOnce (name) { if (['GPS', 'ATT', 'AHR2', 'MODE'].indexOf(name) === -1) { if (this.messageTypes.hasOwnProperty(name)) { - let fields = this.messages[name][0].fieldnames + let fields = this.messageTypes[name].complexFields if (this.messageTypes[name].hasOwnProperty('multipliers')) { - for (let message in this.messages[name]) { - for (let i = 1; i < fields.length; i++) { - let fieldname = fields[i] - if (!isNaN(this.messageTypes[name].multipliers[i])) { - this.messages[name][message][fieldname] *= this.messageTypes[name].multipliers[i] + for (let [fieldname, field] of Object.entries(fields)) { + if (!isNaN(field.multiplier) && field.multiplier !== 0) { + for (let i = 0; i < this.messages[name].length; i++) { + this.messages[name][i][fieldname] *= field.multiplier } } } @@ -668,7 +667,7 @@ export class DataflashParser { messageTypes[msg.Name + '[' + instance + ']'] = { expressions: fields, units: msg.units, - multipiers: msg.multipliers, + multipliers: msg.multipliers, complexFields: complexFields } } @@ -676,7 +675,7 @@ export class DataflashParser { messageTypes[msg.Name] = { expressions: fields, units: msg.units, - multipiers: msg.multipliers, + multipliers: msg.multipliers, complexFields: complexFields } } diff --git a/src/tools/parsers/mavlinkParser.js b/src/tools/parsers/mavlinkParser.js index 4d111ae9..127654be 100644 --- a/src/tools/parsers/mavlinkParser.js +++ b/src/tools/parsers/mavlinkParser.js @@ -296,7 +296,7 @@ export class MavlinkParser { messageTypes[msg] = { expressions: fields, units: null, - multipiers: null, + multipliers: null, complexFields: complexFields } }