From 954ca9a577c0282870889977a60011215c030a1c Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 19 Dec 2023 15:47:53 -0500 Subject: [PATCH 1/2] Record standard deviations for multi-tag pose (#1019) * Record standard deviations for multi-tag pose * Add XYZ translation and angle to stdev uI * create multitag result buffer in store allows results to be stored in the background * simplify logic in targeting tab also adds a reset button * Formatting fixes * convert rad angles to deg --------- Co-authored-by: Sriman Achanta <68172138+srimanachanta@users.noreply.github.com> --- .../components/dashboard/tabs/TargetsTab.vue | 146 ++++++++++++++---- photon-client/src/stores/StateStore.ts | 22 ++- .../src/types/PhotonTrackingTypes.ts | 2 + .../common/util/SerializationUtils.java | 2 + 4 files changed, 142 insertions(+), 30 deletions(-) diff --git a/photon-client/src/components/dashboard/tabs/TargetsTab.vue b/photon-client/src/components/dashboard/tabs/TargetsTab.vue index ac6aa632c4..11f20f0810 100644 --- a/photon-client/src/components/dashboard/tabs/TargetsTab.vue +++ b/photon-client/src/components/dashboard/tabs/TargetsTab.vue @@ -3,13 +3,22 @@ import { useCameraSettingsStore } from "@/stores/settings/CameraSettingsStore"; import { PipelineType } from "@/types/PipelineTypes"; import { useStateStore } from "@/stores/StateStore"; -const currentPipelineSettings = useCameraSettingsStore().currentPipelineSettings; +const calculateStdDev = (values: number[]): number => { + if (values.length < 2) return 0; + + const mean = values.reduce((sum, number) => sum + number, 0) / values.length; + + return Math.sqrt(values.map((x) => Math.pow(x - mean, 2)).reduce((a, b) => a + b) / values.length); +}; +const resetCurrentBuffer = () => { + // Need to clear the array in place + while (useStateStore().currentMultitagBuffer?.length != 0) useStateStore().currentMultitagBuffer?.pop(); +}; diff --git a/photon-client/src/stores/StateStore.ts b/photon-client/src/stores/StateStore.ts index 3f51b56fb2..47ec05eb82 100644 --- a/photon-client/src/stores/StateStore.ts +++ b/photon-client/src/stores/StateStore.ts @@ -1,7 +1,7 @@ import { defineStore } from "pinia"; import type { LogMessage } from "@/types/SettingTypes"; import type { AutoReconnectingWebsocket } from "@/lib/AutoReconnectingWebsocket"; -import type { PipelineResult } from "@/types/PhotonTrackingTypes"; +import type { MultitagResult, PipelineResult } from "@/types/PhotonTrackingTypes"; import type { WebsocketCalibrationData, WebsocketLogMessage, @@ -25,6 +25,7 @@ interface StateStore { currentCameraIndex: number; backendResults: Record; + multitagResultBuffer: Record; colorPickingMode: boolean; @@ -59,6 +60,7 @@ export const useStateStore = defineStore("state", { currentCameraIndex: 0, backendResults: {}, + multitagResultBuffer: {}, colorPickingMode: false, @@ -80,6 +82,9 @@ export const useStateStore = defineStore("state", { getters: { currentPipelineResults(): PipelineResult | undefined { return this.backendResults[this.currentCameraIndex.toString()]; + }, + currentMultitagBuffer(): MultitagResult[] | undefined { + return this.multitagResultBuffer[this.currentCameraIndex.toString()]; } }, actions: { @@ -105,6 +110,21 @@ export const useStateStore = defineStore("state", { ...this.backendResults, ...data }; + + for (const key in data) { + const multitagRes = data[key].multitagResult; + + if (multitagRes) { + if (!this.multitagResultBuffer[key]) { + this.multitagResultBuffer[key] = []; + } + + this.multitagResultBuffer[key].push(multitagRes); + if (this.multitagResultBuffer[key].length > 100) { + this.multitagResultBuffer[key].shift(); + } + } + } }, updateCalibrationStateValuesFromWebsocket(data: WebsocketCalibrationData) { this.calibrationData = { diff --git a/photon-client/src/types/PhotonTrackingTypes.ts b/photon-client/src/types/PhotonTrackingTypes.ts index ee19240ffa..c5589dc0ab 100644 --- a/photon-client/src/types/PhotonTrackingTypes.ts +++ b/photon-client/src/types/PhotonTrackingTypes.ts @@ -6,6 +6,8 @@ export interface Transform3d { qx: number; qy: number; qz: number; + angle_x: number; + angle_y: number; angle_z: number; } diff --git a/photon-core/src/main/java/org/photonvision/common/util/SerializationUtils.java b/photon-core/src/main/java/org/photonvision/common/util/SerializationUtils.java index 6fc3ea9c30..db41f548b1 100644 --- a/photon-core/src/main/java/org/photonvision/common/util/SerializationUtils.java +++ b/photon-core/src/main/java/org/photonvision/common/util/SerializationUtils.java @@ -55,6 +55,8 @@ public static HashMap transformToHashMap(Transform3d transform) ret.put("qy", transform.getRotation().getQuaternion().getY()); ret.put("qz", transform.getRotation().getQuaternion().getZ()); + ret.put("angle_x", transform.getRotation().getX()); + ret.put("angle_y", transform.getRotation().getY()); ret.put("angle_z", transform.getRotation().getZ()); return ret; } From 0356eeeb5062a7d337cf24fca96c466e5bb063ff Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 19 Dec 2023 19:38:55 -0500 Subject: [PATCH 2/2] Install script use Java 17 --- scripts/install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index cfbaa2fa06..14fa346c5a 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -54,10 +54,10 @@ else fi echo "Installing the JRE..." -if ! package_is_installed openjdk-11-jre-headless +if ! package_is_installed openjdk-17-jre-headless then apt-get update - apt-get install --yes openjdk-11-jre-headless + apt-get install --yes openjdk-17-jre-headless fi echo "JRE installation complete."