mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-23 18:41:24 -08:00
Compare commits
42
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
028ef9d3a9 | ||
|
|
ea2b208f66 | ||
|
|
ffc8ac94e4 | ||
|
|
66c151200f | ||
|
|
3287f1ee7d | ||
|
|
8a857affbc | ||
|
|
690a8b5c6e | ||
|
|
255b8b2865 | ||
|
|
e27ec63985 | ||
|
|
9f8be6551c | ||
|
|
f09cd687c7 | ||
|
|
686499f8dd | ||
|
|
a3bcc61892 | ||
|
|
faf70c9a39 | ||
|
|
2aa8d3a056 | ||
|
|
23df46ca33 | ||
|
|
8407f52777 | ||
|
|
b44dcaa9c2 | ||
|
|
ff0d823aff | ||
|
|
2e8bfa5373 | ||
|
|
87940ddd03 | ||
|
|
6208979ce9 | ||
|
|
9a27fb1320 | ||
|
|
53129328d0 | ||
|
|
2d79c5a0e9 | ||
|
|
74f5a92ce1 | ||
|
|
146930279c | ||
|
|
0c33579858 | ||
|
|
c9783d097b | ||
|
|
d3eafb8d06 | ||
|
|
09d44b51d6 | ||
|
|
cf357e71f5 | ||
|
|
122efacc52 | ||
|
|
7f536528d0 | ||
|
|
3982249ebf | ||
|
|
388bea2e72 | ||
|
|
921a760817 | ||
|
|
55bcec4dda | ||
|
|
bb08e8dc6a | ||
|
|
a82f950eb6 | ||
|
|
e2dbaab8ba | ||
|
|
3611bb5cc7 |
No files matched your search
+1
-1
@@ -10,7 +10,7 @@
|
||||
/pnpm-workspace.yaml @loucass003
|
||||
|
||||
# loucass003 and Erimel responsible for i18n
|
||||
/gui/public/i18n/ @loucass003 @Erimelowo
|
||||
/gui/public/i18n/ @loucass003 @Erimelowo @ImSapphire
|
||||
/gui/src/i18n/ @loucass003 @Erimelowo
|
||||
/l10n.toml @loucass003 @Erimelowo
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ jobs:
|
||||
|
||||
- if: startsWith(matrix.os, 'windows')
|
||||
name: Upload a Build Artifact (Windows)
|
||||
uses: actions/upload-artifact@v5
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
# Artifact name
|
||||
name: ${{ format('SlimeVR-GUI-Windows-{0}', env.BUILD_ARCH) }}
|
||||
@@ -112,7 +112,7 @@ jobs:
|
||||
|
||||
- if: startsWith(matrix.os, 'ubuntu')
|
||||
name: Upload a Build Artifact (Linux)
|
||||
uses: actions/upload-artifact@v5
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
# Artifact name
|
||||
name: ${{ format('SlimeVR-GUI-Linux-{0}', env.BUILD_ARCH) }}
|
||||
@@ -121,7 +121,7 @@ jobs:
|
||||
|
||||
- if: matrix.os == 'macos-latest'
|
||||
name: Upload a Build Artifact (macOS)
|
||||
uses: actions/upload-artifact@v5
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
# Artifact name
|
||||
name: SlimeVR-GUI-macOS
|
||||
|
||||
@@ -20,7 +20,7 @@ jobs:
|
||||
run: |
|
||||
npx @slimevr/update-manifest-generator@latest
|
||||
|
||||
- uses: actions/upload-artifact@v5
|
||||
- uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: "update-manifest.json"
|
||||
path: ./update-manifest.json
|
||||
|
||||
@@ -68,7 +68,7 @@ jobs:
|
||||
run: ./gradlew :server:desktop:shadowJar
|
||||
|
||||
- name: Upload the Server JAR as a Build Artifact
|
||||
uses: actions/upload-artifact@v5
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
# Artifact name
|
||||
name: 'SlimeVR-Server' # optional, default is artifact
|
||||
@@ -127,7 +127,7 @@ jobs:
|
||||
ANDROID_KEY_PASSWD: ${{ secrets.ANDROID_KEY_PASSWD }}
|
||||
|
||||
- name: Upload the Android build artifact
|
||||
uses: actions/upload-artifact@v5
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
# Artifact name
|
||||
name: 'SlimeVR-Android' # optional, default is artifact
|
||||
@@ -158,7 +158,7 @@ jobs:
|
||||
ANDROID_KEY_PASSWD: ${{ secrets.ANDROID_GPLAY_KEY_PASSWD }}
|
||||
|
||||
- name: Upload the Google Play artifact
|
||||
uses: actions/upload-artifact@v5
|
||||
uses: actions/upload-artifact@v6
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
with:
|
||||
# Artifact name
|
||||
@@ -181,7 +181,7 @@ jobs:
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- uses: actions/download-artifact@v6
|
||||
- uses: actions/download-artifact@v7
|
||||
with:
|
||||
name: 'SlimeVR-Server'
|
||||
path: server/desktop/build/libs/
|
||||
@@ -230,23 +230,23 @@ jobs:
|
||||
run: |
|
||||
tar czf slimevr-gui-dist.tar.gz -C gui/dist/ .
|
||||
|
||||
- uses: actions/upload-artifact@v5
|
||||
- uses: actions/upload-artifact@v6
|
||||
if: matrix.os == 'ubuntu-latest'
|
||||
with:
|
||||
name: SlimeVR-GUI-Dist
|
||||
path: ./slimevr-gui-dist.tar.gz
|
||||
|
||||
- uses: actions/upload-artifact@v5
|
||||
- uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: ${{ format('SlimeVR-GUI-Deb-{0}', env.BUILD_ARCH) }}
|
||||
path: target/release/bundle/deb/slimevr*.deb
|
||||
|
||||
- uses: actions/upload-artifact@v5
|
||||
- uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: ${{ format('SlimeVR-GUI-AppImage-{0}', env.BUILD_ARCH) }}
|
||||
path: target/release/bundle/appimage/slimevr*.AppImage
|
||||
|
||||
- uses: actions/upload-artifact@v5
|
||||
- uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: ${{ format('SlimeVR-GUI-RPM-{0}', env.BUILD_ARCH) }}
|
||||
path: target/release/bundle/rpm/slimevr*.rpm
|
||||
@@ -279,7 +279,7 @@ jobs:
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- uses: actions/download-artifact@v6
|
||||
- uses: actions/download-artifact@v7
|
||||
with:
|
||||
name: 'SlimeVR-Server'
|
||||
path: server/desktop/build/libs/
|
||||
@@ -320,12 +320,12 @@ jobs:
|
||||
--volicon ../macos/SlimeVR.app/Contents/Resources/icon.icns --skip-jenkins \
|
||||
--eula ../../../../../LICENSE-MIT slimevr.dmg ../macos/SlimeVR.app
|
||||
|
||||
- uses: actions/upload-artifact@v5
|
||||
- uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: SlimeVR-GUI-MacApp
|
||||
path: target/universal-apple-darwin/release/bundle/macos/SlimeVR*.app
|
||||
|
||||
- uses: actions/upload-artifact@v5
|
||||
- uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: SlimeVR-GUI-MacDmg
|
||||
path: target/universal-apple-darwin/release/bundle/dmg/slimevr.dmg
|
||||
@@ -359,7 +359,7 @@ jobs:
|
||||
with:
|
||||
submodules: recursive
|
||||
|
||||
- uses: actions/download-artifact@v6
|
||||
- uses: actions/download-artifact@v7
|
||||
with:
|
||||
name: 'SlimeVR-Server'
|
||||
path: server/desktop/build/libs/
|
||||
@@ -399,7 +399,7 @@ jobs:
|
||||
cp target/release/slimevr.exe ./SlimeVR/
|
||||
7z a -tzip "SlimeVR-$BUILD_ARCH.zip" ./SlimeVR/
|
||||
|
||||
- uses: actions/upload-artifact@v5
|
||||
- uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: ${{ format('SlimeVR-GUI-Windows-{0}', env.BUILD_ARCH) }}
|
||||
path: ./SlimeVR*.zip
|
||||
|
||||
@@ -109,6 +109,11 @@ board_type-XIAO_ESP32C3 = Seeed Studio XIAO ESP32C3
|
||||
board_type-HARITORA = Haritora
|
||||
board_type-ESP32C6DEVKITC1 = Espressif ESP32-C6 DevKitC-1
|
||||
board_type-GLOVE_IMU_SLIMEVR_DEV = SlimeVR Dev IMU Glove
|
||||
board_type-GESTURES = Gestures
|
||||
board_type-ESP32S3_SUPERMINI = ESP32-S3 Supermini
|
||||
board_type-GENERIC_NRF = Generic nRF
|
||||
board_type-SLIMEVR_BUTTERFLY_DEV = SlimeVR Dev Butterfly
|
||||
board_type-SLIMEVR_BUTTERFLY = SlimeVR Butterfly
|
||||
|
||||
## Proportions
|
||||
skeleton_bone-NONE = None
|
||||
@@ -287,9 +292,6 @@ widget-overlay = Overlay
|
||||
widget-overlay-is_visible_label = Show Overlay in SteamVR
|
||||
widget-overlay-is_mirrored_label = Display Overlay as Mirror
|
||||
|
||||
## Widget: Drift compensation
|
||||
widget-drift_compensation-clear = Clear drift compensation
|
||||
|
||||
## Widget: Clear Mounting calibration
|
||||
widget-clear_mounting = Clear mounting calibration
|
||||
|
||||
@@ -379,9 +381,6 @@ tracker-settings-assignment_section-edit = Edit assignment
|
||||
tracker-settings-mounting_section = Mounting orientation
|
||||
tracker-settings-mounting_section-description = Where is the tracker mounted?
|
||||
tracker-settings-mounting_section-edit = Edit mounting
|
||||
tracker-settings-drift_compensation_section = Allow drift compensation
|
||||
tracker-settings-drift_compensation_section-description = Should this tracker compensate for its drift when drift compensation is enabled?
|
||||
tracker-settings-drift_compensation_section-edit = Allow drift compensation
|
||||
tracker-settings-use_mag = Allow magnetometer on this tracker
|
||||
# Multiline!
|
||||
tracker-settings-use_mag-description =
|
||||
@@ -407,6 +406,7 @@ tracker-settings-update = Update now
|
||||
tracker-settings-update-title = Firmware version
|
||||
tracker-settings-current-version = Current
|
||||
tracker-settings-latest-version = Latest
|
||||
tracker-settings-build-date = Build Date
|
||||
|
||||
|
||||
## Tracker part card info
|
||||
@@ -534,29 +534,6 @@ settings-general-tracker_mechanics-filtering-type-prediction = Prediction
|
||||
settings-general-tracker_mechanics-filtering-type-prediction-description = Reduces latency and makes movements more snappy, but may increase jitter.
|
||||
settings-general-tracker_mechanics-filtering-amount = Amount
|
||||
settings-general-tracker_mechanics-yaw-reset-smooth-time = Yaw reset smooth time (0s disables smoothing)
|
||||
settings-general-tracker_mechanics-drift_compensation = Drift compensation
|
||||
# This cares about multilines
|
||||
settings-general-tracker_mechanics-drift_compensation-description =
|
||||
Compensates for IMU yaw drift by applying an inverse rotation.
|
||||
Change the amount of compensation and the number of resets taken into account.
|
||||
This should only be used if you need to reset very often!
|
||||
settings-general-tracker_mechanics-drift_compensation-enabled-label = Drift compensation
|
||||
settings-general-tracker_mechanics-drift_compensation-prediction = Drift compensation prediction
|
||||
# This cares about multilines
|
||||
settings-general-tracker_mechanics-drift_compensation-prediction-description =
|
||||
Predicts yaw drift compensation beyond previously measured range.
|
||||
Enable this if your trackers are continuously spinning on the yaw axis.
|
||||
settings-general-tracker_mechanics-drift_compensation-prediction-label = Drift compensation prediction
|
||||
settings-general-tracker_mechanics-drift_compensation_warning =
|
||||
<b>Warning:</b> Only use drift compensation if you need to reset
|
||||
very often (every ~5-10 minutes).
|
||||
|
||||
Some IMUs prone to frequent resets include:
|
||||
Joy-Cons, owoTrack, and MPUs (without recent firmware).
|
||||
settings-general-tracker_mechanics-drift_compensation_warning-cancel = Cancel
|
||||
settings-general-tracker_mechanics-drift_compensation_warning-done = I understand
|
||||
settings-general-tracker_mechanics-drift_compensation-amount-label = Compensation amount
|
||||
settings-general-tracker_mechanics-drift_compensation-max_resets-label = Use up to x last resets
|
||||
settings-general-tracker_mechanics-save_mounting_reset = Save automatic mounting calibration
|
||||
settings-general-tracker_mechanics-save_mounting_reset-description =
|
||||
Saves the automatic mounting calibration for the trackers between restarts. Useful
|
||||
@@ -567,12 +544,15 @@ settings-general-tracker_mechanics-use_mag_on_all_trackers-description =
|
||||
Uses magnetometer on all trackers that have a compatible firmware for it, reducing drift in stable magnetic environments.
|
||||
Can be disabled per tracker in the tracker's settings. <b>Please don't shutdown any of the trackers while toggling this!</b>
|
||||
settings-general-tracker_mechanics-use_mag_on_all_trackers-label = Use magnetometer on trackers
|
||||
settings-general-tracker_mechanics-trackers_over_usb = Trackers over USB
|
||||
settings-general-tracker_mechanics-trackers_over_usb-description =
|
||||
Enables receiving HID tracker data over USB. Make sure connected trackers have <b>connection over HID</b> enabled!
|
||||
settings-general-tracker_mechanics-trackers_over_usb-enabled-label = Allow HID trackers to connect directly over USB
|
||||
|
||||
settings-stay_aligned = Stay Aligned
|
||||
settings-stay_aligned-description = Stay Aligned reduces drift by gradually adjusting your trackers to match your relaxed poses.
|
||||
settings-stay_aligned-setup-label = Setup Stay Aligned
|
||||
settings-stay_aligned-setup-description = You must complete "Setup Stay Aligned" to enable Stay Aligned.
|
||||
settings-stay_aligned-warnings-drift_compensation = ⚠ Please turn off Drift Compensation! Drift Compensation will conflict with Stay Aligned.
|
||||
settings-stay_aligned-enabled-label = Adjust trackers
|
||||
settings-stay_aligned-hide_yaw_correction-label = Hide adjustment (to compare with no Stay Aligned)
|
||||
settings-stay_aligned-general-label = General
|
||||
@@ -1342,6 +1322,7 @@ onboarding-stay_aligned-previous_step = Previous
|
||||
onboarding-stay_aligned-next_step = Next
|
||||
onboarding-stay_aligned-restart = Restart
|
||||
onboarding-stay_aligned-done = Done
|
||||
onboarding-stay_aligned-manual_mounting-done = Done
|
||||
|
||||
## Home
|
||||
home-no_trackers = No trackers detected or assigned
|
||||
@@ -1393,6 +1374,9 @@ firmware_tool-select_source-firmware = Firmware Source
|
||||
firmware_tool-select_source-version = Firmware Version
|
||||
firmware_tool-select_source-official = Official
|
||||
firmware_tool-select_source-dev = Dev
|
||||
firmware_tool-select_source-not_selected = No source selected
|
||||
firmware_tool-select_source-no_boards = No available boards for this source
|
||||
firmware_tool-select_source-no_versions = No available versions for this source
|
||||
|
||||
firmware_tool-board_defaults = Configure your board
|
||||
firmware_tool-board_defaults-description = Set the pins or settings relative to your hardware
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -156,9 +156,9 @@ export function TopBar({
|
||||
<>
|
||||
<div className="flex gap-0 flex-col">
|
||||
<div className="h-[3px]" />
|
||||
<div data-tauri-drag-region className="flex gap-2 h-[38px] z-50">
|
||||
<div data-tauri-drag-region className="flex gap-2 h-[38px] z-49">
|
||||
<div
|
||||
className="flex px-2 py-2 justify-around z-50"
|
||||
className="flex px-2 py-2 justify-around z-49"
|
||||
data-tauri-drag-region
|
||||
>
|
||||
<div className="flex gap-2" data-tauri-drag-region>
|
||||
|
||||
@@ -10,7 +10,7 @@ export function TipBox({
|
||||
whitespace = false,
|
||||
className,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
children?: ReactNode;
|
||||
hideIcon?: boolean;
|
||||
whitespace?: boolean;
|
||||
className?: string;
|
||||
|
||||
@@ -101,13 +101,10 @@ export function SelectSourceSetep({
|
||||
curr.push({
|
||||
name: source.source,
|
||||
official: source.official,
|
||||
disabled:
|
||||
!partialBoard?.board ||
|
||||
!source.availableBoards.includes(partialBoard.board),
|
||||
});
|
||||
return curr;
|
||||
},
|
||||
[] as { name: string; official: boolean; disabled: boolean }[]
|
||||
[] as { name: string; official: boolean }[]
|
||||
)
|
||||
.sort((a, b) => {
|
||||
if (a.official !== b.official) return a.official ? -1 : 1;
|
||||
@@ -115,6 +112,7 @@ export function SelectSourceSetep({
|
||||
}),
|
||||
possibleBoards: sources
|
||||
?.reduce((curr, source) => {
|
||||
if (source.source !== partialBoard?.source) return curr;
|
||||
const unknownBoards = source.availableBoards.filter(
|
||||
(b) => !curr.includes(b)
|
||||
);
|
||||
@@ -136,6 +134,7 @@ export function SelectSourceSetep({
|
||||
possibleVersions: sources
|
||||
?.reduce(
|
||||
(curr, source) => {
|
||||
if (source.source !== partialBoard?.source) return curr;
|
||||
if (!curr.find(({ name }) => source.version === name))
|
||||
curr.push({
|
||||
disabled:
|
||||
@@ -193,6 +192,25 @@ export function SelectSourceSetep({
|
||||
{!isFetching && !isError && (
|
||||
<div className="flex flex-col gap-2">
|
||||
<div className="grid md:grid-cols-3 gap-4">
|
||||
<div className="flex flex-col gap-1 w-full">
|
||||
<Localized id="firmware_tool-select_source-firmware">
|
||||
<Typography variant="section-title" />
|
||||
</Localized>
|
||||
<div className="flex flex-col gap-4 md:max-h-[305px] overflow-y-auto bg-background-80 rounded-lg p-4">
|
||||
{sourcesGroupped?.map(({ name, official }) => (
|
||||
<Selector
|
||||
active={partialBoard?.source === name}
|
||||
key={`${name}`}
|
||||
tag={official ? 'official' : undefined}
|
||||
onClick={() => {
|
||||
if (partialBoard?.source !== name)
|
||||
setPartialBoard({ source: name });
|
||||
}}
|
||||
text={formatSource(name, official)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1 w-full">
|
||||
<Localized id="firmware_tool-select_source-board_type">
|
||||
<Typography variant="section-title" />
|
||||
@@ -203,7 +221,7 @@ export function SelectSourceSetep({
|
||||
active={partialBoard?.board === board}
|
||||
key={`${board}`}
|
||||
onClick={() => {
|
||||
setPartialBoard({ board });
|
||||
setPartialBoard((curr) => ({ ...curr, board }));
|
||||
}}
|
||||
tag={
|
||||
board.startsWith('BOARD_SLIMEVR')
|
||||
@@ -219,30 +237,15 @@ export function SelectSourceSetep({
|
||||
}
|
||||
/>
|
||||
))}
|
||||
{partialBoard?.source && possibleBoards?.length === 0 && (
|
||||
<Typography id="firmware_tool-select_source-no_boards" />
|
||||
)}
|
||||
{!partialBoard?.source && (
|
||||
<Typography id="firmware_tool-select_source-not_selected" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1 w-full">
|
||||
<Localized id="firmware_tool-select_source-firmware">
|
||||
<Typography variant="section-title" />
|
||||
</Localized>
|
||||
<div className="flex flex-col gap-4 md:max-h-[305px] overflow-y-auto bg-background-80 rounded-lg p-4">
|
||||
{sourcesGroupped?.map(({ name, official, disabled }) => (
|
||||
<Selector
|
||||
active={partialBoard?.source === name}
|
||||
disabled={disabled}
|
||||
key={`${name}`}
|
||||
tag={official ? 'official' : undefined}
|
||||
onClick={() => {
|
||||
setPartialBoard((curr) => ({
|
||||
...curr,
|
||||
source: name,
|
||||
}));
|
||||
}}
|
||||
text={formatSource(name, official)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-1 w-full">
|
||||
<Localized id="firmware_tool-select_source-version">
|
||||
<Typography variant="section-title" />
|
||||
@@ -268,6 +271,12 @@ export function SelectSourceSetep({
|
||||
text={name}
|
||||
/>
|
||||
))}
|
||||
{partialBoard?.source && possibleVersions?.length === 0 && (
|
||||
<Typography id="firmware_tool-select_source-no_versions" />
|
||||
)}
|
||||
{!partialBoard?.source && (
|
||||
<Typography id="firmware_tool-select_source-not_selected" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -28,18 +28,23 @@ export function ResetButtonIcon(options: UseResetOptions) {
|
||||
}
|
||||
|
||||
export function ResetButton({
|
||||
onClick,
|
||||
className,
|
||||
onReseted,
|
||||
children,
|
||||
onFailed,
|
||||
...options
|
||||
}: {
|
||||
onClick?: () => void;
|
||||
className?: string;
|
||||
children?: ReactNode;
|
||||
onReseted?: () => void;
|
||||
onFailed?: () => void;
|
||||
} & UseResetOptions) {
|
||||
const { triggerReset, status, timer, disabled, name, error } = useReset(
|
||||
options,
|
||||
onReseted
|
||||
onReseted,
|
||||
onFailed
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -60,7 +65,10 @@ export function ResetButton({
|
||||
>
|
||||
<Button
|
||||
icon={<ResetButtonIcon {...options} />}
|
||||
onClick={triggerReset}
|
||||
onClick={() => {
|
||||
if (onClick) onClick();
|
||||
triggerReset();
|
||||
}}
|
||||
className={classNames(
|
||||
'border-2 py-[5px]',
|
||||
status === 'finished'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
import { ReactNode, useCallback, useMemo, useState } from 'react';
|
||||
import { AssignTrackerRequestT, BodyPart, RpcMessage } from 'solarxr-protocol';
|
||||
import { useOnboarding } from '@/hooks/onboarding';
|
||||
import { useWebsocketAPI } from '@/hooks/websocket-api';
|
||||
@@ -12,7 +12,7 @@ import { TipBox } from '@/components/commons/TipBox';
|
||||
import { Typography } from '@/components/commons/Typography';
|
||||
import { BodyAssignment } from '@/components/onboarding/BodyAssignment';
|
||||
import { MountingSelectionMenu } from './MountingSelectionMenu';
|
||||
import { useLocalization } from '@fluent/react';
|
||||
import { Localized } from '@fluent/react';
|
||||
import { useBreakpoint } from '@/hooks/breakpoint';
|
||||
import { Quaternion } from 'three';
|
||||
import { AssignMode, defaultConfig, useConfig } from '@/hooks/config';
|
||||
@@ -22,7 +22,6 @@ import * as Sentry from '@sentry/react';
|
||||
|
||||
export function ManualMountingPage() {
|
||||
const { isMobile } = useBreakpoint('mobile');
|
||||
const { l10n } = useLocalization();
|
||||
const { applyProgress, state } = useOnboarding();
|
||||
const { sendRPCPacket } = useWebsocketAPI();
|
||||
const { config } = useConfig();
|
||||
@@ -57,7 +56,6 @@ export function ManualMountingPage() {
|
||||
mountingOrientationDegrees
|
||||
);
|
||||
assignreq.trackerId = td.tracker.trackerId;
|
||||
assignreq.allowDriftCompensation = false;
|
||||
|
||||
sendRPCPacket(RpcMessage.AssignTrackerRequest, assignreq);
|
||||
Sentry.metrics.count('manual_mounting_set', 1, {
|
||||
@@ -103,28 +101,26 @@ export function ManualMountingPage() {
|
||||
<div className="flex flex-col gap-5 h-full items-center w-full xs:justify-center relative overflow-y-auto">
|
||||
<div className="flex xs:flex-row mobile:flex-col h-full px-8 xs:w-full xs:justify-center mobile:px-4 items-center">
|
||||
<div className="flex flex-col w-full xs:max-w-sm gap-3">
|
||||
<Typography variant="main-title">
|
||||
{l10n.getString('onboarding-manual_mounting')}
|
||||
</Typography>
|
||||
<Typography>
|
||||
{l10n.getString('onboarding-manual_mounting-description')}
|
||||
</Typography>
|
||||
<TipBox>{l10n.getString('tips-find_tracker')}</TipBox>
|
||||
<Typography variant="main-title" id="onboarding-manual_mounting" />
|
||||
<Typography id="onboarding-manual_mounting-description" />
|
||||
<Typography id="tips-find_tracker" />
|
||||
<Localized id="tips-find_tracker">
|
||||
<TipBox />
|
||||
</Localized>
|
||||
|
||||
<div className="flex flex-row gap-3 mt-auto">
|
||||
<Button
|
||||
variant="secondary"
|
||||
to="/onboarding/mounting/choose"
|
||||
state={state}
|
||||
>
|
||||
{l10n.getString('onboarding-previous_step')}
|
||||
</Button>
|
||||
id="onboarding-previous_step"
|
||||
/>
|
||||
{!state.alonePage && (
|
||||
<Button
|
||||
variant="primary"
|
||||
to="/onboarding/body-proportions/scaled"
|
||||
>
|
||||
{l10n.getString('onboarding-manual_mounting-next')}
|
||||
</Button>
|
||||
id="onboarding-manual_mounting-next"
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
@@ -142,3 +138,108 @@ export function ManualMountingPage() {
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export function ManualMountingPageStayAligned({
|
||||
children,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
}) {
|
||||
const { isMobile } = useBreakpoint('mobile');
|
||||
const { sendRPCPacket } = useWebsocketAPI();
|
||||
const { config } = useConfig();
|
||||
|
||||
const [selectedRole, setSelectRole] = useState<BodyPart>(BodyPart.NONE);
|
||||
|
||||
const assignedTrackers = useAtomValue(assignedTrackersAtom);
|
||||
|
||||
const trackerPartGrouped = useMemo(
|
||||
() =>
|
||||
assignedTrackers.reduce<{ [key: number]: FlatDeviceTracker[] }>(
|
||||
(curr, td) => {
|
||||
const key = td.tracker.info?.bodyPart || BodyPart.NONE;
|
||||
return {
|
||||
...curr,
|
||||
[key]: [...(curr[key] || []), td],
|
||||
};
|
||||
},
|
||||
{}
|
||||
),
|
||||
[assignedTrackers]
|
||||
);
|
||||
|
||||
const onDirectionSelected = (mountingOrientationDegrees: Quaternion) => {
|
||||
(trackerPartGrouped[selectedRole] || []).forEach((td) => {
|
||||
const assignreq = new AssignTrackerRequestT();
|
||||
|
||||
assignreq.bodyPosition = td.tracker.info?.bodyPart || BodyPart.NONE;
|
||||
assignreq.mountingOrientation = MountingOrientationDegreesToQuatT(
|
||||
mountingOrientationDegrees
|
||||
);
|
||||
assignreq.trackerId = td.tracker.trackerId;
|
||||
|
||||
sendRPCPacket(RpcMessage.AssignTrackerRequest, assignreq);
|
||||
Sentry.metrics.count('manual_mounting_set', 1, {
|
||||
attributes: {
|
||||
part: BodyPart[assignreq.bodyPosition],
|
||||
direction: assignreq.mountingOrientation,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
setSelectRole(BodyPart.NONE);
|
||||
};
|
||||
|
||||
const getCurrRotation = useCallback(
|
||||
(role: BodyPart) => {
|
||||
if (role === BodyPart.NONE) return undefined;
|
||||
|
||||
const trackers = trackerPartGrouped[role] || [];
|
||||
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]
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<MountingSelectionMenu
|
||||
bodyPart={selectedRole}
|
||||
currRotation={getCurrRotation(selectedRole)}
|
||||
isOpen={selectedRole !== BodyPart.NONE}
|
||||
onClose={() => setSelectRole(BodyPart.NONE)}
|
||||
onDirectionSelected={onDirectionSelected}
|
||||
/>
|
||||
<div className="flex flex-col gap-5 h-full items-center w-full xs:justify-center relative overflow-y-auto">
|
||||
<div className="flex xs:flex-row mobile:flex-col h-full px-8 xs:w-full xs:justify-center mobile:px-4 items-center">
|
||||
<div className="flex flex-col w-full xs:max-w-sm gap-3">
|
||||
<Typography variant="main-title" id="onboarding-manual_mounting" />
|
||||
<Typography id="onboarding-manual_mounting-description" />
|
||||
<Typography id="tips-find_tracker" />
|
||||
<Localized id="tips-find_tracker">
|
||||
<TipBox />
|
||||
</Localized>
|
||||
{children}
|
||||
</div>
|
||||
<div className="flex flex-row justify-center">
|
||||
<BodyAssignment
|
||||
width={isMobile ? 160 : undefined}
|
||||
mirror={config?.mirrorView ?? defaultConfig.mirrorView}
|
||||
onlyAssigned={true}
|
||||
assignMode={AssignMode.All}
|
||||
onRoleSelected={setSelectRole}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -238,7 +238,7 @@ export function MountingSelectionMenu({
|
||||
shouldCloseOnEsc
|
||||
onRequestClose={onClose}
|
||||
overlayClassName={classNames(
|
||||
'fixed top-0 right-0 left-0 bottom-0 flex flex-col items-center w-full h-full bg-background-90 bg-opacity-90 z-20'
|
||||
'fixed top-0 right-0 left-0 bottom-0 flex flex-col items-center w-full h-full bg-background-90 bg-opacity-90 z-50'
|
||||
)}
|
||||
className={classNames(
|
||||
'focus:ring-transparent focus:ring-offset-transparent focus:outline-transparent outline-none mt-20 z-10'
|
||||
|
||||
+41
-17
@@ -1,32 +1,33 @@
|
||||
import { useState } from 'react';
|
||||
import { Button } from '@/components/commons/Button';
|
||||
import { Typography } from '@/components/commons/Typography';
|
||||
import { ResetType } from 'solarxr-protocol';
|
||||
import { ResetButton } from '@/components/home/ResetButton';
|
||||
import { useLocalization } from '@fluent/react';
|
||||
import { useBreakpoint } from '@/hooks/breakpoint';
|
||||
import { VerticalStepComponentProps } from '@/components/commons/VerticalStepper';
|
||||
|
||||
import { BaseModal } from '@/components/commons/BaseModal';
|
||||
import { ManualMountingPageStayAligned } from '@/components/onboarding/pages/mounting/ManualMounting';
|
||||
export function VerifyMountingStep({
|
||||
nextStep,
|
||||
prevStep,
|
||||
}: VerticalStepComponentProps) {
|
||||
const { isMobile } = useBreakpoint('mobile');
|
||||
const { l10n } = useLocalization();
|
||||
const [isOpen, setOpen] = useState(false);
|
||||
const [disableMounting, setDisableMounting] = useState(false);
|
||||
|
||||
const goNextStep = () => {
|
||||
setDisableMounting(false);
|
||||
setOpen(false);
|
||||
nextStep();
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col flex-grow justify-between py-2 gap-2">
|
||||
<div className="flex flex-col flex-grow">
|
||||
<div className="flex flex-grow flex-col gap-4 max-w-sm">
|
||||
<div className="flex flex-col gap-2">
|
||||
<Typography>
|
||||
{l10n.getString(
|
||||
'onboarding-automatic_mounting-mounting_reset-step-0'
|
||||
)}
|
||||
</Typography>
|
||||
<Typography>
|
||||
{l10n.getString(
|
||||
'onboarding-automatic_mounting-mounting_reset-step-1'
|
||||
)}
|
||||
</Typography>
|
||||
<Typography id="onboarding-automatic_mounting-mounting_reset-step-0" />
|
||||
<Typography id="onboarding-automatic_mounting-mounting_reset-step-1" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -50,13 +51,36 @@ export function VerifyMountingStep({
|
||||
</div>
|
||||
)}
|
||||
<div className="flex gap-3 justify-between">
|
||||
<Button variant={'secondary'} onClick={prevStep}>
|
||||
{l10n.getString('onboarding-automatic_mounting-prev_step')}
|
||||
</Button>
|
||||
<Button
|
||||
variant={'secondary'}
|
||||
onClick={prevStep}
|
||||
id="onboarding-automatic_mounting-prev_step"
|
||||
/>
|
||||
<Button
|
||||
disabled={disableMounting}
|
||||
variant={'secondary'}
|
||||
className="self-start mt-auto"
|
||||
onClick={() => setOpen(true)}
|
||||
id="onboarding-automatic_mounting-manual_mounting"
|
||||
/>
|
||||
<BaseModal isOpen={isOpen} onRequestClose={() => setOpen(false)}>
|
||||
<ManualMountingPageStayAligned>
|
||||
<div className="flex flex-row gap-3 mt-auto">
|
||||
<Button
|
||||
variant="primary"
|
||||
onClick={goNextStep}
|
||||
id="onboarding-stay_aligned-manual_mounting-done"
|
||||
/>
|
||||
</div>
|
||||
</ManualMountingPageStayAligned>
|
||||
</BaseModal>
|
||||
|
||||
<ResetButton
|
||||
onClick={() => setDisableMounting(true)}
|
||||
type={ResetType.Mounting}
|
||||
group="default"
|
||||
onReseted={nextStep}
|
||||
onReseted={goNextStep}
|
||||
onFailed={() => setDisableMounting(false)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -112,7 +112,6 @@ export function TrackersAssignPage() {
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
newTapSettings
|
||||
)
|
||||
);
|
||||
@@ -128,7 +127,6 @@ export function TrackersAssignPage() {
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
newTapSettings
|
||||
)
|
||||
);
|
||||
@@ -216,7 +214,6 @@ export function TrackersAssignPage() {
|
||||
assignreq.bodyPosition = role;
|
||||
assignreq.mountingOrientation = rotation;
|
||||
assignreq.trackerId = trackerId;
|
||||
assignreq.allowDriftCompensation = false;
|
||||
|
||||
sendRPCPacket(RpcMessage.AssignTrackerRequest, assignreq);
|
||||
};
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
SettingsResponseT,
|
||||
SteamVRTrackersSettingT,
|
||||
TapDetectionSettingsT,
|
||||
HIDSettingsT,
|
||||
} from 'solarxr-protocol';
|
||||
import { useConfig } from '@/hooks/config';
|
||||
import { useWebsocketAPI } from '@/hooks/websocket-api';
|
||||
@@ -101,6 +102,9 @@ export type SettingsForm = {
|
||||
};
|
||||
resetsSettings: ResetSettingsForm;
|
||||
stayAligned: StayAlignedSettingsForm;
|
||||
hidSettings: {
|
||||
trackersOverHID: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
const defaultValues: SettingsForm = {
|
||||
@@ -156,6 +160,7 @@ const defaultValues: SettingsForm = {
|
||||
legTweaks: { correctionStrength: 0.3 },
|
||||
resetsSettings: defaultResetSettings,
|
||||
stayAligned: defaultStayAlignedSettings,
|
||||
hidSettings: { trackersOverHID: false },
|
||||
};
|
||||
|
||||
export function GeneralSettings() {
|
||||
@@ -277,6 +282,10 @@ export function GeneralSettings() {
|
||||
|
||||
settings.stayAligned = serializeStayAlignedSettings(values.stayAligned);
|
||||
|
||||
const hidSettings = new HIDSettingsT();
|
||||
hidSettings.trackersOverHid = values.hidSettings.trackersOverHID;
|
||||
settings.hidSettings = hidSettings;
|
||||
|
||||
if (values.resetsSettings) {
|
||||
settings.resetsSettings = loadResetSettings(values.resetsSettings);
|
||||
}
|
||||
@@ -392,6 +401,12 @@ export function GeneralSettings() {
|
||||
);
|
||||
}
|
||||
|
||||
if (settings.hidSettings) {
|
||||
formData.hidSettings = {
|
||||
trackersOverHID: settings.hidSettings.trackersOverHid,
|
||||
};
|
||||
}
|
||||
|
||||
reset({ ...getValues(), ...formData });
|
||||
});
|
||||
|
||||
@@ -689,6 +704,28 @@ export function GeneralSettings() {
|
||||
settingType="general"
|
||||
id="mechanics-magnetometer"
|
||||
/>
|
||||
<div className="flex flex-col pt-5 pb-3">
|
||||
<Typography variant="section-title">
|
||||
{l10n.getString(
|
||||
'settings-general-tracker_mechanics-trackers_over_usb'
|
||||
)}
|
||||
</Typography>
|
||||
<Localized
|
||||
id="settings-general-tracker_mechanics-trackers_over_usb-description"
|
||||
elems={{ b: <b /> }}
|
||||
>
|
||||
<Typography />
|
||||
</Localized>
|
||||
</div>
|
||||
<CheckBox
|
||||
variant="toggle"
|
||||
outlined
|
||||
control={control}
|
||||
name="hidSettings.trackersOverHID"
|
||||
label={l10n.getString(
|
||||
'settings-general-tracker_mechanics-trackers_over_usb-enabled-label'
|
||||
)}
|
||||
/>
|
||||
</>
|
||||
</SettingsPagePaneLayout>
|
||||
<SettingsPagePaneLayout icon={<WrenchIcon />} id="fksettings">
|
||||
|
||||
@@ -54,11 +54,11 @@ export function TrackingChecklistSettings({
|
||||
// doing it this way prevents calling ignore step for every step.
|
||||
// that prevent sending a packet for steps that didnt change
|
||||
if (!value && !ignoredSteps.includes(stepId)) {
|
||||
ignoreStep(stepId, true);
|
||||
ignoreStep(stepId, true, false);
|
||||
}
|
||||
|
||||
if (value && ignoredSteps.includes(stepId)) {
|
||||
ignoreStep(stepId, false);
|
||||
ignoreStep(stepId, false, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,11 +2,14 @@ import { useConfig } from '@/hooks/config';
|
||||
import { useLocaleConfig } from '@/i18n/config';
|
||||
import { BatteryIcon } from '@/components/commons/icon/BatteryIcon';
|
||||
import { Typography } from '@/components/commons/Typography';
|
||||
import { Tooltip } from '@/components/commons/Tooltip';
|
||||
|
||||
export function TrackerBattery({
|
||||
value,
|
||||
voltage,
|
||||
runtime,
|
||||
disabled,
|
||||
moreInfo = false,
|
||||
textColor = 'primary',
|
||||
}: {
|
||||
/**
|
||||
@@ -14,7 +17,9 @@ export function TrackerBattery({
|
||||
*/
|
||||
value: number;
|
||||
voltage?: number | null;
|
||||
runtime?: bigint | null;
|
||||
disabled?: boolean;
|
||||
moreInfo?: boolean;
|
||||
textColor?: string;
|
||||
}) {
|
||||
const { currentLocales } = useLocaleConfig();
|
||||
@@ -28,31 +33,49 @@ export function TrackerBattery({
|
||||
});
|
||||
|
||||
const charging = (voltage || 0) > 4.3;
|
||||
const showVoltage = voltage && config?.debug;
|
||||
const debug = config?.debug || config?.devSettings.moreInfo;
|
||||
const showVoltage = moreInfo && voltage && debug;
|
||||
|
||||
return (
|
||||
<div className="flex gap-2">
|
||||
<div className="flex flex-col justify-around">
|
||||
<BatteryIcon value={value} disabled={disabled} charging={charging} />
|
||||
<Tooltip
|
||||
disabled={!charging && (!runtime || debug)}
|
||||
preferedDirection="left"
|
||||
content=<Typography>{percentFormatter.format(value)}</Typography>
|
||||
>
|
||||
<div className="flex gap-2">
|
||||
<div className="flex flex-col justify-around">
|
||||
<BatteryIcon value={value} disabled={disabled} charging={charging} />
|
||||
</div>
|
||||
{((!charging || showVoltage) && (
|
||||
<div className="w-15">
|
||||
{!charging && runtime != null && runtime > 0 && (
|
||||
<Typography color={textColor}>
|
||||
{(runtime / BigInt(3600000000)).toString() +
|
||||
'h ' +
|
||||
(
|
||||
(runtime % BigInt(3600000000)) /
|
||||
BigInt(60000000)
|
||||
).toString() +
|
||||
'min'}
|
||||
</Typography>
|
||||
)}
|
||||
{!charging && (!runtime || debug) && (
|
||||
<Typography color={textColor}>
|
||||
{percentFormatter.format(value)}
|
||||
</Typography>
|
||||
)}
|
||||
{showVoltage && (
|
||||
<Typography color={textColor}>
|
||||
{voltageFormatter.format(voltage)}V
|
||||
</Typography>
|
||||
)}
|
||||
</div>
|
||||
)) || (
|
||||
<div className="flex flex-col justify-center w-15">
|
||||
<div className="w-5 h-1 bg-background-30 rounded-full" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{((!charging || showVoltage) && (
|
||||
<div className="w-10">
|
||||
{!charging && (
|
||||
<Typography color={textColor}>
|
||||
{percentFormatter.format(value)}
|
||||
</Typography>
|
||||
)}
|
||||
{showVoltage && (
|
||||
<Typography color={textColor}>
|
||||
{voltageFormatter.format(voltage)}V
|
||||
</Typography>
|
||||
)}
|
||||
</div>
|
||||
)) || (
|
||||
<div className="flex flex-col justify-center w-10">
|
||||
<div className="w-5 h-1 bg-background-30 rounded-full" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Tooltip>
|
||||
);
|
||||
}
|
||||
@@ -51,7 +51,9 @@ function TrackerBig({
|
||||
<TrackerBattery
|
||||
voltage={device.hardwareStatus.batteryVoltage}
|
||||
value={device.hardwareStatus.batteryPctEstimate / 100}
|
||||
runtime={device.hardwareStatus.batteryRuntimeEstimate}
|
||||
disabled={tracker.status === TrackerStatusEnum.DISCONNECTED}
|
||||
moreInfo={true}
|
||||
/>
|
||||
)}
|
||||
<div className="flex gap-2">
|
||||
@@ -119,6 +121,7 @@ function TrackerSmol({
|
||||
<TrackerBattery
|
||||
voltage={device.hardwareStatus.batteryVoltage}
|
||||
value={device.hardwareStatus.batteryPctEstimate / 100}
|
||||
runtime={device.hardwareStatus.batteryRuntimeEstimate}
|
||||
disabled={tracker.status === TrackerStatusEnum.DISCONNECTED}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -85,7 +85,6 @@ export function TrackerSettingsPage() {
|
||||
);
|
||||
assignreq.bodyPosition = tracker?.tracker.info?.bodyPart || BodyPart.NONE;
|
||||
assignreq.trackerId = tracker?.tracker.trackerId;
|
||||
assignreq.allowDriftCompensation = false;
|
||||
sendRPCPacket(RpcMessage.AssignTrackerRequest, assignreq);
|
||||
setSelectRotation(false);
|
||||
};
|
||||
@@ -96,7 +95,6 @@ export function TrackerSettingsPage() {
|
||||
const assignreq = new AssignTrackerRequestT();
|
||||
assignreq.bodyPosition = role;
|
||||
assignreq.trackerId = tracker?.tracker.trackerId;
|
||||
assignreq.allowDriftCompensation = false;
|
||||
sendRPCPacket(RpcMessage.AssignTrackerRequest, assignreq);
|
||||
setSelectBodypart(false);
|
||||
};
|
||||
@@ -116,7 +114,6 @@ export function TrackerSettingsPage() {
|
||||
|
||||
assignreq.displayName = trackerName ?? null;
|
||||
assignreq.trackerId = tracker?.tracker.trackerId;
|
||||
assignreq.allowDriftCompensation = false;
|
||||
sendRPCPacket(RpcMessage.AssignTrackerRequest, assignreq);
|
||||
};
|
||||
|
||||
@@ -208,6 +205,15 @@ export function TrackerSettingsPage() {
|
||||
Firmware version
|
||||
</Typography>
|
||||
<div className="flex gap-2 flex-col">
|
||||
<div className="flex justify-between gap-2">
|
||||
<Typography id="tracker-settings-build-date" />
|
||||
<Typography
|
||||
whitespace="whitespace-pre-wrap"
|
||||
textAlign="text-end"
|
||||
>
|
||||
{tracker?.device?.hardwareInfo?.firmwareDate || '--'}
|
||||
</Typography>
|
||||
</div>
|
||||
<div className="flex justify-between gap-2">
|
||||
<Typography id="tracker-settings-current-version" />
|
||||
<Typography
|
||||
|
||||
@@ -229,7 +229,9 @@ function Row({
|
||||
<TrackerBattery
|
||||
value={device.hardwareStatus.batteryPctEstimate / 100}
|
||||
voltage={device.hardwareStatus.batteryVoltage}
|
||||
runtime={device.hardwareStatus.batteryRuntimeEstimate}
|
||||
disabled={tracker.status === TrackerStatusEnum.DISCONNECTED}
|
||||
moreInfo={config?.devSettings.moreInfo}
|
||||
textColor={fontColor}
|
||||
/>
|
||||
)}
|
||||
@@ -327,20 +329,20 @@ export function TrackersTable({
|
||||
|
||||
const gridTemplateColumns = useMemo(() => {
|
||||
const cols = [
|
||||
'minmax(150px, 1.5fr)', // Name
|
||||
'minmax(100px, 1fr)', // Type
|
||||
'minmax(60px, 1fr)', // Battery
|
||||
'6rem', // Ping (w-24)
|
||||
'minmax(60px, 1fr)', // TPS
|
||||
config?.devSettings?.preciseRotation ? '11rem' : '8rem', // Rotation
|
||||
'minmax(60px, 1fr)', // Temp
|
||||
'minmax(15rem, 1.5fr)', // Name
|
||||
'9rem', // Type
|
||||
'9rem', // Battery
|
||||
'9rem', // Ping (w-24)
|
||||
'5rem', // TPS
|
||||
config?.devSettings?.preciseRotation ? '11rem' : '9rem', // Rotation
|
||||
'9rem', // Temp
|
||||
];
|
||||
|
||||
if (moreInfo) {
|
||||
cols.push('9rem'); // Linear Acc
|
||||
cols.push('9rem'); // Position
|
||||
cols.push('9rem'); // Stay Aligned
|
||||
cols.push('minmax(150px, 1fr)'); // URL
|
||||
cols.push('11rem'); // URL
|
||||
}
|
||||
|
||||
return cols.join(' ');
|
||||
|
||||
@@ -109,7 +109,10 @@ const stepContentLookup: Record<
|
||||
context: TrackingChecklistContext
|
||||
) => JSX.Element
|
||||
> = {
|
||||
[TrackingChecklistStepId.TRACKERS_REST_CALIBRATION]: (step, { toggle }) => {
|
||||
[TrackingChecklistStepId.TRACKERS_REST_CALIBRATION]: (
|
||||
step,
|
||||
{ toggleSession }
|
||||
) => {
|
||||
return (
|
||||
<div className="space-y-2.5">
|
||||
<Typography id="tracking_checklist-TRACKERS_REST_CALIBRATION-desc" />
|
||||
@@ -118,7 +121,7 @@ const stepContentLookup: Record<
|
||||
<Button
|
||||
id="tracking_checklist-ignore"
|
||||
variant="secondary"
|
||||
onClick={() => toggle(step.id)}
|
||||
onClick={() => toggleSession(step.id)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
@@ -166,7 +169,7 @@ const stepContentLookup: Record<
|
||||
</div>
|
||||
);
|
||||
},
|
||||
[TrackingChecklistStepId.STEAMVR_DISCONNECTED]: (step, { toggle }) => {
|
||||
[TrackingChecklistStepId.STEAMVR_DISCONNECTED]: (step, { toggleSession }) => {
|
||||
return (
|
||||
<>
|
||||
<div className="space-y-2.5">
|
||||
@@ -181,7 +184,7 @@ const stepContentLookup: Record<
|
||||
<Button
|
||||
id="tracking_checklist-ignore"
|
||||
variant="secondary"
|
||||
onClick={() => toggle(step.id)}
|
||||
onClick={() => toggleSession(step.id)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
@@ -195,7 +198,10 @@ const stepContentLookup: Record<
|
||||
[TrackingChecklistStepId.UNASSIGNED_HMD]: () => {
|
||||
return <Typography id="tracking_checklist-UNASSIGNED_HMD-desc" />;
|
||||
},
|
||||
[TrackingChecklistStepId.NETWORK_PROFILE_PUBLIC]: (step, { toggle }) => {
|
||||
[TrackingChecklistStepId.NETWORK_PROFILE_PUBLIC]: (
|
||||
step,
|
||||
{ toggleSession }
|
||||
) => {
|
||||
const data = step.extraData as TrackingChecklistPublicNetworksT | null;
|
||||
return (
|
||||
<>
|
||||
@@ -226,7 +232,7 @@ const stepContentLookup: Record<
|
||||
<Button
|
||||
id="tracking_checklist-ignore"
|
||||
variant="secondary"
|
||||
onClick={() => toggle(step.id)}
|
||||
onClick={() => toggleSession(step.id)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
@@ -234,7 +240,7 @@ const stepContentLookup: Record<
|
||||
</>
|
||||
);
|
||||
},
|
||||
[TrackingChecklistStepId.VRCHAT_SETTINGS]: (step, { toggle }) => {
|
||||
[TrackingChecklistStepId.VRCHAT_SETTINGS]: (step, { toggleSession }) => {
|
||||
return (
|
||||
<>
|
||||
<div className="space-y-2.5">
|
||||
@@ -249,7 +255,7 @@ const stepContentLookup: Record<
|
||||
<Button
|
||||
id="tracking_checklist-ignore"
|
||||
variant="secondary"
|
||||
onClick={() => toggle(step.id)}
|
||||
onClick={() => toggleSession(step.id)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
@@ -257,7 +263,7 @@ const stepContentLookup: Record<
|
||||
</>
|
||||
);
|
||||
},
|
||||
[TrackingChecklistStepId.MOUNTING_CALIBRATION]: (step, { toggle }) => {
|
||||
[TrackingChecklistStepId.MOUNTING_CALIBRATION]: (step, { toggleSession }) => {
|
||||
return (
|
||||
<div className="space-y-2.5">
|
||||
<Typography id="onboarding-automatic_mounting-mounting_reset-step-0" />
|
||||
@@ -275,14 +281,17 @@ const stepContentLookup: Record<
|
||||
<Button
|
||||
id="tracking_checklist-ignore"
|
||||
variant="secondary"
|
||||
onClick={() => toggle(step.id)}
|
||||
onClick={() => toggleSession(step.id)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
[TrackingChecklistStepId.FEET_MOUNTING_CALIBRATION]: (step, { toggle }) => {
|
||||
[TrackingChecklistStepId.FEET_MOUNTING_CALIBRATION]: (
|
||||
step,
|
||||
{ toggleSession }
|
||||
) => {
|
||||
return (
|
||||
<div className="space-y-2.5">
|
||||
<Typography id="onboarding-automatic_mounting-mounting_reset-feet-step-0" />
|
||||
@@ -309,14 +318,17 @@ const stepContentLookup: Record<
|
||||
<Button
|
||||
id="tracking_checklist-ignore"
|
||||
variant="secondary"
|
||||
onClick={() => toggle(step.id)}
|
||||
onClick={() => toggleSession(step.id)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
[TrackingChecklistStepId.STAY_ALIGNED_CONFIGURED]: (step, { toggle }) => {
|
||||
[TrackingChecklistStepId.STAY_ALIGNED_CONFIGURED]: (
|
||||
step,
|
||||
{ toggleSession }
|
||||
) => {
|
||||
return (
|
||||
<>
|
||||
<div className="space-y-2.5">
|
||||
@@ -332,7 +344,7 @@ const stepContentLookup: Record<
|
||||
<Button
|
||||
id="tracking_checklist-ignore"
|
||||
variant="secondary"
|
||||
onClick={() => toggle(step.id)}
|
||||
onClick={() => toggleSession(step.id)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -27,13 +27,16 @@ export const BODY_PARTS_GROUPS: Record<MountingResetGroup, BodyPart[]> = {
|
||||
fingers: FINGER_BODY_PARTS,
|
||||
};
|
||||
|
||||
export function useReset(options: UseResetOptions, onReseted?: () => void) {
|
||||
export function useReset(
|
||||
options: UseResetOptions,
|
||||
onReseted?: () => void,
|
||||
onFailed?: () => void
|
||||
) {
|
||||
if (options.type === ResetType.Mounting && !options.group) options.group = 'default';
|
||||
|
||||
const serverGuards = useAtomValue(serverGuardsAtom);
|
||||
const { currentLocales } = useLocaleConfig();
|
||||
const { sendRPCPacket, useRPCPacket } = useWebsocketAPI();
|
||||
|
||||
const finishedTimeoutRef = useRef<NodeJS.Timeout>();
|
||||
const [status, setStatus] = useState<ResetBtnStatus>('idle');
|
||||
const [progress, setProgress] = useState(0);
|
||||
@@ -62,6 +65,7 @@ export function useReset(options: UseResetOptions, onReseted?: () => void) {
|
||||
|
||||
const onResetCanceled = () => {
|
||||
if (status !== 'finished') setStatus('idle');
|
||||
if (onFailed) onFailed();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -92,8 +92,16 @@ export type Steps = {
|
||||
visibleSteps: TrackingChecklistStep[];
|
||||
ignoredSteps: TrackingChecklistStepId[];
|
||||
};
|
||||
|
||||
const filterActive =
|
||||
(ignoredSteps: TrackingChecklistStepId[]) => (step: TrackingChecklistStepT) =>
|
||||
!ignoredSteps.includes(step.id) && step.enabled;
|
||||
|
||||
export function provideTrackingChecklist() {
|
||||
const { sendRPCPacket, useRPCPacket } = useWebsocketAPI();
|
||||
const [sessionIgnoredSteps, setSessionIgnoredSteps] = useState<
|
||||
TrackingChecklistStepId[]
|
||||
>([]);
|
||||
const [steps, setSteps] = useState<Steps>({
|
||||
steps: [],
|
||||
visibleSteps: [],
|
||||
@@ -104,7 +112,7 @@ export function provideTrackingChecklist() {
|
||||
RpcMessage.TrackingChecklistResponse,
|
||||
(data: TrackingChecklistResponseT) => {
|
||||
const activeSteps = data.steps.filter(
|
||||
(step) => !data.ignoredSteps.includes(step.id) && step.enabled
|
||||
filterActive([...data.ignoredSteps, ...sessionIgnoredSteps])
|
||||
);
|
||||
setSteps({
|
||||
steps: data.steps,
|
||||
@@ -161,26 +169,48 @@ export function provideTrackingChecklist() {
|
||||
[steps]
|
||||
);
|
||||
|
||||
const ignoreStep = (step: TrackingChecklistStepId, ignore: boolean) => {
|
||||
const res = new IgnoreTrackingChecklistStepRequestT();
|
||||
res.stepId = step;
|
||||
res.ignore = ignore;
|
||||
sendRPCPacket(RpcMessage.IgnoreTrackingChecklistStepRequest, res);
|
||||
Sentry.metrics.count(ignore ? 'mute_checklist_step' : 'unmute_checklist_step', 1, {
|
||||
attributes: { step: TrackingChecklistStepId[step] },
|
||||
const ignoreStep = (
|
||||
step: TrackingChecklistStepId,
|
||||
ignore: boolean,
|
||||
session = true
|
||||
) => {
|
||||
setSessionIgnoredSteps((curr) => {
|
||||
if (ignore && !curr.includes(step)) return [...curr, step];
|
||||
if (!ignore && curr.includes(step)) {
|
||||
curr.splice(curr.indexOf(step), 1);
|
||||
return curr;
|
||||
}
|
||||
return curr;
|
||||
});
|
||||
Sentry.metrics.count(ignore ? 'mute_checklist_step' : 'unmute_checklist_step', 1, {
|
||||
attributes: { step: TrackingChecklistStepId[step], session },
|
||||
});
|
||||
if (session) {
|
||||
// Force refresh of the flightlist when ignoring a step as the filtering
|
||||
// is done only in one place to simplify the data flow
|
||||
sendRPCPacket(
|
||||
RpcMessage.TrackingChecklistRequest,
|
||||
new TrackingChecklistRequestT()
|
||||
);
|
||||
} else {
|
||||
const res = new IgnoreTrackingChecklistStepRequestT();
|
||||
res.stepId = step;
|
||||
res.ignore = ignore;
|
||||
sendRPCPacket(RpcMessage.IgnoreTrackingChecklistStepRequest, res);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
...steps,
|
||||
sessionIgnoredSteps,
|
||||
firstRequired,
|
||||
highlightedTrackers,
|
||||
progress,
|
||||
completion,
|
||||
warnings,
|
||||
ignoreStep,
|
||||
toggle: (step: TrackingChecklistStepId) =>
|
||||
ignoreStep(step, !steps.ignoredSteps.includes(step)),
|
||||
toggleSession: (step: TrackingChecklistStepId) =>
|
||||
ignoreStep(step, !sessionIgnoredSteps.includes(step)),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+6
-2
@@ -8,10 +8,13 @@ import android.content.IntentFilter
|
||||
import android.hardware.usb.UsbDevice
|
||||
import android.hardware.usb.UsbManager
|
||||
import androidx.core.content.ContextCompat
|
||||
import dev.slimevr.VRServer
|
||||
import dev.slimevr.config.config
|
||||
import dev.slimevr.tracking.trackers.Device
|
||||
import dev.slimevr.tracking.trackers.Tracker
|
||||
import dev.slimevr.tracking.trackers.TrackerStatus
|
||||
import dev.slimevr.tracking.trackers.hid.HIDCommon
|
||||
import dev.slimevr.tracking.trackers.hid.HIDCommon.Companion.HID_TRACKER_PID
|
||||
import dev.slimevr.tracking.trackers.hid.HIDCommon.Companion.HID_TRACKER_RECEIVER_PID
|
||||
import dev.slimevr.tracking.trackers.hid.HIDCommon.Companion.HID_TRACKER_RECEIVER_VID
|
||||
import dev.slimevr.tracking.trackers.hid.HIDCommon.Companion.PACKET_SIZE
|
||||
@@ -91,7 +94,7 @@ class AndroidHIDManager(
|
||||
}
|
||||
|
||||
fun checkConfigureDevice(usbDevice: UsbDevice, requestPermission: Boolean = false) {
|
||||
if (usbDevice.vendorId == HID_TRACKER_RECEIVER_VID && usbDevice.productId == HID_TRACKER_RECEIVER_PID) {
|
||||
if (usbDevice.vendorId == HID_TRACKER_RECEIVER_VID && (usbDevice.productId == HID_TRACKER_RECEIVER_PID || usbDevice.productId == HID_TRACKER_PID)) {
|
||||
if (usbManager.hasPermission(usbDevice)) {
|
||||
LogManager.info("[TrackerServer] Already have permission for ${usbDevice.deviceName}")
|
||||
proceedWithDeviceConfiguration(usbDevice)
|
||||
@@ -199,8 +202,9 @@ class AndroidHIDManager(
|
||||
}
|
||||
|
||||
private fun deviceEnumerate(requestPermission: Boolean = false) {
|
||||
val trackersOverHID: Boolean = VRServer.instance.configManager.vrConfig.hidConfig.trackersOverHID
|
||||
val hidDeviceList: MutableList<UsbDevice> = usbManager.deviceList.values.filter {
|
||||
it.vendorId == HID_TRACKER_RECEIVER_VID && it.productId == HID_TRACKER_RECEIVER_PID
|
||||
it.vendorId == HID_TRACKER_RECEIVER_VID && (it.productId == HID_TRACKER_RECEIVER_PID || (trackersOverHID && it.productId == HID_TRACKER_PID))
|
||||
}.toMutableList()
|
||||
synchronized(devicesByHID) {
|
||||
// Work on devicesByHid and add/remove as necessary
|
||||
|
||||
@@ -223,7 +223,6 @@ class VRServer @JvmOverloads constructor(
|
||||
queueTask {
|
||||
humanPoseManager.trackerUpdated(tracker)
|
||||
updateSkeletonModel()
|
||||
refreshTrackersDriftCompensationEnabled()
|
||||
configManager.vrConfig.writeTrackerConfig(tracker)
|
||||
configManager.saveConfig()
|
||||
}
|
||||
@@ -281,7 +280,6 @@ class VRServer @JvmOverloads constructor(
|
||||
if (tracker.isComputed) {
|
||||
vMCHandler.addComputedTracker(tracker)
|
||||
}
|
||||
refreshTrackersDriftCompensationEnabled()
|
||||
}
|
||||
|
||||
@ThreadSecure
|
||||
@@ -441,22 +439,6 @@ class VRServer @JvmOverloads constructor(
|
||||
return null
|
||||
}
|
||||
|
||||
fun clearTrackersDriftCompensation() {
|
||||
for (t in allTrackers) {
|
||||
if (t.isImu()) {
|
||||
t.resetsHandler.clearDriftCompensation()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun refreshTrackersDriftCompensationEnabled() {
|
||||
for (t in allTrackers) {
|
||||
if (t.isImu()) {
|
||||
t.resetsHandler.refreshDriftCompensationEnabled()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun trackerStatusChanged(tracker: Tracker, oldStatus: TrackerStatus, newStatus: TrackerStatus) {
|
||||
trackerStatusListeners.forEach { it.onTrackerStatusChanged(tracker, oldStatus, newStatus) }
|
||||
}
|
||||
|
||||
@@ -339,6 +339,15 @@ public class CurrentVRConfigConverter implements VersionedModelConverter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (version < 15) {
|
||||
ObjectNode checklistNode = (ObjectNode) modelData.get("trackingChecklist");
|
||||
if (checklistNode != null) {
|
||||
ArrayNode ignoredStepsArray = (ArrayNode) checklistNode.get("ignoredStepsIds");
|
||||
if (ignoredStepsArray != null)
|
||||
ignoredStepsArray.removeAll();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogManager.severe("Error during config migration: " + e);
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import dev.slimevr.VRServer
|
||||
|
||||
class DriftCompensationConfig {
|
||||
|
||||
// Is drift compensation enabled
|
||||
var enabled = false
|
||||
|
||||
// Is drift prediction enabled
|
||||
var prediction = false
|
||||
|
||||
// Amount of drift compensation applied
|
||||
var amount = 0.8f
|
||||
|
||||
// Max resets for the calculated average drift
|
||||
var maxResets = 6
|
||||
|
||||
fun updateTrackersDriftCompensation() {
|
||||
for (t in VRServer.instance.allTrackers) {
|
||||
if (t.isImu()) {
|
||||
t.resetsHandler.readDriftCompensationConfig(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package dev.slimevr.config
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
|
||||
class HIDConfig {
|
||||
var trackersOverHID = false
|
||||
}
|
||||
@@ -15,7 +15,6 @@ class TrackerConfig {
|
||||
var adjustment: ObjectQuaternion? = null
|
||||
var mountingOrientation: ObjectQuaternion? = null
|
||||
var mountingResetOrientation: ObjectQuaternion? = null
|
||||
var allowDriftCompensation: Boolean? = null
|
||||
|
||||
/**
|
||||
* Only checked if [ServerConfig.useMagnetometerOnAllTrackers] enabled
|
||||
@@ -27,7 +26,6 @@ class TrackerConfig {
|
||||
constructor(tracker: Tracker) {
|
||||
this.designation = if (tracker.trackerPosition != null) tracker.trackerPosition!!.designation else null
|
||||
this.customName = tracker.customName
|
||||
allowDriftCompensation = tracker.isImu()
|
||||
shouldHaveMagEnabled = tracker.isImu()
|
||||
}
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import dev.slimevr.tracking.trackers.Tracker
|
||||
import dev.slimevr.tracking.trackers.TrackerRole
|
||||
|
||||
@JsonVersionedModel(
|
||||
currentVersion = "14",
|
||||
defaultDeserializeToVersion = "14",
|
||||
currentVersion = "15",
|
||||
defaultDeserializeToVersion = "15",
|
||||
toCurrentConverterClass = CurrentVRConfigConverter::class,
|
||||
)
|
||||
class VRConfig {
|
||||
@@ -19,8 +19,6 @@ class VRConfig {
|
||||
|
||||
val filters: FiltersConfig = FiltersConfig()
|
||||
|
||||
val driftCompensation: DriftCompensationConfig = DriftCompensationConfig()
|
||||
|
||||
val oscRouter: OSCConfig = OSCConfig()
|
||||
|
||||
val vrcOSC: VRCOSCConfig = VRCOSCConfig()
|
||||
@@ -42,6 +40,8 @@ class VRConfig {
|
||||
|
||||
val stayAlignedConfig = StayAlignedConfig()
|
||||
|
||||
val hidConfig = HIDConfig()
|
||||
|
||||
@JsonDeserialize(using = TrackerConfigMapDeserializer::class)
|
||||
@JsonSerialize(keyUsing = StdKeySerializers.StringKeySerializer::class)
|
||||
private val trackers: MutableMap<String, TrackerConfig> = HashMap()
|
||||
@@ -106,7 +106,6 @@ class VRConfig {
|
||||
if (tracker.userEditable) {
|
||||
val config = getTracker(tracker)
|
||||
tracker.readConfig(config)
|
||||
if (tracker.isImu()) tracker.resetsHandler.readDriftCompensationConfig(driftCompensation)
|
||||
tracker.resetsHandler.readResetConfig(resetsConfig)
|
||||
if (tracker.allowReset) {
|
||||
tracker.saveMountingResetOrientation(config)
|
||||
|
||||
@@ -39,6 +39,10 @@ public class DataFeedBuilder {
|
||||
? fbb.createString(device.getManufacturer())
|
||||
: 0;
|
||||
|
||||
int firmwareDateOffset = device.getFirmwareDate() != null
|
||||
? fbb.createString(device.getFirmwareDate())
|
||||
: 0;
|
||||
|
||||
int hardwareIdentifierOffset = fbb.createString(device.getHardwareIdentifier());
|
||||
|
||||
HardwareInfo.startHardwareInfo(fbb);
|
||||
@@ -46,6 +50,8 @@ public class DataFeedBuilder {
|
||||
HardwareInfo.addManufacturer(fbb, manufacturerOffset);
|
||||
HardwareInfo.addHardwareIdentifier(fbb, hardwareIdentifierOffset);
|
||||
|
||||
HardwareInfo.addFirmwareDate(fbb, firmwareDateOffset);
|
||||
|
||||
if (device instanceof UDPDevice udpDevice) {
|
||||
var address = udpDevice.getIpAddress().getAddress();
|
||||
HardwareInfo
|
||||
@@ -68,6 +74,7 @@ public class DataFeedBuilder {
|
||||
|
||||
HardwareInfo.addMcuId(fbb, device.getMcuType().getSolarType());
|
||||
HardwareInfo.addOfficialBoardType(fbb, device.getBoardType().getSolarType());
|
||||
|
||||
return HardwareInfo.endHardwareInfo(fbb);
|
||||
}
|
||||
|
||||
@@ -129,17 +136,7 @@ public class DataFeedBuilder {
|
||||
|
||||
// TODO need support: TrackerInfo.addPollRate(fbb, tracker.);
|
||||
|
||||
if (tracker.isImu()) {
|
||||
TrackerInfo.addIsImu(fbb, true);
|
||||
TrackerInfo
|
||||
.addAllowDriftCompensation(
|
||||
fbb,
|
||||
tracker.getResetsHandler().getAllowDriftCompensation()
|
||||
);
|
||||
} else {
|
||||
TrackerInfo.addIsImu(fbb, false);
|
||||
TrackerInfo.addAllowDriftCompensation(fbb, false);
|
||||
}
|
||||
TrackerInfo.addIsImu(fbb, tracker.isImu());
|
||||
|
||||
if (tracker.getAllowMounting()) {
|
||||
Quaternion quaternion = tracker.getResetsHandler().getMountingOrientation();
|
||||
@@ -310,6 +307,9 @@ public class DataFeedBuilder {
|
||||
HardwareStatus.addRssi(fbb, (short) tracker.getSignalStrength().floatValue());
|
||||
}
|
||||
|
||||
if (tracker.getBatteryRemainingRuntime() != null) {
|
||||
HardwareStatus.addBatteryRuntimeEstimate(fbb, tracker.getBatteryRemainingRuntime());
|
||||
}
|
||||
|
||||
int hardwareDataOffset = HardwareStatus.endHardwareStatus(fbb);
|
||||
int hardwareInfoOffset = DataFeedBuilder.createHardwareInfo(fbb, device);
|
||||
|
||||
@@ -58,11 +58,6 @@ class RPCHandler(private val api: ProtocolAPI) : ProtocolHandler<RpcMessageHeade
|
||||
::onAssignTrackerRequest,
|
||||
)
|
||||
|
||||
registerPacketListener(
|
||||
RpcMessage.ClearDriftCompensationRequest,
|
||||
::onClearDriftCompensationRequest,
|
||||
)
|
||||
|
||||
registerPacketListener(
|
||||
RpcMessage.RecordBVHRequest,
|
||||
::onRecordBVHRequest,
|
||||
@@ -312,26 +307,9 @@ class RPCHandler(private val api: ProtocolAPI) : ProtocolHandler<RpcMessageHeade
|
||||
tracker.customName = req.displayName()
|
||||
}
|
||||
|
||||
if (tracker.isImu()) {
|
||||
tracker.resetsHandler.allowDriftCompensation = req.allowDriftCompensation()
|
||||
}
|
||||
|
||||
api.server.trackerUpdated(tracker)
|
||||
}
|
||||
|
||||
fun onClearDriftCompensationRequest(
|
||||
conn: GenericConnection,
|
||||
messageHeader: RpcMessageHeader,
|
||||
) {
|
||||
if (messageHeader
|
||||
.message(ClearDriftCompensationRequest()) !is ClearDriftCompensationRequest
|
||||
) {
|
||||
return
|
||||
}
|
||||
|
||||
api.server.clearTrackersDriftCompensation()
|
||||
}
|
||||
|
||||
fun onLegTweaksTmpChange(
|
||||
conn: GenericConnection,
|
||||
messageHeader: RpcMessageHeader,
|
||||
|
||||
+5
-19
@@ -113,20 +113,6 @@ public class RPCSettingsBuilder {
|
||||
);
|
||||
}
|
||||
|
||||
public static int createDriftCompensationSettings(
|
||||
FlatBufferBuilder fbb,
|
||||
DriftCompensationConfig driftCompensationConfig
|
||||
) {
|
||||
return DriftCompensationSettings
|
||||
.createDriftCompensationSettings(
|
||||
fbb,
|
||||
driftCompensationConfig.getEnabled(),
|
||||
driftCompensationConfig.getPrediction(),
|
||||
driftCompensationConfig.getAmount(),
|
||||
driftCompensationConfig.getMaxResets()
|
||||
);
|
||||
}
|
||||
|
||||
public static int createTapDetectionSettings(
|
||||
FlatBufferBuilder fbb,
|
||||
TapDetectionConfig tapDetectionConfig
|
||||
@@ -366,11 +352,6 @@ public class RPCSettingsBuilder {
|
||||
fbb,
|
||||
server.configManager.getVrConfig().getFilters()
|
||||
),
|
||||
RPCSettingsBuilder
|
||||
.createDriftCompensationSettings(
|
||||
fbb,
|
||||
server.configManager.getVrConfig().getDriftCompensation()
|
||||
),
|
||||
RPCSettingsBuilder
|
||||
.createOSCRouterSettings(
|
||||
fbb,
|
||||
@@ -412,6 +393,11 @@ public class RPCSettingsBuilder {
|
||||
.createStayAlignedSettings(
|
||||
fbb,
|
||||
server.configManager.getVrConfig().getStayAlignedConfig()
|
||||
),
|
||||
RPCSettingsBuilderKotlin.INSTANCE
|
||||
.createHIDSettings(
|
||||
fbb,
|
||||
server.configManager.getVrConfig().getHidConfig()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
+11
@@ -1,7 +1,9 @@
|
||||
package dev.slimevr.protocol.rpc.settings
|
||||
|
||||
import com.google.flatbuffers.FlatBufferBuilder
|
||||
import dev.slimevr.config.HIDConfig
|
||||
import dev.slimevr.config.StayAlignedConfig
|
||||
import solarxr_protocol.rpc.HIDSettings
|
||||
import solarxr_protocol.rpc.StayAlignedSettings
|
||||
|
||||
object RPCSettingsBuilderKotlin {
|
||||
@@ -29,4 +31,13 @@ object RPCSettingsBuilderKotlin {
|
||||
config.flatRelaxedPose.footAngleInDeg,
|
||||
config.setupComplete,
|
||||
)
|
||||
|
||||
fun createHIDSettings(
|
||||
fbb: FlatBufferBuilder,
|
||||
config: HIDConfig,
|
||||
): Int = HIDSettings
|
||||
.createHIDSettings(
|
||||
fbb,
|
||||
config.trackersOverHID,
|
||||
)
|
||||
}
|
||||
@@ -77,17 +77,6 @@ class RPCSettingsHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) {
|
||||
}
|
||||
}
|
||||
|
||||
if (req.driftCompensation() != null) {
|
||||
val driftCompensationConfig = api.server.configManager
|
||||
.vrConfig
|
||||
.driftCompensation
|
||||
driftCompensationConfig.enabled = req.driftCompensation().enabled()
|
||||
driftCompensationConfig.prediction = req.driftCompensation().prediction()
|
||||
driftCompensationConfig.amount = req.driftCompensation().amount()
|
||||
driftCompensationConfig.maxResets = req.driftCompensation().maxResets()
|
||||
driftCompensationConfig.updateTrackersDriftCompensation()
|
||||
}
|
||||
|
||||
if (req.oscRouter() != null) {
|
||||
val oscRouterConfig = api.server.configManager
|
||||
.vrConfig
|
||||
@@ -369,6 +358,12 @@ class RPCSettingsHandler(var rpcHandler: RPCHandler, var api: ProtocolAPI) {
|
||||
config.flatRelaxedPose.footAngleInDeg = requestConfig.flatFootAngle()
|
||||
}
|
||||
|
||||
if (req.hidSettings() != null) {
|
||||
val config = api.server.configManager.vrConfig.hidConfig
|
||||
val requestConfig = req.hidSettings()
|
||||
config.trackersOverHID = requestConfig.trackersOverHid()
|
||||
}
|
||||
|
||||
api.server.configManager.saveConfig()
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ open class Device(val magSupport: Boolean = false) {
|
||||
open val id: Int = nextLocalDeviceId.incrementAndGet()
|
||||
open var name: String? = null
|
||||
open var firmwareVersion: String? = null
|
||||
open var firmwareDate: String? = null
|
||||
open var manufacturer: String? = null
|
||||
open val trackers: MutableMap<Int, Tracker> = ConcurrentHashMap()
|
||||
|
||||
|
||||
@@ -112,9 +112,11 @@ class Tracker @JvmOverloads constructor(
|
||||
val trackerFlexHandler: TrackerFlexHandler = TrackerFlexHandler(this)
|
||||
var batteryVoltage: Float? = null
|
||||
var batteryLevel: Float? = null
|
||||
var batteryRemainingRuntime: Long? = null
|
||||
var ping: Int? = null
|
||||
var signalStrength: Int? = null
|
||||
var temperature: Float? = null
|
||||
var button: Int? = null
|
||||
var customName: String? = null
|
||||
var magStatus: MagnetometerStatus = magStatus
|
||||
private set
|
||||
@@ -139,7 +141,6 @@ class Tracker @JvmOverloads constructor(
|
||||
// the VRServer to recreate the skeleton, as it may need to
|
||||
// assign or un-assign the tracker to a body part
|
||||
VRServer.instance.updateSkeletonModel()
|
||||
VRServer.instance.refreshTrackersDriftCompensationEnabled()
|
||||
VRServer.instance.trackerStatusChanged(this, old, new)
|
||||
}
|
||||
}
|
||||
@@ -198,16 +199,6 @@ class Tracker @JvmOverloads constructor(
|
||||
// Load manual mounting
|
||||
config.mountingOrientation?.let { resetsHandler.mountingOrientation = it.toValue() }
|
||||
}
|
||||
if (this.isImu() && config.allowDriftCompensation == null) {
|
||||
// If value didn't exist, default to true and save
|
||||
resetsHandler.allowDriftCompensation = true
|
||||
VRServer.instance.configManager.vrConfig.getTracker(this).allowDriftCompensation = true
|
||||
VRServer.instance.configManager.saveConfig()
|
||||
} else {
|
||||
config.allowDriftCompensation?.let {
|
||||
resetsHandler.allowDriftCompensation = it
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,9 +211,6 @@ class Tracker @JvmOverloads constructor(
|
||||
// Save manual mounting
|
||||
config.mountingOrientation = resetsHandler.mountingOrientation.toObject()
|
||||
}
|
||||
if (this.isImu()) {
|
||||
config.allowDriftCompensation = resetsHandler.allowDriftCompensation
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -282,7 +270,7 @@ class Tracker @JvmOverloads constructor(
|
||||
|
||||
/**
|
||||
* Gets the adjusted tracker rotation after the resetsHandler's corrections
|
||||
* (reset, mounting and drift compensation).
|
||||
* (reset and mounting).
|
||||
* This is the rotation that is applied on the SlimeVR skeleton bones.
|
||||
* Warning: This performs several Quaternion multiplications, so calling
|
||||
* it too much should be avoided for performance reasons.
|
||||
@@ -297,8 +285,8 @@ class Tracker @JvmOverloads constructor(
|
||||
|
||||
// Reset if needed and is not computed and internal
|
||||
return if (allowReset && !(isComputed && isInternal) && trackerDataType == TrackerDataType.ROTATION) {
|
||||
// Adjust to reset, mounting and drift compensation
|
||||
resetsHandler.getReferenceAdjustedDriftRotationFrom(rot)
|
||||
// Adjust to reset and mounting
|
||||
resetsHandler.getReferenceAdjustedRotationFrom(rot)
|
||||
} else {
|
||||
rot
|
||||
}
|
||||
@@ -317,8 +305,8 @@ class Tracker @JvmOverloads constructor(
|
||||
|
||||
// Reset if needed and is not computed and internal
|
||||
return if (allowReset && !(isComputed && isInternal) && trackerDataType == TrackerDataType.ROTATION) {
|
||||
// Adjust to reset, mounting and drift compensation
|
||||
resetsHandler.getReferenceAdjustedDriftRotationFrom(rot)
|
||||
// Adjust to reset and mounting
|
||||
resetsHandler.getReferenceAdjustedRotationFrom(rot)
|
||||
} else {
|
||||
rot
|
||||
}
|
||||
@@ -326,7 +314,7 @@ class Tracker @JvmOverloads constructor(
|
||||
|
||||
/**
|
||||
* Gets the identity-adjusted tracker rotation after the resetsHandler's corrections
|
||||
* (identity reset, drift and identity mounting).
|
||||
* (identity reset and identity mounting).
|
||||
* This is used for debugging/visualizing tracker data
|
||||
*/
|
||||
fun getIdentityAdjustedRotation(): Quaternion {
|
||||
@@ -340,7 +328,7 @@ class Tracker @JvmOverloads constructor(
|
||||
// Reset if needed or is a computed tracker besides head
|
||||
return if (allowReset && !(isComputed && trackerPosition != TrackerPosition.HEAD) && trackerDataType == TrackerDataType.ROTATION) {
|
||||
// Adjust to reset and mounting
|
||||
resetsHandler.getIdentityAdjustedDriftRotationFrom(rot)
|
||||
resetsHandler.getIdentityAdjustedRotationFrom(rot)
|
||||
} else {
|
||||
rot
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package dev.slimevr.tracking.trackers
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
import dev.slimevr.VRServer
|
||||
import dev.slimevr.config.ArmsResetModes
|
||||
import dev.slimevr.config.DriftCompensationConfig
|
||||
import dev.slimevr.config.ResetsConfig
|
||||
import dev.slimevr.filtering.CircularArrayList
|
||||
import dev.slimevr.tracking.trackers.udp.TrackerDataType
|
||||
import io.github.axisangles.ktmath.EulerAngles
|
||||
import io.github.axisangles.ktmath.EulerOrder
|
||||
@@ -13,9 +10,7 @@ import io.github.axisangles.ktmath.Quaternion
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import kotlin.math.*
|
||||
|
||||
private const val DRIFT_COOLDOWN_MS = 50000L
|
||||
|
||||
/** Class taking care of full reset, yaw reset, mounting reset, and drift compensation logic. */
|
||||
/** Class taking care of full reset, yaw reset, and mounting reset logic. */
|
||||
class TrackerResetsHandler(val tracker: Tracker) {
|
||||
|
||||
private val HalfHorizontal = EulerAngles(
|
||||
@@ -26,22 +21,10 @@ class TrackerResetsHandler(val tracker: Tracker) {
|
||||
).toQuaternion()
|
||||
private val QuarterPitch = Quaternion.rotationAroundXAxis(FastMath.HALF_PI)
|
||||
|
||||
private var driftAmount = 0f
|
||||
private var averagedDriftQuat = Quaternion.IDENTITY
|
||||
private var rotationSinceReset = Quaternion.IDENTITY
|
||||
private var driftQuats = CircularArrayList<Quaternion>(0)
|
||||
private var driftTimes = CircularArrayList<Long>(0)
|
||||
private var totalDriftTime: Long = 0
|
||||
private var driftSince: Long = 0
|
||||
private var timeAtLastReset: Long = 0
|
||||
private var compensateDrift = false
|
||||
private var driftPrediction = false
|
||||
private var driftCompensationEnabled = false
|
||||
private var armsResetMode = ArmsResetModes.BACK
|
||||
private var yawResetSmoothTime = 0.0f
|
||||
var saveMountingReset = false
|
||||
var resetHmdPitch = false
|
||||
var allowDriftCompensation = false
|
||||
var lastResetQuaternion: Quaternion? = null
|
||||
|
||||
// Manual mounting orientation
|
||||
@@ -108,47 +91,6 @@ class TrackerResetsHandler(val tracker: Tracker) {
|
||||
*/
|
||||
private var tposeDownFix = Quaternion.IDENTITY
|
||||
|
||||
/**
|
||||
* Reads/loads drift compensation settings from given config
|
||||
*/
|
||||
fun readDriftCompensationConfig(config: DriftCompensationConfig) {
|
||||
compensateDrift = false
|
||||
driftPrediction = config.prediction
|
||||
driftAmount = config.amount
|
||||
val maxResets = config.maxResets
|
||||
|
||||
if (compensateDrift && maxResets != driftQuats.capacity()) {
|
||||
driftQuats = CircularArrayList<Quaternion>(maxResets)
|
||||
driftTimes = CircularArrayList<Long>(maxResets)
|
||||
}
|
||||
|
||||
refreshDriftCompensationEnabled()
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears drift compensation data
|
||||
*/
|
||||
fun clearDriftCompensation() {
|
||||
driftSince = 0L
|
||||
timeAtLastReset = 0L
|
||||
totalDriftTime = 0L
|
||||
driftQuats.clear()
|
||||
driftTimes.clear()
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for compensateDrift, allowDriftCompensation, and if
|
||||
* a computed head tracker exists.
|
||||
*/
|
||||
fun refreshDriftCompensationEnabled() {
|
||||
driftCompensationEnabled = compensateDrift &&
|
||||
allowDriftCompensation &&
|
||||
TrackerUtils.getNonInternalNonImuTrackerForBodyPosition(
|
||||
VRServer.instance.allTrackers,
|
||||
TrackerPosition.HEAD,
|
||||
) != null
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads/loads reset settings from the given config
|
||||
*/
|
||||
@@ -166,16 +108,16 @@ class TrackerResetsHandler(val tracker: Tracker) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a rotation and adjusts it to resets, mounting,
|
||||
* and drift compensation, with the HMD as the reference.
|
||||
* Takes a rotation and adjusts it to resets and mounting with the HMD as the
|
||||
* reference.
|
||||
*/
|
||||
fun getReferenceAdjustedDriftRotationFrom(rotation: Quaternion): Quaternion = adjustToDrift(adjustToReference(rotation))
|
||||
fun getReferenceAdjustedRotationFrom(rotation: Quaternion): Quaternion = adjustToReference(rotation)
|
||||
|
||||
/**
|
||||
* Takes a rotation and adjusts it to resets and mounting,
|
||||
* with the identity Quaternion as the reference.
|
||||
*/
|
||||
fun getIdentityAdjustedDriftRotationFrom(rotation: Quaternion): Quaternion = adjustToDrift(adjustToIdentity(rotation))
|
||||
fun getIdentityAdjustedRotationFrom(rotation: Quaternion): Quaternion = adjustToIdentity(rotation)
|
||||
|
||||
/**
|
||||
* Get the reference adjusted accel.
|
||||
@@ -220,21 +162,6 @@ class TrackerResetsHandler(val tracker: Tracker) {
|
||||
return rot
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjust the given rotation for drift compensation if enabled,
|
||||
* and returns it
|
||||
*/
|
||||
private fun adjustToDrift(rotation: Quaternion): Quaternion {
|
||||
if (driftCompensationEnabled && totalDriftTime > 0) {
|
||||
var driftTimeRatio = ((System.currentTimeMillis() - driftSince).toFloat() / totalDriftTime)
|
||||
if (!driftPrediction) {
|
||||
driftTimeRatio = min(1.0f, driftTimeRatio)
|
||||
}
|
||||
return averagedDriftQuat.pow(driftAmount * driftTimeRatio) * rotation
|
||||
}
|
||||
return rotation
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the tracker so that its current rotation is counted as (0, HMD Yaw,
|
||||
* 0). This allows the tracker to be strapped to body at any pitch and roll.
|
||||
@@ -260,9 +187,8 @@ class TrackerResetsHandler(val tracker: Tracker) {
|
||||
Quaternion.IDENTITY
|
||||
}
|
||||
|
||||
// Old rot for drift compensation
|
||||
val oldRot = adjustToReference(tracker.getRawRotation())
|
||||
lastResetQuaternion = oldRot
|
||||
// Old rot for drift logging
|
||||
lastResetQuaternion = adjustToReference(tracker.getRawRotation())
|
||||
|
||||
// Adjust raw rotation to mountingOrientation
|
||||
val rotation = tracker.getRawRotation()
|
||||
@@ -312,15 +238,13 @@ class TrackerResetsHandler(val tracker: Tracker) {
|
||||
attachmentFix *= HalfHorizontal
|
||||
}
|
||||
|
||||
makeIdentityAdjustmentQuatsFull()
|
||||
|
||||
// Don't adjust yaw if head and computed
|
||||
if (tracker.trackerPosition != TrackerPosition.HEAD || !tracker.isComputed) {
|
||||
yawFix = gyroFix * reference.project(Vector3.POS_Y).unit()
|
||||
tracker.yawResetSmoothing.reset()
|
||||
}
|
||||
|
||||
calculateDrift(oldRot)
|
||||
makeIdentityAdjustmentQuatsFull()
|
||||
|
||||
// Reset Stay Aligned (before resetting filtering, which depends on the
|
||||
// tracker's rotation)
|
||||
@@ -355,9 +279,8 @@ class TrackerResetsHandler(val tracker: Tracker) {
|
||||
return
|
||||
}
|
||||
|
||||
// Old rot for drift compensation
|
||||
val oldRot = adjustToReference(tracker.getRawRotation())
|
||||
lastResetQuaternion = oldRot
|
||||
// Old rot for drift logging
|
||||
lastResetQuaternion = adjustToReference(tracker.getRawRotation())
|
||||
|
||||
val yawFixOld = yawFix
|
||||
yawFix = fixYaw(tracker.getRawRotation(), reference)
|
||||
@@ -365,8 +288,6 @@ class TrackerResetsHandler(val tracker: Tracker) {
|
||||
|
||||
makeIdentityAdjustmentQuatsYaw()
|
||||
|
||||
calculateDrift(oldRot)
|
||||
|
||||
// Start at yaw before reset if smoothing enabled
|
||||
if (yawResetSmoothTime > 0.0f) {
|
||||
tracker.yawResetSmoothing.interpolate(
|
||||
@@ -399,7 +320,7 @@ class TrackerResetsHandler(val tracker: Tracker) {
|
||||
constraintFix = Quaternion.IDENTITY
|
||||
|
||||
// Get the current calibrated rotation
|
||||
var rotBuf = adjustToDrift(tracker.getRawRotation())
|
||||
var rotBuf = tracker.getRawRotation()
|
||||
rotBuf *= attachmentFix
|
||||
rotBuf = mountingOrientation.inv() * rotBuf * mountingOrientation
|
||||
rotBuf = yawFix * rotBuf
|
||||
@@ -498,100 +419,4 @@ class TrackerResetsHandler(val tracker: Tracker) {
|
||||
sensorRotation *= attachmentFixNoMounting
|
||||
yawFixZeroReference = fixGyroscope(sensorRotation)
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates drift since last reset and store the data related to it in
|
||||
* driftQuat and timeAtLastReset
|
||||
*/
|
||||
private fun calculateDrift(beforeQuat: Quaternion) {
|
||||
if (driftCompensationEnabled) {
|
||||
val rotQuat = adjustToReference(tracker.getRawRotation())
|
||||
|
||||
if (driftSince > 0 && System.currentTimeMillis() - timeAtLastReset > DRIFT_COOLDOWN_MS) {
|
||||
// Check and remove from lists to keep them under the reset limit
|
||||
if (driftQuats.size == driftQuats.capacity()) {
|
||||
driftQuats.removeLast()
|
||||
driftTimes.removeLast()
|
||||
}
|
||||
|
||||
// Add new drift quaternion
|
||||
driftQuats.add(getYawQuaternion(rotQuat) / getYawQuaternion(beforeQuat))
|
||||
|
||||
// Add drift time to total
|
||||
driftTimes.add(System.currentTimeMillis() - driftSince)
|
||||
totalDriftTime = 0
|
||||
for (time in driftTimes) {
|
||||
totalDriftTime += time
|
||||
}
|
||||
|
||||
// Calculate drift Quaternions' weights
|
||||
val driftWeights = ArrayList<Float>(driftTimes.size)
|
||||
for (time in driftTimes) {
|
||||
driftWeights.add(time.toFloat() / totalDriftTime.toFloat())
|
||||
}
|
||||
|
||||
// Make it so recent Quaternions weigh more
|
||||
for (i in driftWeights.size - 1 downTo 1) {
|
||||
// Add some of i-1's value to i
|
||||
driftWeights[i] = driftWeights[i] + driftWeights[i - 1] / driftWeights.size
|
||||
// Remove the value that was added to i from i-1
|
||||
driftWeights[i - 1] = driftWeights[i - 1] - driftWeights[i - 1] / driftWeights.size
|
||||
}
|
||||
|
||||
// Set final averaged drift Quaternion
|
||||
averagedDriftQuat = fromAveragedQuaternions(driftQuats, driftWeights)
|
||||
|
||||
// Save tracker rotation and current time
|
||||
rotationSinceReset = driftQuats.latest
|
||||
timeAtLastReset = System.currentTimeMillis()
|
||||
} else if (System.currentTimeMillis() - timeAtLastReset < DRIFT_COOLDOWN_MS && driftQuats.size > 0) {
|
||||
// Replace latest drift quaternion
|
||||
rotationSinceReset *= (getYawQuaternion(rotQuat) / getYawQuaternion(beforeQuat))
|
||||
driftQuats[driftQuats.size - 1] = rotationSinceReset
|
||||
|
||||
// Add drift time to total
|
||||
driftTimes[driftTimes.size - 1] = driftTimes.latest + System.currentTimeMillis() - driftSince
|
||||
totalDriftTime = 0
|
||||
for (time in driftTimes) {
|
||||
totalDriftTime += time
|
||||
}
|
||||
|
||||
// Calculate drift Quaternions' weights
|
||||
val driftWeights = ArrayList<Float>(driftTimes.size)
|
||||
for (time in driftTimes) {
|
||||
driftWeights.add(time.toFloat() / totalDriftTime.toFloat())
|
||||
}
|
||||
|
||||
// Make it so recent Quaternions weigh more
|
||||
for (i in driftWeights.size - 1 downTo 1) {
|
||||
// Add some of i-1's value to i
|
||||
driftWeights[i] = driftWeights[i] + driftWeights[i - 1] / driftWeights.size
|
||||
// Remove the value that was added to i from i-1
|
||||
driftWeights[i - 1] = driftWeights[i - 1] - driftWeights[i - 1] / driftWeights.size
|
||||
}
|
||||
|
||||
// Set final averaged drift Quaternion
|
||||
averagedDriftQuat = fromAveragedQuaternions(driftQuats, driftWeights)
|
||||
} else {
|
||||
timeAtLastReset = System.currentTimeMillis()
|
||||
}
|
||||
|
||||
driftSince = System.currentTimeMillis()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates and returns the averaged Quaternion
|
||||
* from the given Quaternions and weights.
|
||||
*/
|
||||
private fun fromAveragedQuaternions(
|
||||
qn: CircularArrayList<Quaternion>,
|
||||
tn: ArrayList<Float>,
|
||||
): Quaternion {
|
||||
var totalMatrix = qn[0].toMatrix() * tn[0]
|
||||
for (i in 1 until qn.size) {
|
||||
totalMatrix += (qn[i].toMatrix() * tn[i])
|
||||
}
|
||||
return totalMatrix.toQuaternion()
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ class HIDCommon {
|
||||
companion object {
|
||||
const val HID_TRACKER_RECEIVER_VID = 0x1209
|
||||
const val HID_TRACKER_RECEIVER_PID = 0x7690
|
||||
const val HID_TRACKER_PID = 0x7692
|
||||
|
||||
const val PACKET_SIZE = 16
|
||||
|
||||
@@ -138,11 +139,13 @@ class HIDCommon {
|
||||
}
|
||||
|
||||
// Packet data
|
||||
var runtime: Long? = null
|
||||
var batt: Int? = null
|
||||
var batt_v: Int? = null
|
||||
var temp: Int? = null
|
||||
var brd_id: Int? = null
|
||||
var mcu_id: Int? = null
|
||||
var button: Int? = null
|
||||
// var imu_id: Int? = null
|
||||
// var mag_id: Int? = null
|
||||
var fw_date: Int? = null
|
||||
@@ -220,11 +223,42 @@ class HIDCommon {
|
||||
}
|
||||
}
|
||||
|
||||
5 -> { // runtime
|
||||
// ulong as little endian
|
||||
runtime = (dataReceived[i + 9].toUByte().toLong() shl 56) or (dataReceived[i + 8].toUByte().toLong() shl 48) or (dataReceived[i + 7].toUByte().toLong() shl 40) or (dataReceived[i + 6].toUByte().toLong() shl 32) or (dataReceived[i + 5].toUByte().toLong() shl 24) or (dataReceived[i + 4].toUByte().toLong() shl 16) or (dataReceived[i + 3].toUByte().toLong() shl 8) or dataReceived[i + 2].toUByte().toLong()
|
||||
}
|
||||
|
||||
6 -> { // data
|
||||
button = dataReceived[i + 2].toUByte().toInt()
|
||||
rssi = dataReceived[i + 15].toUByte().toInt()
|
||||
}
|
||||
|
||||
7 -> { // reduced precision quat and accel with data
|
||||
button = dataReceived[i + 2].toUByte().toInt()
|
||||
// quaternion is quantized as exponential map
|
||||
// X = 10 bits, Y/Z = 11 bits
|
||||
val buffer = ByteBuffer.wrap(dataReceived, i + 5, 4)
|
||||
buffer.order(java.nio.ByteOrder.LITTLE_ENDIAN)
|
||||
val q_buf = buffer.getInt().toUInt()
|
||||
q[0] = (q_buf and 1023u).toInt()
|
||||
q[1] = (q_buf shr 10 and 2047u).toInt()
|
||||
q[2] = (q_buf shr 21 and 2047u).toInt()
|
||||
for (j in 0..2) { // accel received as fixed 7, in m/s^2
|
||||
// Q7 as short little endian
|
||||
a[j] = dataReceived[i + 9 + j * 2 + 1].toInt() shl 8 or dataReceived[i + 9 + j * 2].toUByte().toInt()
|
||||
}
|
||||
rssi = dataReceived[i + 15].toUByte().toInt()
|
||||
}
|
||||
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
|
||||
// Assign data
|
||||
if (runtime != null && runtime >= 0) {
|
||||
tracker.batteryRemainingRuntime = runtime
|
||||
}
|
||||
// -1: Not known (e.g. not yet calculated after wake up, reusing known value is okay), 0: N/A (e.g. charging)
|
||||
if (batt != null) {
|
||||
tracker.batteryLevel = if (batt == 128) 1f else (batt and 127).toFloat()
|
||||
}
|
||||
@@ -248,12 +282,23 @@ class HIDCommon {
|
||||
device.mcuType = mcuType!!
|
||||
}
|
||||
}
|
||||
if (fw_date != null && fw_major != null && fw_minor != null && fw_patch != null) {
|
||||
if (button != null) {
|
||||
if (tracker.button == null) {
|
||||
tracker.button = 0
|
||||
}
|
||||
if (button != tracker.button) {
|
||||
button = button and tracker.button!!.inv()
|
||||
// Nothing to do now..
|
||||
}
|
||||
}
|
||||
if (fw_date != null) {
|
||||
val firmwareYear = 2020 + (fw_date shr 9 and 127)
|
||||
val firmwareMonth = fw_date shr 5 and 15
|
||||
val firmwareDay = fw_date and 31
|
||||
val firmwareDate = String.format("%04d-%02d-%02d", firmwareYear, firmwareMonth, firmwareDay)
|
||||
device.firmwareVersion = "$fw_major.$fw_minor.$fw_patch (Build $firmwareDate)"
|
||||
device.firmwareDate = String.format("%04d-%02d-%02d", firmwareYear, firmwareMonth, firmwareDay)
|
||||
}
|
||||
if (fw_major != null && fw_minor != null && fw_patch != null) {
|
||||
device.firmwareVersion = "$fw_major.$fw_minor.$fw_patch"
|
||||
}
|
||||
if (svr_status != null) {
|
||||
val status = TrackerStatus.getById(svr_status)
|
||||
@@ -274,7 +319,7 @@ class HIDCommon {
|
||||
rot = AXES_OFFSET.times(scaleRot).times(rot) // no division
|
||||
tracker.setRotation(rot)
|
||||
}
|
||||
if (packetType == 2) {
|
||||
if (packetType == 2 || packetType == 7) {
|
||||
val v = floatArrayOf(q[0].toFloat(), q[1].toFloat(), q[2].toFloat()) // used q array for quantized data
|
||||
v[0] /= (1 shl 10).toFloat()
|
||||
v[1] /= (1 shl 11).toFloat()
|
||||
@@ -293,7 +338,7 @@ class HIDCommon {
|
||||
rot = AXES_OFFSET.times(rot) // no division
|
||||
tracker.setRotation(rot)
|
||||
}
|
||||
if (packetType == 1 || packetType == 2) {
|
||||
if (packetType == 1 || packetType == 2 || packetType == 7) {
|
||||
// Acceleration is in local device frame
|
||||
// On flat surface / face up:
|
||||
// Right side of the device is +X
|
||||
@@ -317,7 +362,7 @@ class HIDCommon {
|
||||
val magnetometer = Vector3(m[0].toFloat(), m[1].toFloat(), m[2].toFloat()).times(scaleMag) // no division
|
||||
tracker.setMagVector(magnetometer)
|
||||
}
|
||||
if (packetType == 1 || packetType == 2 || packetType == 4) {
|
||||
if (packetType == 1 || packetType == 2 || packetType == 4 || packetType == 7) {
|
||||
tracker.dataTick() // only data tick if there is rotation data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,9 @@ enum class BoardType(val id: UInt) {
|
||||
GESTURES(21u),
|
||||
SLIMEVR_V1_2(22u),
|
||||
ESP32S3_SUPERMINI(23u),
|
||||
GENERIC_NRF(24u),
|
||||
SLIMEVR_BUTTERFLY_DEV(25u),
|
||||
SLIMEVR_BUTTERFLY(26u),
|
||||
DEV_RESERVED(250u),
|
||||
;
|
||||
|
||||
@@ -88,6 +91,9 @@ enum class BoardType(val id: UInt) {
|
||||
GLOVE_IMU_SLIMEVR_DEV -> "SlimeVR Dev IMU Glove"
|
||||
SLIMEVR_V1_2 -> "SlimeVR v1.2"
|
||||
ESP32S3_SUPERMINI -> "ESP32-S3 SuperMini"
|
||||
GENERIC_NRF -> "Generic nRF"
|
||||
SLIMEVR_BUTTERFLY_DEV -> "SlimeVR Dev Butterfly"
|
||||
SLIMEVR_BUTTERFLY -> "SlimeVR Butterfly"
|
||||
DEV_RESERVED -> "Prototype"
|
||||
}
|
||||
|
||||
@@ -109,6 +115,8 @@ enum class MCUType(val id: UInt) {
|
||||
ESP32_C3(6u),
|
||||
MOCOPI(7u),
|
||||
HARITORA(8u),
|
||||
NRF52(9u),
|
||||
NRF54L(10u),
|
||||
DEV_RESERVED(250u),
|
||||
;
|
||||
|
||||
|
||||
@@ -397,7 +397,9 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
} finally {
|
||||
Util.close(socket)
|
||||
if (::socket.isInitialized) {
|
||||
Util.close(socket)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -415,9 +417,13 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
if (tracker == null) return
|
||||
tracker.setRotation(rot)
|
||||
if (packet is UDPPacket23RotationAndAcceleration) {
|
||||
// If sensorOffset was applied to accel correctly, the axes will already
|
||||
// be correct for SlimeVR
|
||||
tracker.setAcceleration(SENSOR_OFFSET_CORRECTION.sandwich(packet.acceleration))
|
||||
// sensorOffset is applied correctly since protocol 22
|
||||
// See: https://github.com/SlimeVR/SlimeVR-Tracker-ESP/pull/480
|
||||
if (connection.protocolVersion >= 22) {
|
||||
tracker.setAcceleration(packet.acceleration)
|
||||
} else {
|
||||
tracker.setAcceleration(SENSOR_OFFSET_CORRECTION.sandwich(packet.acceleration))
|
||||
}
|
||||
}
|
||||
tracker.dataTick()
|
||||
}
|
||||
@@ -449,9 +455,13 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
is UDPPacket4Acceleration -> {
|
||||
tracker = connection?.getTracker(packet.sensorId)
|
||||
if (tracker == null) return
|
||||
// If sensorOffset was applied to accel correctly, the axes will already
|
||||
// be correct for SlimeVR
|
||||
tracker.setAcceleration(SENSOR_OFFSET_CORRECTION.sandwich(packet.acceleration))
|
||||
// sensorOffset is applied correctly since protocol 22
|
||||
// See: https://github.com/SlimeVR/SlimeVR-Tracker-ESP/pull/480
|
||||
if (connection.protocolVersion >= 22) {
|
||||
tracker.setAcceleration(packet.acceleration)
|
||||
} else {
|
||||
tracker.setAcceleration(SENSOR_OFFSET_CORRECTION.sandwich(packet.acceleration))
|
||||
}
|
||||
}
|
||||
|
||||
is UDPPacket10PingPong -> {
|
||||
|
||||
@@ -3,6 +3,7 @@ package dev.slimevr.websocketapi;
|
||||
import dev.slimevr.protocol.ConnectionContext;
|
||||
import dev.slimevr.protocol.GenericConnection;
|
||||
import org.java_websocket.WebSocket;
|
||||
import org.java_websocket.exceptions.WebsocketNotConnectedException;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.UUID;
|
||||
@@ -27,8 +28,13 @@ public class WebsocketConnection implements GenericConnection {
|
||||
|
||||
@Override
|
||||
public void send(ByteBuffer bytes) {
|
||||
if (this.conn.isOpen())
|
||||
this.conn.send(bytes.slice());
|
||||
if (this.conn.isOpen()) {
|
||||
try {
|
||||
this.conn.send(bytes.slice());
|
||||
} catch (WebsocketNotConnectedException ignored) {
|
||||
// Race condition if it closes between our check and sending
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+28
-5
@@ -1,9 +1,12 @@
|
||||
package dev.slimevr.desktop.tracking.trackers.hid
|
||||
|
||||
import dev.slimevr.VRServer
|
||||
import dev.slimevr.config.config
|
||||
import dev.slimevr.tracking.trackers.Device
|
||||
import dev.slimevr.tracking.trackers.Tracker
|
||||
import dev.slimevr.tracking.trackers.TrackerStatus
|
||||
import dev.slimevr.tracking.trackers.hid.HIDCommon
|
||||
import dev.slimevr.tracking.trackers.hid.HIDCommon.Companion.HID_TRACKER_PID
|
||||
import dev.slimevr.tracking.trackers.hid.HIDCommon.Companion.HID_TRACKER_RECEIVER_PID
|
||||
import dev.slimevr.tracking.trackers.hid.HIDCommon.Companion.HID_TRACKER_RECEIVER_VID
|
||||
import dev.slimevr.tracking.trackers.hid.HIDCommon.Companion.PACKET_SIZE
|
||||
@@ -55,12 +58,15 @@ class DesktopHIDManager(name: String, private val trackersConsumer: Consumer<Tra
|
||||
}
|
||||
|
||||
private fun checkConfigureDevice(hidDevice: HidDevice) {
|
||||
if (hidDevice.vendorId == HID_TRACKER_RECEIVER_VID && hidDevice.productId == HID_TRACKER_RECEIVER_PID) { // TODO: Use correct ids
|
||||
if (hidDevice.vendorId == HID_TRACKER_RECEIVER_VID && (hidDevice.productId == HID_TRACKER_RECEIVER_PID || hidDevice.productId == HID_TRACKER_PID)) { // TODO: Use list of valid ids
|
||||
val serial = hidDevice.serialNumber ?: "Unknown HID Device"
|
||||
if (hidDevice.isClosed) {
|
||||
check(hidDevice.open()) { "Unable to open device" }
|
||||
if (!hidDevice.open()) {
|
||||
LogManager.warning("[TrackerServer] Unable to open device: $serial")
|
||||
return
|
||||
}
|
||||
}
|
||||
// TODO: Configure the device here
|
||||
val serial = hidDevice.serialNumber ?: "Unknown HID Device"
|
||||
// val product = hidDevice.product
|
||||
// val manufacturer = hidDevice.manufacturer
|
||||
this.devicesBySerial[serial]?.let {
|
||||
@@ -205,12 +211,29 @@ class DesktopHIDManager(name: String, private val trackersConsumer: Consumer<Tra
|
||||
}
|
||||
|
||||
private fun deviceEnumerate() {
|
||||
var root: HidDeviceInfoStructure? = null
|
||||
var rootReceivers: HidDeviceInfoStructure? = null
|
||||
var rootTrackers: HidDeviceInfoStructure? = null
|
||||
val trackersOverHID: Boolean = VRServer.instance.configManager.vrConfig.hidConfig.trackersOverHID
|
||||
try {
|
||||
root = HidApi.enumerateDevices(HID_TRACKER_RECEIVER_VID, HID_TRACKER_RECEIVER_PID) // TODO: change to proper vendorId and productId, need to enum all appropriate productId
|
||||
rootReceivers = HidApi.enumerateDevices(HID_TRACKER_RECEIVER_VID, HID_TRACKER_RECEIVER_PID) // TODO: Use list of ids
|
||||
rootTrackers = if (trackersOverHID) {
|
||||
HidApi.enumerateDevices(HID_TRACKER_RECEIVER_VID, HID_TRACKER_PID)
|
||||
} else {
|
||||
null
|
||||
} // TODO: Use list of ids
|
||||
} catch (e: Throwable) {
|
||||
LogManager.severe("[TrackerServer] Couldn't enumerate HID devices", e)
|
||||
}
|
||||
var root: HidDeviceInfoStructure? = rootReceivers
|
||||
if (root == null) {
|
||||
root = rootTrackers
|
||||
} else {
|
||||
var last: HidDeviceInfoStructure = root
|
||||
while (last.hasNext()) {
|
||||
last = last.next()
|
||||
}
|
||||
last.next = rootTrackers
|
||||
}
|
||||
val hidDeviceList: MutableList<HidDevice> = mutableListOf()
|
||||
if (root != null) {
|
||||
var hidDeviceInfoStructure: HidDeviceInfoStructure? = root
|
||||
|
||||
+1
-1
Submodule solarxr-protocol updated: b0147eeffa...cb151b36a3.
Reference in new issue
Block a user