Skip to content

Commit

Permalink
Fix rotation issues with showing ATFL
Browse files Browse the repository at this point in the history
  • Loading branch information
srimanachanta committed Oct 19, 2023
1 parent f9bbd0a commit b4a5816
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions photon-client/src/components/settings/ApriltagControlCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import { useSettingsStore } from "@/stores/settings/GeneralSettingsStore";
import { Euler, Quaternion as ThreeQuat } from "three";
import type { Quaternion } from "@/types/PhotonTrackingTypes";
const quatToEuler = (quat: Quaternion): Euler => {
const three_quat = new ThreeQuat(quat.X, quat.Y, quat.Z, quat.W);
return new Euler().setFromQuaternion(three_quat, "ZYX");
};
const quaternionToEuler = (rot_quat: Quaternion): {x: number, y: number, z: number} => {
const quat = new ThreeQuat(rot_quat.X, rot_quat.Y, rot_quat.Z, rot_quat.W);
const euler = new Euler().setFromQuaternion(quat, "ZYX");
// Convert from radians to degrees.
const degrees = (radians: number): number => radians * (180.0 / Math.PI);
return {
x: euler.x * (180.0 / Math.PI),
y: euler.y * (180.0 / Math.PI),
z: euler.z * (180.0 / Math.PI)
};
};
</script>

<template>
Expand All @@ -36,11 +39,11 @@ const degrees = (radians: number): number => radians * (180.0 / Math.PI);
<tbody>
<tr v-for="(tag, index) in useSettingsStore().currentFieldLayout.tags" :key="index">
<td>{{ tag.ID }}</td>
<td v-for="(val, idx) in Object.values(tag.pose.translation).slice(0, 3).map(degrees)" :key="idx">
<td v-for="(val, idx) in Object.values(tag.pose.translation)" :key="idx">
{{ val.toFixed(2) }}
</td>
<td
v-for="(val, idx) in Object.values(quatToEuler(tag.pose.rotation.quaternion)).slice(0, 3).map(degrees)"
v-for="(val, idx) in Object.values(quaternionToEuler(tag.pose.rotation.quaternion))"
:key="idx"
>
{{ val.toFixed(2) }}
Expand Down

0 comments on commit b4a5816

Please sign in to comment.