mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-21 17:41:28 -08:00
Individual Pose calibration for stay aligned (#1452)
This commit is contained in:
1 parent
4ae5fb7215
commit
89ec689a46
3 files changed
+289
-93
No files matched your search
@@ -557,6 +557,7 @@ settings-stay_aligned-relaxed_poses-sitting = Adjust trackers while sitting in a
|
||||
settings-stay_aligned-relaxed_poses-flat = Adjust trackers while sitting on the floor, or lying on your back
|
||||
settings-stay_aligned-relaxed_poses-save_pose = Save pose
|
||||
settings-stay_aligned-relaxed_poses-reset_pose = Reset pose
|
||||
settings-stay_aligned-relaxed_poses-close = Close
|
||||
settings-stay_aligned-debug-label = Debugging
|
||||
settings-stay_aligned-debug-description = Please include your settings when reporting problems about Stay Aligned.
|
||||
settings-stay_aligned-debug-copy-label = Copy settings to clipboard
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
import { BaseModal } from '@/components/commons/BaseModal';
|
||||
import { Button } from '@/components/commons/Button';
|
||||
import { Typography } from '@/components/commons/Typography';
|
||||
import {
|
||||
DetectRelaxedPoseButton,
|
||||
ResetRelaxedPoseButton,
|
||||
} from '@/components/stay-aligned/RelaxedPose';
|
||||
import { useLocalization } from '@fluent/react';
|
||||
import { Dispatch, ReactNode, SetStateAction } from 'react';
|
||||
import { StayAlignedRelaxedPose } from 'solarxr-protocol';
|
||||
|
||||
function StaAlignedPoseModal({
|
||||
open,
|
||||
title,
|
||||
descriptionKeys,
|
||||
children,
|
||||
relaxedPose,
|
||||
}: {
|
||||
open: [boolean, Dispatch<SetStateAction<boolean>>];
|
||||
title: string;
|
||||
descriptionKeys: string[];
|
||||
children: ReactNode;
|
||||
relaxedPose: StayAlignedRelaxedPose;
|
||||
lastStep?: boolean;
|
||||
}) {
|
||||
const { l10n } = useLocalization();
|
||||
|
||||
return (
|
||||
<BaseModal
|
||||
isOpen={open[0]}
|
||||
appendClasses={'w-xl max-w-xl mobile:w-full'}
|
||||
closeable
|
||||
onRequestClose={() => {
|
||||
open[1](false);
|
||||
}}
|
||||
>
|
||||
<div className="flex flex-col">
|
||||
<div className="pb-4">
|
||||
<Typography variant="main-title">{l10n.getString(title)}</Typography>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
{descriptionKeys.map((descriptionKey) => (
|
||||
<Typography color="secondary">
|
||||
{l10n.getString(descriptionKey)}
|
||||
</Typography>
|
||||
))}
|
||||
</div>
|
||||
<div className="flex pt-1 items-center fill-background-50 justify-center px-12">
|
||||
{children}
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<Button variant={'tertiary'} onClick={() => open[1](false)}>
|
||||
{l10n.getString('settings-stay_aligned-relaxed_poses-close')}
|
||||
</Button>
|
||||
<div className="flex gap-2">
|
||||
<ResetRelaxedPoseButton
|
||||
variant="tertiary"
|
||||
onClick={() => {
|
||||
open[1](false);
|
||||
}}
|
||||
pose={relaxedPose}
|
||||
>
|
||||
{l10n.getString('settings-stay_aligned-relaxed_poses-reset_pose')}
|
||||
</ResetRelaxedPoseButton>
|
||||
<DetectRelaxedPoseButton
|
||||
onClick={() => {
|
||||
open[1](false);
|
||||
}}
|
||||
pose={relaxedPose}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</BaseModal>
|
||||
);
|
||||
}
|
||||
|
||||
export const StandingRelaxedPoseModal = ({
|
||||
open,
|
||||
}: {
|
||||
open: [boolean, Dispatch<SetStateAction<boolean>>];
|
||||
}) => (
|
||||
<StaAlignedPoseModal
|
||||
open={open}
|
||||
title={'onboarding-stay_aligned-relaxed_poses-standing-title'}
|
||||
descriptionKeys={[
|
||||
'onboarding-stay_aligned-relaxed_poses-standing-step-0',
|
||||
'onboarding-stay_aligned-relaxed_poses-standing-step-2',
|
||||
]}
|
||||
relaxedPose={StayAlignedRelaxedPose.STANDING}
|
||||
>
|
||||
<img
|
||||
src={'/images/stay-aligned/StayAlignedStanding.webp'}
|
||||
width={260}
|
||||
alt="Reset position"
|
||||
/>
|
||||
</StaAlignedPoseModal>
|
||||
);
|
||||
|
||||
export const SittingRelaxedPoseModal = ({
|
||||
open,
|
||||
}: {
|
||||
open: [boolean, Dispatch<SetStateAction<boolean>>];
|
||||
}) => (
|
||||
<StaAlignedPoseModal
|
||||
open={open}
|
||||
title={'onboarding-stay_aligned-relaxed_poses-sitting-title'}
|
||||
descriptionKeys={[
|
||||
'onboarding-stay_aligned-relaxed_poses-sitting-step-0',
|
||||
'onboarding-stay_aligned-relaxed_poses-sitting-step-2',
|
||||
]}
|
||||
relaxedPose={StayAlignedRelaxedPose.SITTING}
|
||||
>
|
||||
<img
|
||||
src={'/images/stay-aligned/StayAlignedSitting.webp'}
|
||||
width={260}
|
||||
alt="Reset position"
|
||||
/>
|
||||
</StaAlignedPoseModal>
|
||||
);
|
||||
|
||||
export const FlatRelaxedPoseModal = ({
|
||||
open,
|
||||
}: {
|
||||
open: [boolean, Dispatch<SetStateAction<boolean>>];
|
||||
}) => (
|
||||
<StaAlignedPoseModal
|
||||
open={open}
|
||||
title={'onboarding-stay_aligned-relaxed_poses-flat-title'}
|
||||
descriptionKeys={[
|
||||
'onboarding-stay_aligned-relaxed_poses-flat-step-0',
|
||||
'onboarding-stay_aligned-relaxed_poses-flat-step-2',
|
||||
]}
|
||||
relaxedPose={StayAlignedRelaxedPose.FLAT}
|
||||
>
|
||||
<img
|
||||
src={'/images/stay-aligned/StayAlignedFloor.webp'}
|
||||
width={560}
|
||||
alt="Reset position"
|
||||
/>
|
||||
</StaAlignedPoseModal>
|
||||
);
|
||||
@@ -6,11 +6,17 @@ import { CheckBox } from '@/components/commons/Checkbox';
|
||||
import { WrenchIcon } from '@/components/commons/icon/WrenchIcons';
|
||||
import { Typography } from '@/components/commons/Typography';
|
||||
import { SettingsPagePaneLayout } from '@/components/settings/SettingsPageLayout';
|
||||
import { useLocalization } from '@fluent/react';
|
||||
import { Localized, useLocalization } from '@fluent/react';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { connectedIMUTrackersAtom } from '@/store/app-store';
|
||||
import { bodypartToString } from '@/utils/formatting';
|
||||
import { useLocaleConfig } from '@/i18n/config';
|
||||
import {
|
||||
FlatRelaxedPoseModal,
|
||||
SittingRelaxedPoseModal,
|
||||
StandingRelaxedPoseModal,
|
||||
} from './StayAlignedPoseModal';
|
||||
import { useState } from 'react';
|
||||
|
||||
export type StayAlignedSettingsForm = {
|
||||
enabled: boolean;
|
||||
@@ -165,106 +171,153 @@ export function StayAlignedSettings({
|
||||
config.flatLowerLegAngle !== 0.0 ||
|
||||
config.flatFootAngle !== 0.0;
|
||||
|
||||
const openStanding = useState(false);
|
||||
const openSitting = useState(false);
|
||||
const openFlat = useState(false);
|
||||
|
||||
return (
|
||||
<SettingsPagePaneLayout icon={<WrenchIcon />} id="stayaligned">
|
||||
<Typography variant="main-title">
|
||||
{l10n.getString('settings-stay_aligned')}
|
||||
</Typography>
|
||||
<div className="mt-2">
|
||||
<Typography color="secondary">
|
||||
{l10n.getString('settings-stay_aligned-description')}
|
||||
</Typography>
|
||||
<Typography color="secondary">
|
||||
{l10n.getString('settings-stay_aligned-setup-description')}
|
||||
</Typography>
|
||||
<div className="flex mt-2">
|
||||
<Button
|
||||
variant="primary"
|
||||
to="/onboarding/stay-aligned"
|
||||
state={{ alonePage: true }}
|
||||
>
|
||||
{l10n.getString('settings-stay_aligned-setup-label')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-6">
|
||||
<Typography bold>
|
||||
{l10n.getString('settings-stay_aligned-general-label')}
|
||||
</Typography>
|
||||
<div className="grid sm:grid-cols-2 gap-3 mt-2">
|
||||
<CheckBox
|
||||
variant="toggle"
|
||||
outlined
|
||||
control={control}
|
||||
name="stayAligned.enabled"
|
||||
label={l10n.getString('settings-stay_aligned-enabled-label')}
|
||||
disabled={!config.setupComplete}
|
||||
/>
|
||||
<CheckBox
|
||||
variant="toggle"
|
||||
outlined
|
||||
control={control}
|
||||
name="stayAligned.hideYawCorrection"
|
||||
label={l10n.getString(
|
||||
'settings-stay_aligned-hide_yaw_correction-label'
|
||||
)}
|
||||
disabled={!config.setupComplete}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-6">
|
||||
<Typography bold>
|
||||
{l10n.getString('settings-stay_aligned-relaxed_poses-label')}
|
||||
<>
|
||||
<SettingsPagePaneLayout icon={<WrenchIcon />} id="stayaligned">
|
||||
<Typography variant="main-title">
|
||||
{l10n.getString('settings-stay_aligned')}
|
||||
</Typography>
|
||||
<div className="mt-2">
|
||||
<Typography color="secondary">
|
||||
{l10n.getString('settings-stay_aligned-relaxed_poses-description')}
|
||||
{l10n.getString('settings-stay_aligned-description')}
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="grid sm:grid-cols-1 gap-3 mt-2">
|
||||
<CheckBox
|
||||
variant="toggle"
|
||||
outlined
|
||||
control={control}
|
||||
name="stayAligned.standingEnabled"
|
||||
label={l10n.getString(
|
||||
'settings-stay_aligned-relaxed_poses-standing'
|
||||
)}
|
||||
disabled={!config.setupComplete || !hasStandingPose}
|
||||
/>
|
||||
<CheckBox
|
||||
variant="toggle"
|
||||
outlined
|
||||
control={control}
|
||||
name="stayAligned.sittingEnabled"
|
||||
label={l10n.getString(
|
||||
'settings-stay_aligned-relaxed_poses-sitting'
|
||||
)}
|
||||
disabled={!config.setupComplete || !hasSittingPose}
|
||||
/>
|
||||
<CheckBox
|
||||
variant="toggle"
|
||||
outlined
|
||||
control={control}
|
||||
name="stayAligned.flatEnabled"
|
||||
label={l10n.getString('settings-stay_aligned-relaxed_poses-flat')}
|
||||
disabled={!config.setupComplete || !hasFlatPose}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-6">
|
||||
<Typography bold>
|
||||
{l10n.getString('settings-stay_aligned-debug-label')}
|
||||
</Typography>
|
||||
<div className="mt-2">
|
||||
<Typography color="secondary">
|
||||
{l10n.getString('settings-stay_aligned-debug-description')}
|
||||
{l10n.getString('settings-stay_aligned-setup-description')}
|
||||
</Typography>
|
||||
<div className="flex mt-2">
|
||||
<Button
|
||||
variant="primary"
|
||||
to="/onboarding/stay-aligned"
|
||||
state={{ alonePage: true }}
|
||||
>
|
||||
{l10n.getString('settings-stay_aligned-setup-label')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-2">
|
||||
<CopySettingsButton values={values} />
|
||||
<div className="mt-6">
|
||||
<Typography bold>
|
||||
{l10n.getString('settings-stay_aligned-general-label')}
|
||||
</Typography>
|
||||
<div className="grid sm:grid-cols-2 gap-3 mt-2">
|
||||
<CheckBox
|
||||
variant="toggle"
|
||||
outlined
|
||||
control={control}
|
||||
name="stayAligned.enabled"
|
||||
label={l10n.getString('settings-stay_aligned-enabled-label')}
|
||||
disabled={!config.setupComplete}
|
||||
/>
|
||||
<CheckBox
|
||||
variant="toggle"
|
||||
outlined
|
||||
control={control}
|
||||
name="stayAligned.hideYawCorrection"
|
||||
label={l10n.getString(
|
||||
'settings-stay_aligned-hide_yaw_correction-label'
|
||||
)}
|
||||
disabled={!config.setupComplete}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</SettingsPagePaneLayout>
|
||||
<div className="mt-6">
|
||||
<Typography bold>
|
||||
{l10n.getString('settings-stay_aligned-relaxed_poses-label')}
|
||||
</Typography>
|
||||
<div className="mt-2">
|
||||
<Typography color="secondary">
|
||||
{l10n.getString(
|
||||
'settings-stay_aligned-relaxed_poses-description'
|
||||
)}
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="grid sm:grid-cols-1 gap-3 mt-2">
|
||||
<div className="flex gap-2">
|
||||
<CheckBox
|
||||
variant="toggle"
|
||||
outlined
|
||||
control={control}
|
||||
name="stayAligned.standingEnabled"
|
||||
label={l10n.getString(
|
||||
'settings-stay_aligned-relaxed_poses-standing'
|
||||
)}
|
||||
disabled={!config.setupComplete || !hasStandingPose}
|
||||
/>
|
||||
<StandingRelaxedPoseModal
|
||||
open={openStanding}
|
||||
></StandingRelaxedPoseModal>
|
||||
<Localized id="settings-stay_aligned-relaxed_poses-save_pose">
|
||||
<Button
|
||||
variant="primary"
|
||||
className="w-full max-w-32"
|
||||
disabled={!config.setupComplete}
|
||||
onClick={() => openStanding[1](true)}
|
||||
></Button>
|
||||
</Localized>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<CheckBox
|
||||
variant="toggle"
|
||||
outlined
|
||||
control={control}
|
||||
name="stayAligned.sittingEnabled"
|
||||
label={l10n.getString(
|
||||
'settings-stay_aligned-relaxed_poses-sitting'
|
||||
)}
|
||||
disabled={!config.setupComplete || !hasSittingPose}
|
||||
/>
|
||||
<SittingRelaxedPoseModal
|
||||
open={openSitting}
|
||||
></SittingRelaxedPoseModal>
|
||||
<Localized id="settings-stay_aligned-relaxed_poses-save_pose">
|
||||
<Button
|
||||
variant="primary"
|
||||
className="w-full max-w-32"
|
||||
disabled={!config.setupComplete}
|
||||
onClick={() => openSitting[1](true)}
|
||||
></Button>
|
||||
</Localized>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<CheckBox
|
||||
variant="toggle"
|
||||
outlined
|
||||
control={control}
|
||||
name="stayAligned.flatEnabled"
|
||||
label={l10n.getString(
|
||||
'settings-stay_aligned-relaxed_poses-flat'
|
||||
)}
|
||||
disabled={!config.setupComplete || !hasFlatPose}
|
||||
/>
|
||||
<FlatRelaxedPoseModal open={openFlat}></FlatRelaxedPoseModal>
|
||||
<Localized id="settings-stay_aligned-relaxed_poses-save_pose">
|
||||
<Button
|
||||
variant="primary"
|
||||
className="w-full max-w-32"
|
||||
disabled={!config.setupComplete}
|
||||
onClick={() => openFlat[1](true)}
|
||||
></Button>
|
||||
</Localized>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-6">
|
||||
<Typography bold>
|
||||
{l10n.getString('settings-stay_aligned-debug-label')}
|
||||
</Typography>
|
||||
<div className="mt-2">
|
||||
<Typography color="secondary">
|
||||
{l10n.getString('settings-stay_aligned-debug-description')}
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="mt-2">
|
||||
<CopySettingsButton values={values} />
|
||||
</div>
|
||||
</div>
|
||||
</SettingsPagePaneLayout>
|
||||
</>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user