2023-08-21 01:51:35 -04:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { useCameraSettingsStore } from "@/stores/settings/CameraSettingsStore";
|
|
|
|
|
import { PipelineType } from "@/types/PipelineTypes";
|
|
|
|
|
import { useStateStore } from "@/stores/StateStore";
|
2023-10-21 11:09:55 -04:00
|
|
|
|
2023-12-28 12:40:50 -05:00
|
|
|
const wrapToPi = (delta: number): number => {
|
|
|
|
|
let ret = delta;
|
|
|
|
|
while (ret < -Math.PI) ret += Math.PI * 2;
|
|
|
|
|
while (ret > Math.PI) ret -= Math.PI * 2;
|
|
|
|
|
return ret;
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-19 15:47:53 -05:00
|
|
|
const calculateStdDev = (values: number[]): number => {
|
|
|
|
|
if (values.length < 2) return 0;
|
|
|
|
|
|
2023-12-28 12:40:50 -05:00
|
|
|
// Use mean of cosine/sine components to handle angle wrapping
|
|
|
|
|
const cosines = values.map((it) => Math.cos(it));
|
|
|
|
|
const sines = values.map((it) => Math.sin(it));
|
|
|
|
|
const cosmean = cosines.reduce((sum, number) => sum + number, 0) / values.length;
|
|
|
|
|
const sinmean = sines.reduce((sum, number) => sum + number, 0) / values.length;
|
|
|
|
|
|
|
|
|
|
// Borrowed from WPILib's Rotation2d
|
|
|
|
|
const hypot = Math.hypot(cosmean, sinmean);
|
|
|
|
|
let mean;
|
|
|
|
|
if (hypot > 1e-6) {
|
|
|
|
|
mean = Math.atan2(sinmean / hypot, cosmean / hypot);
|
|
|
|
|
} else {
|
|
|
|
|
mean = 0;
|
|
|
|
|
}
|
2023-12-19 15:47:53 -05:00
|
|
|
|
2023-12-28 12:40:50 -05:00
|
|
|
return Math.sqrt(values.map((x) => Math.pow(wrapToPi(x - mean), 2)).reduce((a, b) => a + b) / values.length);
|
2023-12-19 15:47:53 -05:00
|
|
|
};
|
|
|
|
|
const resetCurrentBuffer = () => {
|
|
|
|
|
// Need to clear the array in place
|
|
|
|
|
while (useStateStore().currentMultitagBuffer?.length != 0) useStateStore().currentMultitagBuffer?.pop();
|
|
|
|
|
};
|
2023-08-21 01:51:35 -04:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div>
|
2023-08-31 16:56:58 -04:00
|
|
|
<v-row align="start" class="pb-4" style="height: 300px">
|
2023-10-17 10:20:00 -04:00
|
|
|
<v-simple-table fixed-header dense dark>
|
2023-08-21 01:51:35 -04:00
|
|
|
<template #default>
|
2023-08-31 16:56:58 -04:00
|
|
|
<thead style="font-size: 1.25rem">
|
2023-08-21 01:51:35 -04:00
|
|
|
<tr>
|
|
|
|
|
<th
|
2023-08-31 16:56:58 -04:00
|
|
|
v-if="
|
|
|
|
|
useCameraSettingsStore().currentPipelineType === PipelineType.AprilTag ||
|
|
|
|
|
useCameraSettingsStore().currentPipelineType === PipelineType.Aruco
|
|
|
|
|
"
|
2023-08-21 01:51:35 -04:00
|
|
|
class="text-center"
|
|
|
|
|
>
|
|
|
|
|
Fiducial ID
|
|
|
|
|
</th>
|
|
|
|
|
<template v-if="!useCameraSettingsStore().currentPipelineSettings.solvePNPEnabled">
|
2023-08-31 16:56:58 -04:00
|
|
|
<th class="text-center">Pitch θ°</th>
|
|
|
|
|
<th class="text-center">Yaw θ°</th>
|
|
|
|
|
<th class="text-center">Skew θ°</th>
|
|
|
|
|
<th class="text-center">Area %</th>
|
2023-08-21 01:51:35 -04:00
|
|
|
</template>
|
|
|
|
|
<template v-else>
|
2023-08-31 16:56:58 -04:00
|
|
|
<th class="text-center">X meters</th>
|
|
|
|
|
<th class="text-center">Y meters</th>
|
|
|
|
|
<th class="text-center">Z Angle θ°</th>
|
2023-08-21 01:51:35 -04:00
|
|
|
</template>
|
2023-08-31 16:56:58 -04:00
|
|
|
<template
|
|
|
|
|
v-if="
|
2023-10-24 19:39:38 -07:00
|
|
|
(useCameraSettingsStore().currentPipelineType === PipelineType.AprilTag ||
|
|
|
|
|
useCameraSettingsStore().currentPipelineType === PipelineType.Aruco) &&
|
2023-08-31 16:56:58 -04:00
|
|
|
useCameraSettingsStore().currentPipelineSettings.solvePNPEnabled
|
|
|
|
|
"
|
|
|
|
|
>
|
2023-11-25 14:06:22 -05:00
|
|
|
<th class="text-center">Ambiguity Ratio</th>
|
2023-08-21 01:51:35 -04:00
|
|
|
</template>
|
|
|
|
|
</tr>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody>
|
2023-10-17 10:20:00 -04:00
|
|
|
<tr v-for="(target, index) in useStateStore().currentPipelineResults?.targets" :key="index">
|
2023-08-31 16:56:58 -04:00
|
|
|
<td
|
|
|
|
|
v-if="
|
|
|
|
|
useCameraSettingsStore().currentPipelineType === PipelineType.AprilTag ||
|
|
|
|
|
useCameraSettingsStore().currentPipelineType === PipelineType.Aruco
|
|
|
|
|
"
|
|
|
|
|
>
|
2023-08-21 01:51:35 -04:00
|
|
|
{{ target.fiducialId }}
|
|
|
|
|
</td>
|
|
|
|
|
<template v-if="!useCameraSettingsStore().currentPipelineSettings.solvePNPEnabled">
|
|
|
|
|
<td>{{ target.pitch.toFixed(2) }}°</td>
|
|
|
|
|
<td>{{ target.yaw.toFixed(2) }}°</td>
|
|
|
|
|
<td>{{ target.skew.toFixed(2) }}°</td>
|
|
|
|
|
<td>{{ target.area.toFixed(2) }}°</td>
|
|
|
|
|
</template>
|
2023-10-21 11:09:55 -04:00
|
|
|
<template v-else>
|
2023-08-21 01:51:35 -04:00
|
|
|
<td>{{ target.pose?.x.toFixed(2) }} m</td>
|
|
|
|
|
<td>{{ target.pose?.y.toFixed(2) }} m</td>
|
2023-10-17 10:20:00 -04:00
|
|
|
<td>{{ (((target.pose?.angle_z || 0) * 180.0) / Math.PI).toFixed(2) }}°</td>
|
2023-08-21 01:51:35 -04:00
|
|
|
</template>
|
2023-08-31 16:56:58 -04:00
|
|
|
<template
|
|
|
|
|
v-if="
|
2023-10-24 19:39:38 -07:00
|
|
|
(useCameraSettingsStore().currentPipelineType === PipelineType.AprilTag ||
|
|
|
|
|
useCameraSettingsStore().currentPipelineType === PipelineType.Aruco) &&
|
2023-08-31 16:56:58 -04:00
|
|
|
useCameraSettingsStore().currentPipelineSettings.solvePNPEnabled
|
|
|
|
|
"
|
|
|
|
|
>
|
2023-11-27 23:43:57 -05:00
|
|
|
<td>{{ target.ambiguity >= 0 ? target.ambiguity.toFixed(2) : "(In Multi-Target)" }}</td>
|
2023-08-21 01:51:35 -04:00
|
|
|
</template>
|
|
|
|
|
</tr>
|
|
|
|
|
</tbody>
|
|
|
|
|
</template>
|
|
|
|
|
</v-simple-table>
|
|
|
|
|
</v-row>
|
2023-12-19 15:47:53 -05:00
|
|
|
<v-container
|
2023-10-17 10:20:00 -04:00
|
|
|
v-if="
|
2023-10-24 19:39:38 -07:00
|
|
|
(useCameraSettingsStore().currentPipelineType === PipelineType.AprilTag ||
|
|
|
|
|
useCameraSettingsStore().currentPipelineType === PipelineType.Aruco) &&
|
2023-12-19 15:47:53 -05:00
|
|
|
useCameraSettingsStore().currentPipelineSettings.doMultiTarget &&
|
2023-10-21 11:09:55 -04:00
|
|
|
useCameraSettingsStore().isCurrentVideoFormatCalibrated &&
|
|
|
|
|
useCameraSettingsStore().currentPipelineSettings.solvePNPEnabled
|
2023-10-17 10:20:00 -04:00
|
|
|
"
|
|
|
|
|
>
|
2023-12-19 15:47:53 -05:00
|
|
|
<v-row class="pb-4 white--text">
|
|
|
|
|
<v-card-subtitle class="ma-0 pa-0 pb-4" style="font-size: 16px"
|
|
|
|
|
>Multi-tag pose, field-to-camera</v-card-subtitle
|
|
|
|
|
>
|
|
|
|
|
<v-simple-table fixed-header height="100%" dense dark>
|
|
|
|
|
<thead style="font-size: 1.25rem">
|
|
|
|
|
<th class="text-center">X meters</th>
|
|
|
|
|
<th class="text-center">Y meters</th>
|
|
|
|
|
<th class="text-center">Z meters</th>
|
|
|
|
|
<th class="text-center">X Angle θ°</th>
|
|
|
|
|
<th class="text-center">Y Angle θ°</th>
|
|
|
|
|
<th class="text-center">Z Angle θ°</th>
|
|
|
|
|
<th class="text-center">Tags</th>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody v-show="useStateStore().currentPipelineResults?.multitagResult">
|
|
|
|
|
<td>{{ useStateStore().currentPipelineResults?.multitagResult?.bestTransform.x.toFixed(2) }} m</td>
|
|
|
|
|
<td>{{ useStateStore().currentPipelineResults?.multitagResult?.bestTransform.y.toFixed(2) }} m</td>
|
|
|
|
|
<td>{{ useStateStore().currentPipelineResults?.multitagResult?.bestTransform.z.toFixed(2) }} m</td>
|
|
|
|
|
<td>
|
|
|
|
|
{{
|
|
|
|
|
(
|
2023-12-28 12:40:50 -05:00
|
|
|
(useStateStore().currentPipelineResults?.multitagResult?.bestTransform.angle_x || 0) *
|
2023-12-19 15:47:53 -05:00
|
|
|
(180.0 / Math.PI)
|
|
|
|
|
).toFixed(2)
|
|
|
|
|
}}°
|
|
|
|
|
</td>
|
|
|
|
|
<td>
|
|
|
|
|
{{
|
|
|
|
|
(
|
2023-12-28 12:40:50 -05:00
|
|
|
(useStateStore().currentPipelineResults?.multitagResult?.bestTransform.angle_y || 0) *
|
2023-12-19 15:47:53 -05:00
|
|
|
(180.0 / Math.PI)
|
|
|
|
|
).toFixed(2)
|
|
|
|
|
}}°
|
|
|
|
|
</td>
|
|
|
|
|
<td>
|
|
|
|
|
{{
|
|
|
|
|
(
|
2023-12-28 12:40:50 -05:00
|
|
|
(useStateStore().currentPipelineResults?.multitagResult?.bestTransform.angle_z || 0) *
|
2023-12-19 15:47:53 -05:00
|
|
|
(180.0 / Math.PI)
|
|
|
|
|
).toFixed(2)
|
|
|
|
|
}}°
|
|
|
|
|
</td>
|
|
|
|
|
<td>{{ useStateStore().currentPipelineResults?.multitagResult?.fiducialIDsUsed }}</td>
|
|
|
|
|
</tbody>
|
|
|
|
|
</v-simple-table>
|
|
|
|
|
</v-row>
|
|
|
|
|
<v-row class="pb-4 white--text" style="display: flex; flex-direction: column">
|
|
|
|
|
<v-card-subtitle class="ma-0 pa-0 pb-4 pr-4" style="font-size: 16px"
|
2023-12-28 12:40:50 -05:00
|
|
|
>Multi-tag pose standard deviation over the last
|
|
|
|
|
{{ useStateStore().currentMultitagBuffer?.length || "NaN" }}/100 samples
|
2023-12-19 15:47:53 -05:00
|
|
|
</v-card-subtitle>
|
|
|
|
|
<v-btn color="secondary" class="mb-4 mt-1" style="width: min-content" depressed @click="resetCurrentBuffer"
|
|
|
|
|
>Reset Samples</v-btn
|
|
|
|
|
>
|
|
|
|
|
<v-simple-table fixed-header height="100%" dense dark>
|
|
|
|
|
<thead style="font-size: 1.25rem">
|
|
|
|
|
<th class="text-center">X meters</th>
|
|
|
|
|
<th class="text-center">Y meters</th>
|
|
|
|
|
<th class="text-center">Z meters</th>
|
|
|
|
|
<th class="text-center">X Angle θ°</th>
|
|
|
|
|
<th class="text-center">Y Angle θ°</th>
|
|
|
|
|
<th class="text-center">Z Angle θ°</th>
|
|
|
|
|
</thead>
|
|
|
|
|
<tbody v-show="useStateStore().currentPipelineResults?.multitagResult">
|
|
|
|
|
<td>
|
|
|
|
|
{{
|
2023-12-28 12:40:50 -05:00
|
|
|
calculateStdDev(useStateStore().currentMultitagBuffer?.map((v) => v.bestTransform.x) || []).toFixed(5)
|
2023-12-19 15:47:53 -05:00
|
|
|
}} m
|
|
|
|
|
</td>
|
|
|
|
|
<td>
|
|
|
|
|
{{
|
2023-12-28 12:40:50 -05:00
|
|
|
calculateStdDev(useStateStore().currentMultitagBuffer?.map((v) => v.bestTransform.y) || []).toFixed(5)
|
2023-12-19 15:47:53 -05:00
|
|
|
}} m
|
|
|
|
|
</td>
|
|
|
|
|
<td>
|
|
|
|
|
{{
|
2023-12-28 12:40:50 -05:00
|
|
|
calculateStdDev(useStateStore().currentMultitagBuffer?.map((v) => v.bestTransform.z) || []).toFixed(5)
|
2023-12-19 15:47:53 -05:00
|
|
|
}} m
|
|
|
|
|
</td>
|
|
|
|
|
<td>
|
|
|
|
|
{{
|
|
|
|
|
calculateStdDev(
|
2023-12-28 12:40:50 -05:00
|
|
|
useStateStore().currentMultitagBuffer?.map((v) => v.bestTransform.angle_x * (180.0 / Math.PI)) || []
|
2023-12-19 15:47:53 -05:00
|
|
|
).toFixed(5)
|
|
|
|
|
}}°
|
|
|
|
|
</td>
|
|
|
|
|
<td>
|
|
|
|
|
{{
|
|
|
|
|
calculateStdDev(
|
2023-12-28 12:40:50 -05:00
|
|
|
useStateStore().currentMultitagBuffer?.map((v) => v.bestTransform.angle_y * (180.0 / Math.PI)) || []
|
2023-12-19 15:47:53 -05:00
|
|
|
).toFixed(5)
|
|
|
|
|
}}°
|
|
|
|
|
</td>
|
|
|
|
|
<td>
|
|
|
|
|
{{
|
|
|
|
|
calculateStdDev(
|
2023-12-28 12:40:50 -05:00
|
|
|
useStateStore().currentMultitagBuffer?.map((v) => v.bestTransform.angle_z * (180.0 / Math.PI)) || []
|
2023-12-19 15:47:53 -05:00
|
|
|
).toFixed(5)
|
|
|
|
|
}}°
|
|
|
|
|
</td>
|
|
|
|
|
</tbody>
|
|
|
|
|
</v-simple-table>
|
|
|
|
|
</v-row>
|
|
|
|
|
</v-container>
|
2023-08-21 01:51:35 -04:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
.v-data-table {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
text-align: center;
|
|
|
|
|
background-color: #006492 !important;
|
|
|
|
|
|
2023-08-31 16:56:58 -04:00
|
|
|
th,
|
|
|
|
|
td {
|
2023-08-21 01:51:35 -04:00
|
|
|
background-color: #006492 !important;
|
|
|
|
|
font-size: 1rem !important;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
td {
|
|
|
|
|
font-family: monospace !important;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
tbody :hover td {
|
|
|
|
|
background-color: #005281 !important;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::-webkit-scrollbar {
|
|
|
|
|
width: 0;
|
|
|
|
|
height: 0.55em;
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::-webkit-scrollbar-track {
|
|
|
|
|
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::-webkit-scrollbar-thumb {
|
|
|
|
|
background-color: #ffd843;
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|