From 37553ea889c3160c89095b6d2579c42f736ca669 Mon Sep 17 00:00:00 2001 From: lucas lelievre Date: Wed, 28 May 2025 03:45:37 +0200 Subject: [PATCH] stay aligned fixes (#1447) --- gui/public/i18n/en/translation.ftl | 6 ++--- .../pages/stay-aligned/StayAlignedSetup.tsx | 4 +-- .../stay-aligned/stay-aligned-steps/Done.tsx | 2 +- .../stay-aligned-steps/PreparationStep.tsx | 2 +- .../stay-aligned-steps/PutTrackersOnStep.tsx | 2 +- .../stay-aligned-steps/RelaxedPoseSteps.tsx | 2 +- .../stay-aligned-steps/VerifyMounting.tsx | 3 ++- .../pages/components/StayAlignedSettings.tsx | 16 ++++++----- .../widgets/SkeletonVisualizerWidget.tsx | 27 ++++++++++++++++--- 9 files changed, 43 insertions(+), 21 deletions(-) diff --git a/gui/public/i18n/en/translation.ftl b/gui/public/i18n/en/translation.ftl index 2e8ee6de1..9da7b0e22 100644 --- a/gui/public/i18n/en/translation.ftl +++ b/gui/public/i18n/en/translation.ftl @@ -1263,13 +1263,13 @@ onboarding-stay_aligned-preparation-title = Preparation onboarding-stay_aligned-preparation-tip = Make sure to stand upright. You must be looking forward and your arms must be down to your sides. onboarding-stay_aligned-relaxed_poses-standing-title = Relaxed Standing Pose onboarding-stay_aligned-relaxed_poses-standing-step-0 = 1. Stand in a comfortable position. Relax! -onboarding-stay_aligned-relaxed_poses-standing-step-2 = 3. Press the "Detect pose" button. +onboarding-stay_aligned-relaxed_poses-standing-step-2 = 3. Press the "Save pose" button. onboarding-stay_aligned-relaxed_poses-sitting-title = Relaxed Sitting in Chair Pose onboarding-stay_aligned-relaxed_poses-sitting-step-0 = 1. Sit in a comfortable position. Relax! -onboarding-stay_aligned-relaxed_poses-sitting-step-2 = 3. Press the "Detect pose" button. +onboarding-stay_aligned-relaxed_poses-sitting-step-2 = 3. Press the "Save pose" button. onboarding-stay_aligned-relaxed_poses-flat-title = Relaxed Sitting on Floor Pose onboarding-stay_aligned-relaxed_poses-flat-step-0 = 1. Sit on the floor with your legs in front. Relax! -onboarding-stay_aligned-relaxed_poses-flat-step-2 = 3. Press the "Detect pose" button. +onboarding-stay_aligned-relaxed_poses-flat-step-2 = 3. Press the "Save pose" button. onboarding-stay_aligned-relaxed_poses-skip_step = Skip onboarding-stay_aligned-done-title = Stay Aligned enabled! onboarding-stay_aligned-done-description = Your Stay Aligned setup is complete! diff --git a/gui/src/components/onboarding/pages/stay-aligned/StayAlignedSetup.tsx b/gui/src/components/onboarding/pages/stay-aligned/StayAlignedSetup.tsx index ff43af791..4297e3b3e 100644 --- a/gui/src/components/onboarding/pages/stay-aligned/StayAlignedSetup.tsx +++ b/gui/src/components/onboarding/pages/stay-aligned/StayAlignedSetup.tsx @@ -203,7 +203,7 @@ export function StayAlignedSetup() { position: new Vector3(3, 2.5, -3), onHeightChange(v, newHeight) { v.controls.target.set(0, newHeight / 2, 0); - const scale = Math.max(1.8, newHeight) / 1.8; + const scale = Math.max(1, newHeight) / 1.5; v.camera.zoom = 1 / scale; }, }); @@ -217,7 +217,7 @@ export function StayAlignedSetup() { position: new Vector3(3, 2.5, -3), onHeightChange(v, newHeight) { v.controls.target.set(0, newHeight / 2, 0); - const scale = Math.max(1.8, newHeight) / 1.8; + const scale = Math.max(1, newHeight) / 1.5; v.camera.zoom = 1 / scale; }, }); diff --git a/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/Done.tsx b/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/Done.tsx index d612603bc..87cad6b1b 100644 --- a/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/Done.tsx +++ b/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/Done.tsx @@ -5,7 +5,7 @@ import { Localized } from '@fluent/react'; export function DoneStep({ goTo }: VerticalStepComponentProps) { return ( -
+
diff --git a/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/PreparationStep.tsx b/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/PreparationStep.tsx index 66b1c52c4..a448abc74 100644 --- a/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/PreparationStep.tsx +++ b/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/PreparationStep.tsx @@ -13,7 +13,7 @@ export function PreparationStep({ prevStep, }: VerticalStepComponentProps) { return ( -
+
diff --git a/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/PutTrackersOnStep.tsx b/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/PutTrackersOnStep.tsx index 6ee645fa0..d63ef52de 100644 --- a/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/PutTrackersOnStep.tsx +++ b/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/PutTrackersOnStep.tsx @@ -14,7 +14,7 @@ export function PutTrackersOnStep({ nextStep }: VerticalStepComponentProps) { const canContinue = assignedTrackers.length >= 5 || import.meta.env.DEV; return ( -
+
diff --git a/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/RelaxedPoseSteps.tsx b/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/RelaxedPoseSteps.tsx index 205a707fa..ed9401df5 100644 --- a/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/RelaxedPoseSteps.tsx +++ b/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/RelaxedPoseSteps.tsx @@ -27,7 +27,7 @@ function PosePage({ const { l10n } = useLocalization(); const { sendRPCPacket } = useWebsocketAPI(); return ( -
+
{descriptionKeys.map((descriptionKey) => ( diff --git a/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/VerifyMounting.tsx b/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/VerifyMounting.tsx index 6e17f90b1..0541ca3f5 100644 --- a/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/VerifyMounting.tsx +++ b/gui/src/components/onboarding/pages/stay-aligned/stay-aligned-steps/VerifyMounting.tsx @@ -8,7 +8,7 @@ export function VerifyMountingStep({ prevStep, }: VerticalStepComponentProps) { return ( -
+
@@ -33,6 +33,7 @@ export function VerifyMountingStep({ diff --git a/gui/src/components/settings/pages/components/StayAlignedSettings.tsx b/gui/src/components/settings/pages/components/StayAlignedSettings.tsx index 0735fca56..66fde638a 100644 --- a/gui/src/components/settings/pages/components/StayAlignedSettings.tsx +++ b/gui/src/components/settings/pages/components/StayAlignedSettings.tsx @@ -112,13 +112,15 @@ Flat: ${config.flatEnabled ? `Enabled (upper_leg=${numberFormat.format(config.fl TRACKERS ======== -${trackers.map((t) => { - const info = t.tracker.info; - const stayAligned = t.tracker.stayAligned; - if (info && stayAligned) { - return `${bodypartToString(info.bodyPart)}: correction=${numberFormat.format(stayAligned.yawCorrectionInDeg)} locked=${stayAligned.locked ? `true locked_error=${numberFormat.format(stayAligned.lockedErrorInDeg)}` : 'false'} center_error=${numberFormat.format(stayAligned.centerErrorInDeg)} neighbor_error=${numberFormat.format(stayAligned.neighborErrorInDeg)}`; - } -})} +${trackers + .map((t) => { + const info = t.tracker.info; + const stayAligned = t.tracker.stayAligned; + if (info && stayAligned) { + return `${bodypartToString(info.bodyPart)}: correction=${numberFormat.format(stayAligned.yawCorrectionInDeg)} locked=${stayAligned.locked ? `true locked_error=${numberFormat.format(stayAligned.lockedErrorInDeg)}` : 'false'} center_error=${numberFormat.format(stayAligned.centerErrorInDeg)} neighbor_error=${numberFormat.format(stayAligned.neighborErrorInDeg)}`; + } + }) + .join('\n')} OTHER ===== diff --git a/gui/src/components/widgets/SkeletonVisualizerWidget.tsx b/gui/src/components/widgets/SkeletonVisualizerWidget.tsx index 3f65065c7..7d1b6ee98 100644 --- a/gui/src/components/widgets/SkeletonVisualizerWidget.tsx +++ b/gui/src/components/widgets/SkeletonVisualizerWidget.tsx @@ -130,6 +130,7 @@ function initializePreview( scene.add(skeleton[0]); let heightOffset = 0; + let skeletonOffset = 0; const rebuildSkeleton = ( newSkeleton: (BoneKind | THREE.Bone)[], @@ -168,7 +169,20 @@ function initializePreview( skeletonGroup.rotation.setFromQuaternion(yawReset); }; - const computeHeight = (bones: Map) => { + const computeUserHeight = (bones: Map) => { + const hmd = bones.get(BodyPart.HEAD); + if (hmd?.headPositionG?.y && hmd.headPositionG.y > 0) { + return hmd.headPositionG.y / 0.936; + } + const yLength = Y_PARTS.map((x) => bones.get(x)); + if (yLength.some((x) => x === undefined)) return 0; + return ( + (yLength as BoneT[]).reduce((prev, cur) => prev + cur.boneLength, 0) / + 0.936 + ); + }; + + const computeSkeletonOffset = (bones: Map) => { const hmd = bones.get(BodyPart.HEAD); // If I know the head position, don't use an offset if (hmd?.headPositionG?.y !== undefined && hmd.headPositionG?.y > 0) { @@ -246,14 +260,19 @@ function initializePreview( skeleton.forEach( (bone) => bone instanceof BoneKind && bone.updateData(bones) ); - const newHeight = computeHeight(bones); + const newHeight = computeUserHeight(bones); if (newHeight !== heightOffset) { heightOffset = newHeight; - skeletonGroup.position.set(0, heightOffset, 0); views.forEach((v) => { v.onHeightChange(v, heightOffset); }); } + + const newSkeletinOffset = computeSkeletonOffset(bones); + if (newSkeletinOffset != skeletonOffset) { + skeletonOffset = newSkeletinOffset; + skeletonGroup.position.set(0, skeletonOffset, 0); + } }, destroy: () => { skeletonHelper.dispose(); @@ -419,7 +438,7 @@ export function SkeletonVisualizerWidget({ position: new THREE.Vector3(3, 2.5, -3), onHeightChange(v, newHeight) { v.controls.target.set(0, newHeight / 2, 0); - const scale = Math.max(1.8, newHeight) / 1.8; + const scale = Math.max(1, newHeight) / 1.5; v.camera.zoom = 1 / scale; }, });