From e39e2248a42c724f50bb04294ecd5c6926f63b1a Mon Sep 17 00:00:00 2001 From: Ondrej Hruska <11602729+ZycaR@users.noreply.github.com> Date: Fri, 12 Jul 2024 14:34:20 +0200 Subject: [PATCH 1/4] Show the current selected direction on the manual mounting page --- .gitignore | 2 ++ .../pages/mounting/ManualMounting.tsx | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index aaa77a2856..34b9ef1c46 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,5 @@ build/ # Ignore Android local properties local.properties +/server/core/bin +/server/desktop/bin diff --git a/gui/src/components/onboarding/pages/mounting/ManualMounting.tsx b/gui/src/components/onboarding/pages/mounting/ManualMounting.tsx index 49b4709e83..e2c844d732 100644 --- a/gui/src/components/onboarding/pages/mounting/ManualMounting.tsx +++ b/gui/src/components/onboarding/pages/mounting/ManualMounting.tsx @@ -1,10 +1,13 @@ -import { useEffect, useMemo, useState } from 'react'; +import { useCallback, useEffect, useMemo, useState } from 'react'; import { AssignTrackerRequestT, BodyPart, RpcMessage } from 'solarxr-protocol'; import { FlatDeviceTracker } from '@/hooks/app'; import { useOnboarding } from '@/hooks/onboarding'; import { useTrackers } from '@/hooks/tracker'; import { useWebsocketAPI } from '@/hooks/websocket-api'; -import { MountingOrientationDegreesToQuatT } from '@/maths/quaternion'; +import { + MountingOrientationDegreesToQuatT, + QuaternionFromQuatT, +} from '@/maths/quaternion'; import { Button } from '@/components/commons/Button'; import { TipBox } from '@/components/commons/TipBox'; import { Typography } from '@/components/commons/Typography'; @@ -66,10 +69,20 @@ export function ManualMountingPage() { setSelectRole(BodyPart.NONE); }; + const getCurrRotation = useCallback( + (role: BodyPart) => { + const trackers = trackerPartGrouped[role] || []; + if (!trackers.length || role === BodyPart.NONE) return undefined; + return QuaternionFromQuatT(trackers[0].tracker.info?.mountingOrientation); + }, + [trackerPartGrouped] + ); + return ( <> setSelectRole(BodyPart.NONE)} onDirectionSelected={onDirectionSelected} From de01e3cf553b16b114dbdd2b6f02abf6e4f5ffec Mon Sep 17 00:00:00 2001 From: Ondrej Hruska <11602729+ZycaR@users.noreply.github.com> Date: Fri, 12 Jul 2024 14:35:43 +0200 Subject: [PATCH 2/4] revert ignore --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index 34b9ef1c46..aaa77a2856 100644 --- a/.gitignore +++ b/.gitignore @@ -41,5 +41,3 @@ build/ # Ignore Android local properties local.properties -/server/core/bin -/server/desktop/bin From 09f9a8cb7a70c2728c53928a533d9b31c73609b5 Mon Sep 17 00:00:00 2001 From: Ondrej Hruska <11602729+ZycaR@users.noreply.github.com> Date: Fri, 12 Jul 2024 15:17:30 +0200 Subject: [PATCH 3/4] add null check --- .../components/onboarding/pages/mounting/ManualMounting.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gui/src/components/onboarding/pages/mounting/ManualMounting.tsx b/gui/src/components/onboarding/pages/mounting/ManualMounting.tsx index e2c844d732..05f5db4f22 100644 --- a/gui/src/components/onboarding/pages/mounting/ManualMounting.tsx +++ b/gui/src/components/onboarding/pages/mounting/ManualMounting.tsx @@ -73,7 +73,10 @@ export function ManualMountingPage() { (role: BodyPart) => { const trackers = trackerPartGrouped[role] || []; if (!trackers.length || role === BodyPart.NONE) return undefined; - return QuaternionFromQuatT(trackers[0].tracker.info?.mountingOrientation); + const mountingOrientation = trackers[0].tracker.info?.mountingOrientation; + return mountingOrientation + ? QuaternionFromQuatT(mountingOrientation) + : undefined; }, [trackerPartGrouped] ); From a67358855dc7ed382f6b70517557503824364b67 Mon Sep 17 00:00:00 2001 From: Ondrej Hruska <11602729+ZycaR@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:32:01 +0200 Subject: [PATCH 4/4] Show tracker mounting orientation when all match. Show tracker mounting orientation on manual mounting page for specific body part only when all mounting orientations of all assigned trackers are the same! --- .../pages/mounting/ManualMounting.tsx | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/gui/src/components/onboarding/pages/mounting/ManualMounting.tsx b/gui/src/components/onboarding/pages/mounting/ManualMounting.tsx index 5efd558e0c..48bc007b9a 100644 --- a/gui/src/components/onboarding/pages/mounting/ManualMounting.tsx +++ b/gui/src/components/onboarding/pages/mounting/ManualMounting.tsx @@ -1,4 +1,4 @@ -import { useCallback, useEffect, useMemo, useState } from 'react'; +import { useCallback, useMemo, useState } from 'react'; import { AssignTrackerRequestT, BodyPart, RpcMessage } from 'solarxr-protocol'; import { FlatDeviceTracker } from '@/hooks/app'; import { useOnboarding } from '@/hooks/onboarding'; @@ -7,6 +7,7 @@ import { useWebsocketAPI } from '@/hooks/websocket-api'; import { MountingOrientationDegreesToQuatT, QuaternionFromQuatT, + similarQuaternions, } from '@/maths/quaternion'; import { Button } from '@/components/commons/Button'; import { TipBox } from '@/components/commons/TipBox'; @@ -67,12 +68,20 @@ export function ManualMountingPage() { const getCurrRotation = useCallback( (role: BodyPart) => { + if (role === BodyPart.NONE) return undefined; + const trackers = trackerPartGrouped[role] || []; - if (!trackers.length || role === BodyPart.NONE) return undefined; - const mountingOrientation = trackers[0].tracker.info?.mountingOrientation; - return mountingOrientation - ? QuaternionFromQuatT(mountingOrientation) - : undefined; + const [mountingOrientation, ...orientation] = trackers + .map((td) => td.tracker.info?.mountingOrientation) + .filter((orientation) => !!orientation) + .map((orientation) => QuaternionFromQuatT(orientation)); + + const identicalOrientations = + mountingOrientation !== undefined && + orientation.every((quat) => + similarQuaternions(quat, mountingOrientation) + ); + return identicalOrientations ? mountingOrientation : undefined; }, [trackerPartGrouped] );