From 34802258a11a1a8573a56d8c207505d0d95bc95f Mon Sep 17 00:00:00 2001 From: bkleiner Date: Fri, 11 Aug 2023 01:41:21 +0200 Subject: [PATCH] add blackbox unit, pid sum --- src/components/TimeGraphComponent.vue | 4 ++- src/stores/blackbox.ts | 38 +++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/components/TimeGraphComponent.vue b/src/components/TimeGraphComponent.vue index 7f98670..d9e2f29 100644 --- a/src/components/TimeGraphComponent.vue +++ b/src/components/TimeGraphComponent.vue @@ -17,6 +17,7 @@ import { defineComponent } from "vue"; import { blackboxFieldIDToString, transformBlackbox, + unitBlackbox, useBlackboxStore, } from "@/stores/blackbox"; import CanvasComponent from "@/components/CanvasComponent.vue"; @@ -136,8 +137,9 @@ export default defineComponent({ return { field, str }; }) .map(({ field, str }) => { + const unit = unitBlackbox(field); while (str.length < maxLen) str = " " + str; - return field.title + " " + str; + return field.title + " " + str + " " + unit; }); }, }, diff --git a/src/stores/blackbox.ts b/src/stores/blackbox.ts index 6b48f45..ff1e60f 100644 --- a/src/stores/blackbox.ts +++ b/src/stores/blackbox.ts @@ -38,6 +38,19 @@ export function transformBlackbox(field: BlackboxFieldDef, val: number) { } } +export function unitBlackbox(field: BlackboxFieldDef) { + switch (field.unit) { + case BlackboxFieldUnit.RADIANS: + return "deg"; + + case BlackboxFieldUnit.US: + return "us"; + + default: + return ""; + } +} + function processEntries(entries: any[], fields: BlackboxFieldDef[]) { const rawEntries = entries.filter((entry: any[], index: number) => { if (entry.length != fields.length) { @@ -82,13 +95,13 @@ export const useBlackboxStore = defineStore("blackbox", { const options = [[]] as any[]; const fields = Object.values(this.fields); - for (const field of fields) { + const generateOption = (field: BlackboxFieldDef) => { if (!Array.isArray(field?.axis)) { options[0].push({ ...field, id: { name: field.name } as BlackboxFieldID, }); - continue; + return; } const opt: any[] = [ @@ -109,7 +122,18 @@ export const useBlackboxStore = defineStore("blackbox", { }), ]; options.push(opt); + }; + + for (const field of fields) { + generateOption(field); } + generateOption({ + name: "pid_sum", + scale: 3000, + title: "Pid Sum", + unit: BlackboxFieldUnit.NONE, + axis: ["Roll", "Pitch", "Yaw"], + }); return options; }, @@ -168,6 +192,16 @@ export const useBlackboxStore = defineStore("blackbox", { entries[blackboxFieldIDToString(id)] = Float32Array.from(values); } } + for (let axis = 0; axis < 3; axis++) { + entries[`pid_sum_${axis}`] = entries.time.map((_, index) => { + return ( + entries[`pid_pterm_${axis}`][index] + + entries[`pid_iterm_${axis}`][index] + + entries[`pid_dterm_${axis}`][index] + ); + }); + } + this.entries = entries; this.duration =