Skip to content
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

DataflashParser: fix applying multipliers #224

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
24 changes: 12 additions & 12 deletions src/tools/dataflashDataExtractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
}
Expand All @@ -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]]
}
Expand All @@ -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]]
}
Expand Down
15 changes: 7 additions & 8 deletions src/tools/parsers/dataflashParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down Expand Up @@ -668,15 +667,15 @@ export class DataflashParser {
messageTypes[msg.Name + '[' + instance + ']'] = {
expressions: fields,
units: msg.units,
multipiers: msg.multipliers,
multipliers: msg.multipliers,
complexFields: complexFields
}
}
} else {
messageTypes[msg.Name] = {
expressions: fields,
units: msg.units,
multipiers: msg.multipliers,
multipliers: msg.multipliers,
complexFields: complexFields
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/parsers/mavlinkParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export class MavlinkParser {
messageTypes[msg] = {
expressions: fields,
units: null,
multipiers: null,
multipliers: null,
complexFields: complexFields
}
}
Expand Down