mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-06 08:42:32 -08:00
Compare commits
34
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62188a8473 | ||
|
|
dbae1e27eb | ||
|
|
e27df69a04 | ||
|
|
d09ad6e18d | ||
|
|
0ebf7be578 | ||
|
|
64261eee6e | ||
|
|
23aa47fc6c | ||
|
|
02e2a00e4f | ||
|
|
aa9fdbe9ee | ||
|
|
4869a5fdfa | ||
|
|
be8eb4ff80 | ||
|
|
49016f4ca3 | ||
|
|
b81fa39499 | ||
|
|
8750da0855 | ||
|
|
6232492ffb | ||
|
|
0f649034a7 | ||
|
|
1f44744e2b | ||
|
|
cc803b59e3 | ||
|
|
70e41f113f | ||
|
|
fb3af2a9f1 | ||
|
|
476d81584d | ||
|
|
9937b42c46 | ||
|
|
a0f6bbfd92 | ||
|
|
06a54e106e | ||
|
|
39b57e770c | ||
|
|
6b28bb1a71 | ||
|
|
c151f1d2fa | ||
|
|
f31fd48f73 | ||
|
|
48255272d2 | ||
|
|
e4b0d0a58e | ||
|
|
ae9efb1a92 | ||
|
|
0368292bf1 | ||
|
|
d55c0ef494 | ||
|
|
7bc6d99f09 |
No files matched your search
@@ -207,6 +207,8 @@ jobs:
|
||||
- name: Run Electron Builder
|
||||
shell: bash
|
||||
run: |
|
||||
set -eo pipefail
|
||||
|
||||
mkdir -p gui/electron/dist/artifacts/linux/ \
|
||||
gui/electron/dist/artifacts/win \
|
||||
gui/electron/dist/artifacts/mac
|
||||
@@ -215,11 +217,51 @@ jobs:
|
||||
VERSION="${VERSION#v}"
|
||||
echo "Building version: $VERSION"
|
||||
pnpm i
|
||||
cd gui/electron
|
||||
pnpm exec electron-builder --${{ matrix.platform }} \
|
||||
cd "${{ github.workspace }}/gui/electron"
|
||||
|
||||
COMMON_ELECTRON_BUILDER_ARGS=(--config.extraMetadata.version="$VERSION" --publish never)
|
||||
# If Linux, build rpm and deb before AppImage (so we don't bundle jre for system packages)
|
||||
pnpm exec electron-builder --${{ matrix.platform }} \
|
||||
${{ matrix.platform == 'macos' && '--universal' || '' }} \
|
||||
--config.extraMetadata.version="$VERSION" \
|
||||
--publish never
|
||||
${{ matrix.platform == 'linux' && 'rpm deb' || ''}} \
|
||||
${COMMON_ELECTRON_BUILDER_ARGS[@]}
|
||||
|
||||
# Fetch JRE from Adoptium and build AppImage
|
||||
# We have to do this afterward because electron-builder does not have a mechanism to
|
||||
# only include a file in extraFiles for a specific target (i.e. only for AppImage)
|
||||
if [[ "${{ matrix.platform }}" == linux ]]; then
|
||||
pushd resources
|
||||
|
||||
# Fetch JRE from Adoptium
|
||||
JRE_ARCHITECTURE="${{ endsWith(matrix.os, '-arm') && 'aarch64' || 'x64' }}"
|
||||
LATEST_JRE_INFO="$(curl -f "https://api.adoptium.net/v3/assets/latest/25/hotspot?architecture=$JRE_ARCHITECTURE&image_type=jre&os=linux&vendor=eclipse")"
|
||||
|
||||
JRE_VERSION="$(echo "$LATEST_JRE_INFO" | jq -r '.[0].release_name')"
|
||||
JRE_ARCHIVE_URL="$(echo "$LATEST_JRE_INFO" | jq -r '.[0].binary.package.link')"
|
||||
JRE_ARCHIVE_NAME="$(echo "$LATEST_JRE_INFO" | jq -r '.[0].binary.package.name')"
|
||||
EXPECTED_JRE_ARCHIVE_CHECKSUM="$(echo "$LATEST_JRE_INFO" | jq -r '.[0].binary.package.checksum')"
|
||||
echo "Downloading Adoptium Eclipse JRE version $JRE_VERSION ($JRE_ARCHIVE_URL)"
|
||||
|
||||
# Make sure name is not a weird relative path
|
||||
[[ "$(dirname "$(realpath "$JRE_ARCHIVE_NAME")")" != "$(pwd)" ]] && { echo "JRE archive name is a weird path, refusing to continue" >&2; exit 1; }
|
||||
# Same with version
|
||||
[[ "$(dirname "$(realpath "$JRE_VERSION")")" != "$(pwd)" ]] && { echo "JRE version is a weird path, refusing to continue" >&2; exit 1; }
|
||||
|
||||
curl -Lf "$JRE_ARCHIVE_URL" -O
|
||||
[[ ! -f "$JRE_ARCHIVE_NAME" ]] && { echo "JRE archive does not exist with filename $JRE_ARCHIVE_NAME" >&2; exit 1; }
|
||||
|
||||
# Make sure checksum matches
|
||||
JRE_ARCHIVE_CHECKSUM="$(sha256sum "$JRE_ARCHIVE_NAME" | cut -d' ' -f1)"
|
||||
[[ "$JRE_ARCHIVE_CHECKSUM" != "$EXPECTED_JRE_ARCHIVE_CHECKSUM" ]] && { echo "JRE checksum does not match ($JRE_ARCHIVE_CHECKSUM != $EXPECTED_JRE_ARCHIVE_CHECKSUM)" >&2; exit 1; }
|
||||
|
||||
tar -xzf "$JRE_ARCHIVE_NAME"
|
||||
mv "${JRE_VERSION}-jre" jre
|
||||
|
||||
popd
|
||||
|
||||
# Now run AppImage build
|
||||
pnpm exec electron-builder --${{ matrix.platform }} appimage ${COMMON_ELECTRON_BUILDER_ARGS[@]}
|
||||
fi
|
||||
- name: Collect and Rename Artifacts
|
||||
shell: bash
|
||||
run: |
|
||||
|
||||
+5
-4
@@ -7,8 +7,9 @@ This document describes essential knowledge required to contribute to the SlimeV
|
||||
### Prerequisites
|
||||
|
||||
- [Git](https://git-scm.com/downloads)
|
||||
- [Java v17+](https://adoptium.net/temurin/releases/)
|
||||
- [Node.js v16.9+](https://nodejs.org) (We recommend the use of `nvm` instead of installing Node.js directly)
|
||||
- [Java v25](https://adoptium.net/temurin/releases/)
|
||||
- [Node.js v24+](https://nodejs.org) (We recommend the use of `nvm` instead of installing Node.js directly)
|
||||
- [pnpm](https://pnpm.io/installation)
|
||||
|
||||
## Cloning the code
|
||||
First, clone the codebase using git in a terminal in the folder you want.
|
||||
@@ -36,13 +37,13 @@ be at `server/desktop/build/libs/slimevr.jar` (you can ignore `server.jar`).
|
||||
|
||||
### Electron (gui)
|
||||
|
||||
- Activate corepack (included with Node.js) via `corepack enable`
|
||||
- Activate corepack (included with Node.js) via `corepack enable`
|
||||
(might require launching Git Bash as administrator on Windows)
|
||||
- Make sure you're at the root of the repository.
|
||||
- Run `pnpm i` in your IDE's terminal to download and install dependencies.
|
||||
- To launch the GUI in dev mode, run `pnpm gui`.
|
||||
- If you get an "Electron uninstall" error, run `node .\gui\electron\node_modules\electron\install.js`.
|
||||
- Finally, to compile for production, run `pnpm package:build` under `gui/electron`.
|
||||
- Finally, to compile for production, run `pnpm package:build` under `gui/electron`.
|
||||
The result will be in `gui/dist/artifacts/`. Content will change depending on the platform.
|
||||
|
||||
## Code style
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
#include <tuple>
|
||||
|
||||
// These must be included before Windows.h because of some macro collisions.
|
||||
#include "flatbuffers/flatbuffers.h"
|
||||
#include "solarxr_protocol/generated/all_generated.h"
|
||||
#include <solarxr_protocol/generated/all_generated.h>
|
||||
|
||||
#include "bridge/BridgeClient.hpp"
|
||||
#include "logger.hpp"
|
||||
@@ -19,7 +18,7 @@
|
||||
#define NOMINMAX
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <cstdlib>
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
@@ -216,8 +215,18 @@ int main() {
|
||||
|
||||
constexpr auto interval = 1000ms / 30;
|
||||
|
||||
// Install signal handlers.
|
||||
// Windows does not provide sigaction
|
||||
#ifdef _WIN32
|
||||
signal(SIGINT, OnSignal);
|
||||
signal(SIGTERM, OnSignal);
|
||||
#else
|
||||
struct sigaction action{};
|
||||
action.sa_handler = OnSignal;
|
||||
sigaction(SIGINT, &action, nullptr);
|
||||
sigaction(SIGTERM, &action, nullptr);
|
||||
#endif
|
||||
|
||||
while (!should_exit) {
|
||||
vr::VREvent_t event{};
|
||||
while (sys->PollNextEvent(&event, sizeof(event))) {
|
||||
|
||||
@@ -242,10 +242,10 @@ reset-mounting-feet = Feet Calibration
|
||||
reset-mounting-toes = Toes Calibration
|
||||
reset-mounting-fingers = Fingers Calibration
|
||||
reset-yaw = Yaw Reset
|
||||
reset-error-mounting-need_full_reset = Need a full reset before mounting
|
||||
reset-error-yaw-need_full_reset = Need a full reset before yaw reset
|
||||
reset-error-need_positional_head = Step mounting needs a VR headset or a positional tracker
|
||||
reset-error-no_trackers = No tracker available
|
||||
reset-error-mounting-need_full_reset = Full reset required before before mounting calibration
|
||||
reset-error-yaw-need_full_reset = Full reset required before yaw reset
|
||||
reset-error-need_positional_head = Step mounting requires a VR headset or a positional tracker
|
||||
reset-error-no_trackers = No trackers available
|
||||
reset-error-no_feet_tracker = No feet tracker assigned / available
|
||||
|
||||
## Navigation bar
|
||||
@@ -514,7 +514,7 @@ settings-routing-description =
|
||||
SteamVR/Monado, VRChat OSC and VMC can each get a different set of body parts.
|
||||
settings-routing-mode = Routing mode
|
||||
settings-routing-automatic-label = Automatic routing
|
||||
settings-routing-automatic-description = Sends each bone to the best output so nothing is sent twice. Turn it off to choose the outputs for every bone yourself.
|
||||
settings-routing-automatic-description = Sends each bone to the best output to avoid duplicates. Disable this to manually pick where bones are routed.
|
||||
settings-routing-bone = Bone
|
||||
settings-routing-cell-required = Mandatory for this output
|
||||
settings-routing-cell-unavailable = Output is unavailable on this platform
|
||||
@@ -743,7 +743,7 @@ settings-general-fk_settings-leg_tweak-foot_plant = Foot plant
|
||||
settings-general-fk_settings-leg_tweak-skating_correction-amount = Skating correction strength
|
||||
settings-general-fk_settings-leg_tweak-skating_correction-amount-description = A higher value will result in more aggressive correction at the cost of accuracy during certain movements.
|
||||
settings-general-fk_settings-leg_tweak-skating_correction-description = Corrects for foot sliding, but can decrease accuracy during certain movements.
|
||||
settings-general-fk_settings-leg_tweak-floor_clip-description = Prevents feet clipping through the floor by shifting them up when they do.
|
||||
settings-general-fk_settings-leg_tweak-floor_clip-description = Pushes your feet upwards when they sink below the floor to prevent clipping.
|
||||
settings-general-fk_settings-leg_tweak-toe_snap-description = When not using feet trackers, guesses the rotation of your feet when going on your tippy toes.
|
||||
settings-general-fk_settings-leg_tweak-foot_plant-description = When not using feet trackers, keeps your feet parallel to the ground when they touch it.
|
||||
settings-general-fk_settings-leg_fk = Leg tracking
|
||||
@@ -804,7 +804,7 @@ settings-general-gesture_control-fullReset-name = Full reset
|
||||
settings-general-gesture_control-mountingReset-name = Mounting calibration
|
||||
# The number of trackers that can have higher acceleration before a tap is rejected
|
||||
settings-general-gesture_control-tapsTrackersOverThreshold = Taps trackers over threshold
|
||||
settings-general-gesture_control-numberTrackersOverThreshold-description = Increase this value if tap detection is not working. Do not increase it above what is needed to make it work in order to prevent false positives.
|
||||
settings-general-gesture_control-numberTrackersOverThreshold-description = Increase this value if tap detection is not working. Do not increase this higher than necessary, to prevent false positives.
|
||||
|
||||
## Appearance settings
|
||||
settings-interface-appearance = Appearance
|
||||
@@ -826,20 +826,20 @@ settings-general-interface-crowdin_in_context-enable = Open in-context translati
|
||||
settings-general-interface-crowdin_in_context-close = Close in-context translation
|
||||
# Keep the font name untranslated
|
||||
settings-interface-appearance-font = GUI font
|
||||
settings-interface-appearance-font-description = This changes the font used by the interface.
|
||||
settings-interface-appearance-font-description = Change the font used by the interface.
|
||||
settings-interface-appearance-font-placeholder = Default font
|
||||
settings-interface-appearance-font-os_font = OS font
|
||||
settings-interface-appearance-font-slime_font = Default font
|
||||
settings-interface-appearance-font_size = Base font scaling
|
||||
settings-interface-appearance-font_size-description = This affects the font size of the whole interface except this settings panel.
|
||||
settings-interface-appearance-font_size-description = Control the font size used throughout the whole interface, except for this settings panel.
|
||||
|
||||
## Notification settings
|
||||
settings-general-interface-feedback_sound = Feedback sound
|
||||
settings-general-interface-feedback_sound-description = This option plays a sound when a reset is triggered.
|
||||
settings-general-interface-feedback_sound-description = Play feedback sounds when performing a reset.
|
||||
settings-general-interface-feedback_sound-volume = Feedback sound volume
|
||||
settings-general-interface-feedback_sound-volume-description = How loud the reset sound is.
|
||||
settings-general-interface-connected_trackers_warning = Connected trackers warning
|
||||
settings-general-interface-connected_trackers_warning-description = This option will show a pop-up every time you try exiting SlimeVR while having one or more connected trackers. It reminds you to turn off your trackers when you are done to preserve battery life.
|
||||
settings-general-interface-connected_trackers_warning-description = Show a pop-up every time you try exiting SlimeVR while having one or more trackers connected, reminding you to preserve battery life by turning off your trackers first.
|
||||
|
||||
## Behavior settings
|
||||
settings-interface-behavior = Behaviour
|
||||
@@ -877,7 +877,7 @@ settings-interface-behavior-skeleton_mesh-label = Use 3D shapes
|
||||
settings-interface-behavior-skeleton_mesh-lines = Lines
|
||||
settings-interface-behavior-skeleton_mesh-mesh = 3D shapes
|
||||
settings-interface-behavior-controller_nav = Game controller navigation
|
||||
settings-interface-behavior-controller_nav-description = Move focus around the interface with a game controller: the D-pad or left stick move between controls, A activates, B goes back, only while a controller is connected. Holding Ctrl or Alt with the arrow keys always moves focus the same way.
|
||||
settings-interface-behavior-controller_nav-description = Allow usage of a game controller to navigate the interface, or a keyboard by holding Ctrl or Alt while pressing the arrow keys. Use the D-pad or left stick to move between controls, A to activate the selected control, and B to go back.
|
||||
|
||||
## Serial settings
|
||||
settings-serial = USB Serial Console
|
||||
@@ -1153,7 +1153,8 @@ settings-home-table_columns-desc = Choose which columns are shown in the tracker
|
||||
|
||||
settings-home-display_group = Display
|
||||
settings-home-tracker_display = Tracker info
|
||||
settings-home-tracker_display-desc = Choose which extra details are shown on trackers
|
||||
settings-home-tracker_display-desc = Choose which extra details are shown on trackers.
|
||||
settings-home-tracker_display-battery_runtime_estimate = Battery runtime estimate
|
||||
settings-home-tracker_display-battery_voltage = Battery voltage
|
||||
settings-home-tracker_display-numeric_signal = Numeric signal strength
|
||||
|
||||
@@ -1304,7 +1305,7 @@ onboarding-connect_tracker-next = I connected all my trackers
|
||||
|
||||
## Tracker assignment setup
|
||||
onboarding-assign_trackers-title = Assign trackers
|
||||
onboarding-assign_trackers-description = Let's choose which tracker goes where. Click on a location where you want to place a tracker.
|
||||
onboarding-assign_trackers-description = Let's choose where your trackers are placed. Click where you want to place a tracker, or drag the tracker from the list.
|
||||
onboarding-assign_trackers-reset_assignments = Reset all assignments
|
||||
# Look at translation of onboarding-connect_tracker-connected_trackers on how to use plurals
|
||||
# $assigned (Number) - Trackers that have been assigned a body part
|
||||
@@ -1581,7 +1582,7 @@ home-new_trackers-adding = Connecting…
|
||||
home-new_trackers-ignore = Ignore until SlimeVR restarts
|
||||
home-new_trackers-official_board = SlimeVR Tracker
|
||||
home-no_trackers-title = No trackers connected
|
||||
home-no_trackers-description = Connect a tracker or turn on your existing trackers to get started
|
||||
home-no_trackers-description = Connect a tracker, or turn on your existing trackers to get started
|
||||
home-no_trackers-connect = Connect trackers
|
||||
home-no_trackers-guide = View setup guide
|
||||
# Accessible names and tooltips for the icon-only buttons in a connection group's toolbox
|
||||
|
||||
@@ -52,49 +52,49 @@ export function PersonFrontIcon({
|
||||
/>
|
||||
<circle
|
||||
className="body-part-circle"
|
||||
cx="82"
|
||||
cx="81.8"
|
||||
cy="105"
|
||||
r={CIRCLE_RADIUS}
|
||||
id={BodyPart[BodyPart.UPPER_CHEST]}
|
||||
/>
|
||||
<circle
|
||||
className="body-part-circle"
|
||||
cx="82"
|
||||
cx="81.8"
|
||||
cy="120"
|
||||
r={CIRCLE_RADIUS}
|
||||
id={BodyPart[BodyPart.LOWER_CHEST]}
|
||||
/>
|
||||
<circle
|
||||
className="body-part-circle"
|
||||
cx="82"
|
||||
cx="81.8"
|
||||
cy="181"
|
||||
r={CIRCLE_RADIUS}
|
||||
id={BodyPart[BodyPart.HIP]}
|
||||
/>
|
||||
<circle
|
||||
className="body-part-circle"
|
||||
cx="82"
|
||||
cx="81.8"
|
||||
cy="155"
|
||||
r={CIRCLE_RADIUS}
|
||||
id={BodyPart[BodyPart.UPPER_WAIST]}
|
||||
/>
|
||||
<circle
|
||||
className="body-part-circle"
|
||||
cx="82"
|
||||
cx="81.8"
|
||||
cy="169"
|
||||
r={CIRCLE_RADIUS}
|
||||
id={BodyPart[BodyPart.LOWER_WAIST]}
|
||||
/>
|
||||
<circle
|
||||
className="body-part-circle"
|
||||
cx="82"
|
||||
cx="81.8"
|
||||
cy="80"
|
||||
r={CIRCLE_RADIUS}
|
||||
id={BodyPart[BodyPart.NECK]}
|
||||
/>
|
||||
<circle
|
||||
className="body-part-circle"
|
||||
cx="82"
|
||||
cx="81.8"
|
||||
cy="35"
|
||||
r={CIRCLE_RADIUS}
|
||||
id={BodyPart[BodyPart.HEAD]}
|
||||
@@ -149,14 +149,6 @@ export function PersonFrontIcon({
|
||||
id={BodyPart[SIDES[right].foot]}
|
||||
/>
|
||||
|
||||
<circle
|
||||
className="body-part-circle"
|
||||
cx="102"
|
||||
cy="393"
|
||||
r={CIRCLE_RADIUS}
|
||||
id="right-toes"
|
||||
/>
|
||||
|
||||
<circle
|
||||
className="body-part-circle"
|
||||
cx="15"
|
||||
@@ -208,13 +200,6 @@ export function PersonFrontIcon({
|
||||
r={CIRCLE_RADIUS}
|
||||
id={BodyPart[SIDES[left].foot]}
|
||||
/>
|
||||
<circle
|
||||
className="body-part-circle"
|
||||
cx="62"
|
||||
cy="393"
|
||||
r={CIRCLE_RADIUS}
|
||||
id="left-toes"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
}
|
||||
@@ -277,26 +277,8 @@ export function HeightSelectionInput({
|
||||
};
|
||||
|
||||
const handleUnitChange = (newUnit: 'meter' | 'foot') => {
|
||||
if (!headHeight || newUnit === unit) return;
|
||||
if (newUnit === unit) return;
|
||||
|
||||
const fullHeight = headHeight / EYE_HEIGHT_TO_HEIGHT_RATIO;
|
||||
let snappedHeight;
|
||||
|
||||
if (newUnit === 'foot') {
|
||||
// Snap to nearest inch
|
||||
const totalInches = Math.round(convert(fullHeight, 'meter').to('inch'));
|
||||
snappedHeight = convert(totalInches, 'inch').to('meter');
|
||||
} else {
|
||||
// Snap to nearest centimeter
|
||||
const totalCm = Math.round(convert(fullHeight, 'meter').to('cm'));
|
||||
snappedHeight = convert(totalCm, 'cm').to('meter');
|
||||
}
|
||||
|
||||
const newEyeHeight = round4Digit(
|
||||
snappedHeight * EYE_HEIGHT_TO_HEIGHT_RATIO
|
||||
);
|
||||
|
||||
setHeadHeight(newEyeHeight);
|
||||
onUnitChange(newUnit);
|
||||
};
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ import { UpperArmIcon } from '@/components/commons/icon/UpperArmIcon';
|
||||
import { Tooltip } from '@/components/commons/Tooltip';
|
||||
import { WarningBox } from '@/components/commons/TipBox';
|
||||
import { HandsWarningModal } from './components/HandsWarningModal';
|
||||
import { useSettingsDefaults } from '@/hooks/settings-defaults';
|
||||
|
||||
const OUTPUT_LABEL_ID: Record<number, string> = {
|
||||
[RoutingOutput.DRIVER]: 'settings-routing-output-driver',
|
||||
@@ -398,6 +399,7 @@ export function BoneRoutingSettings() {
|
||||
const { currentLocales } = useLocaleConfig();
|
||||
const { sendRPCPacket, useRPCPacket, useConnectedEffect } = useWebsocketAPI();
|
||||
const [settings, setSettings] = useState(new BoneRoutingSettingsResponseT());
|
||||
const defaults = useSettingsDefaults().boneRouting;
|
||||
|
||||
const [automatic, setAutomatic] = useState(true);
|
||||
const [routes, setRoutes] = useState<RouteMap>(new Map());
|
||||
@@ -608,6 +610,10 @@ export function BoneRoutingSettings() {
|
||||
<SettingRow
|
||||
setting={groups.mode.rows.automatic}
|
||||
controlId="routing-automatic"
|
||||
reset={{
|
||||
modified: automatic != defaults.automatic,
|
||||
onReset: () => setMode(defaults.automatic),
|
||||
}}
|
||||
control={
|
||||
<CheckboxInternal
|
||||
variant="toggle"
|
||||
|
||||
@@ -123,11 +123,14 @@ export function TrackersTableColumnsSettings({
|
||||
}
|
||||
|
||||
const trackerDisplayToggleOrder: (keyof TrackerDisplayConfig)[] = [
|
||||
'showBatteryRuntimeEstimate',
|
||||
'showBatteryVoltage',
|
||||
'showNumericSignal',
|
||||
];
|
||||
|
||||
const trackerDisplayToggleLabel: Record<keyof TrackerDisplayConfig, string> = {
|
||||
showBatteryRuntimeEstimate:
|
||||
'settings-home-tracker_display-battery_runtime_estimate',
|
||||
showBatteryVoltage: 'settings-home-tracker_display-battery_voltage',
|
||||
showNumericSignal: 'settings-home-tracker_display-numeric_signal',
|
||||
};
|
||||
|
||||
@@ -33,14 +33,17 @@ export function TrackerBattery({
|
||||
});
|
||||
|
||||
const charging = (voltage || 0) > 4.3;
|
||||
const debug = config?.debug;
|
||||
const showRuntime =
|
||||
config?.trackerDisplay?.showBatteryRuntimeEstimate &&
|
||||
runtime != null &&
|
||||
runtime > 0;
|
||||
const showVoltage = voltage && config?.trackerDisplay?.showBatteryVoltage;
|
||||
|
||||
const pct = value > 2 ? 0 : Math.min(Math.max(value, 0), 1);
|
||||
|
||||
return (
|
||||
<Tooltip
|
||||
disabled={charging || !runtime || debug}
|
||||
disabled={charging || !showRuntime}
|
||||
preferedDirection="left"
|
||||
content={<Typography>{percentFormatter.format(pct)}</Typography>}
|
||||
>
|
||||
@@ -50,7 +53,7 @@ export function TrackerBattery({
|
||||
</div>
|
||||
{((!charging || showVoltage) && (
|
||||
<div className="w-15">
|
||||
{!charging && runtime != null && runtime > 0 && (
|
||||
{!charging && showRuntime && (
|
||||
<Typography color={textColor}>
|
||||
{(runtime / BigInt(3600000000)).toString() +
|
||||
'h ' +
|
||||
@@ -61,7 +64,7 @@ export function TrackerBattery({
|
||||
'min'}
|
||||
</Typography>
|
||||
)}
|
||||
{!charging && (!runtime || debug) && (
|
||||
{!charging && !showRuntime && (
|
||||
<Typography color={textColor}>
|
||||
{percentFormatter.format(pct)}
|
||||
</Typography>
|
||||
|
||||
@@ -69,11 +69,13 @@ export const trackersTableColumnOrder = [
|
||||
export type TrackersTableOptionalColumn = (typeof trackersTableColumnOrder)[number];
|
||||
|
||||
export interface TrackerDisplayConfig {
|
||||
showBatteryRuntimeEstimate: boolean;
|
||||
showBatteryVoltage: boolean;
|
||||
showNumericSignal: boolean;
|
||||
}
|
||||
|
||||
export const defaultTrackerDisplay: TrackerDisplayConfig = {
|
||||
showBatteryRuntimeEstimate: true,
|
||||
showBatteryVoltage: false,
|
||||
showNumericSignal: false,
|
||||
};
|
||||
|
||||
@@ -53,6 +53,9 @@ linux:
|
||||
to: "."
|
||||
- from: "./resources/firewall"
|
||||
to: "firewall"
|
||||
# Exists in CI when building for AppImage
|
||||
- from: "./resources/jre"
|
||||
to: "jre"
|
||||
icon: "./resources/icons"
|
||||
|
||||
deb:
|
||||
|
||||
@@ -178,13 +178,20 @@ export function captureServerExit(
|
||||
const eventId = Sentry.captureMessage('server_exit_nonzero', {
|
||||
...serverScope,
|
||||
level: 'error',
|
||||
extra: { code, signal, outputTail },
|
||||
tags: { code, signal },
|
||||
extra: { outputTail },
|
||||
});
|
||||
lastServerFailure = { eventId, code, signal, outputTail };
|
||||
}
|
||||
|
||||
export function sendCrashReport(kind: CrashReportKind) {
|
||||
if (!Sentry.isInitialized()) return false;
|
||||
if (!Sentry.isInitialized()) {
|
||||
logger.warn(
|
||||
{ kind },
|
||||
'Tried to send Sentry crash report before Sentry has initialised'
|
||||
);
|
||||
return false;
|
||||
}
|
||||
const failure = lastServerFailure;
|
||||
Sentry.withScope((scope) => {
|
||||
scope.setTag(USER_REQUESTED_TAG, 'true');
|
||||
@@ -192,10 +199,16 @@ export function sendCrashReport(kind: CrashReportKind) {
|
||||
event_id: failure?.eventId,
|
||||
message: failure ? 'server_exit_nonzero' : `server_${kind}`,
|
||||
level: 'error',
|
||||
tags: serverScope.tags,
|
||||
extra: failure
|
||||
? { code: failure.code, signal: failure.signal, outputTail: failure.outputTail }
|
||||
: { outputTail: serverOutputTail() },
|
||||
tags: failure
|
||||
? {
|
||||
...serverScope.tags,
|
||||
code: failure.code,
|
||||
signal: failure.signal,
|
||||
}
|
||||
: serverScope.tags,
|
||||
extra: {
|
||||
outputTail: failure?.outputTail ?? serverOutputTail(),
|
||||
},
|
||||
});
|
||||
});
|
||||
return true;
|
||||
|
||||
@@ -37,8 +37,9 @@ suspend fun createAndroidSolarXRWebsocketServer(appContext: AppContextProvider)
|
||||
appContext = appContext,
|
||||
scope = this,
|
||||
)
|
||||
val name = bridge.context.name
|
||||
|
||||
AppLogger.ipc.info("SolarXR[${bridge.id}] connected (websocket)")
|
||||
AppLogger.ipc.info("$name connected (websocket)")
|
||||
appContext.server.context.dispatch(VRServerActions.SolarXRConnected(bridge))
|
||||
|
||||
bridge.outbound.on<MessageBundle> { bundle ->
|
||||
@@ -54,7 +55,7 @@ suspend fun createAndroidSolarXRWebsocketServer(appContext: AppContextProvider)
|
||||
for (frame in incoming) {
|
||||
when (frame) {
|
||||
is Frame.Binary -> emit(frame.data)
|
||||
is Frame.Close -> AppLogger.ipc.info("SolarXR[${bridge.id}] connection closed")
|
||||
is Frame.Close -> AppLogger.ipc.info("$name connection closed")
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
@@ -63,7 +64,7 @@ suspend fun createAndroidSolarXRWebsocketServer(appContext: AppContextProvider)
|
||||
onSolarXRMessage(MessageBundle.decode(reader, reader.getInt(0)), bridge)
|
||||
}
|
||||
} finally {
|
||||
AppLogger.ipc.info("SolarXR[${bridge.id}] disconnected (websocket)")
|
||||
AppLogger.ipc.info("$name disconnected (websocket)")
|
||||
bridge.disconnect()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package dev.slimevr.autobone
|
||||
|
||||
class WeightedAverage {
|
||||
var value: Float = 0f
|
||||
private set
|
||||
var weight: Float = 0f
|
||||
private set
|
||||
|
||||
fun average() = if (weight > 0f) {
|
||||
value / weight
|
||||
} else {
|
||||
0f
|
||||
}
|
||||
|
||||
fun addValue(value: Float, weight: Float) {
|
||||
this.value += value * weight
|
||||
this.weight += weight
|
||||
}
|
||||
|
||||
fun subtractValue(value: Float, weight: Float) {
|
||||
this.value -= value * weight
|
||||
this.weight -= weight
|
||||
}
|
||||
|
||||
fun reset() {
|
||||
value = 0f
|
||||
weight = 0f
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package dev.slimevr.autobone
|
||||
|
||||
import dev.slimevr.skeleton.BodyPartMap
|
||||
import dev.slimevr.skeleton.ComputedSkeleton
|
||||
import dev.slimevr.skeleton.bodyPartMap
|
||||
import dev.slimevr.skeleton.mapValues
|
||||
import dev.slimevr.util.Side
|
||||
import dev.slimevr.util.side
|
||||
import io.github.axisangles.ktmath.Quaternion
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import solarxr_protocol.datatypes.BodyPart
|
||||
|
||||
val BODY_PARTS_TO_ADJUST = arrayOf(
|
||||
BodyPart.NECK,
|
||||
BodyPart.UPPER_CHEST,
|
||||
BodyPart.LOWER_CHEST,
|
||||
BodyPart.UPPER_WAIST,
|
||||
BodyPart.LOWER_WAIST,
|
||||
BodyPart.HIP,
|
||||
|
||||
BodyPart.LEFT_UPPER_LEG,
|
||||
BodyPart.LEFT_LOWER_LEG,
|
||||
|
||||
BodyPart.RIGHT_UPPER_LEG,
|
||||
BodyPart.RIGHT_LOWER_LEG,
|
||||
)
|
||||
|
||||
// TODO This should probably be every bone excluding arms, feet, and toes?
|
||||
val CONTRIBUTING_BODY_PARTS = BODY_PARTS_TO_ADJUST.plus(
|
||||
arrayOf(
|
||||
BodyPart.HEAD,
|
||||
),
|
||||
)
|
||||
|
||||
data class TrackerFrame(
|
||||
val rotation: Quaternion,
|
||||
val position: Vector3?,
|
||||
)
|
||||
typealias AutoBoneRecording = List<TrackerFrame>
|
||||
// TODO Figure out actually doing the recording
|
||||
|
||||
typealias BoneContribution = WeightedAverage
|
||||
typealias BoneContributions = BodyPartMap<BoneContribution>
|
||||
|
||||
fun process(recording: BodyPartMap<AutoBoneRecording>) {
|
||||
// TODO Actually make skeletons
|
||||
val skeletonA: ComputedSkeleton = bodyPartMap()
|
||||
val skeletonB: ComputedSkeleton = bodyPartMap()
|
||||
|
||||
val contributions: BoneContributions = bodyPartMap()
|
||||
|
||||
val recordingLength = recording.minOf { it.value.size }
|
||||
for (i in 0 until recordingLength) {
|
||||
val trackers = recording.mapValues { _, frames -> frames[i] }
|
||||
// TODO Apply trackers to skeletons A and B somehow
|
||||
|
||||
computeContributions(contributions, skeletonA, skeletonB)
|
||||
|
||||
// TODO Figure out how to choose adjustment scale
|
||||
// TODO Test new config to see if it actually reduces error
|
||||
}
|
||||
}
|
||||
|
||||
fun boneContribution(contribution: BoneContribution, ankleAToB: Vector3, localBoneTailAToB: Vector3) {
|
||||
val boneToSlideDirectionRatio = ankleAToB.unit().dot(localBoneTailAToB.unit())
|
||||
// - if bone is too short, + if bone is too long
|
||||
contribution.addValue(boneToSlideDirectionRatio, localBoneTailAToB.len())
|
||||
}
|
||||
|
||||
fun computeContributions(contributions: BoneContributions, skeletonA: ComputedSkeleton, skeletonB: ComputedSkeleton) {
|
||||
val leftAnkleA = skeletonA[BodyPart.LEFT_LOWER_LEG]?.tailPosition ?: error("Missing left ankle position A")
|
||||
val leftAnkleB = skeletonB[BodyPart.LEFT_LOWER_LEG]?.tailPosition ?: error("Missing left ankle position B")
|
||||
val leftAnkleAToB = leftAnkleB - leftAnkleA
|
||||
|
||||
val rightAnkleA = skeletonA[BodyPart.RIGHT_LOWER_LEG]?.tailPosition ?: error("Missing right ankle position A")
|
||||
val rightAnkleB = skeletonB[BodyPart.RIGHT_LOWER_LEG]?.tailPosition ?: error("Missing right ankle position B")
|
||||
val rightAnkleAToB = rightAnkleB - rightAnkleA
|
||||
|
||||
// TODO Consider headset sliding; if HMD consistently aligns with sliding, then
|
||||
// either height is wrong, or the headset has weird movement
|
||||
CONTRIBUTING_BODY_PARTS.forEach { bodyPart ->
|
||||
val boneA = skeletonA[bodyPart] ?: return@forEach
|
||||
val boneB = skeletonB[bodyPart] ?: return@forEach
|
||||
|
||||
val contribution = contributions.getOrPut(bodyPart) { BoneContribution() }
|
||||
|
||||
val localBoneTailAToB = boneB.localTailPosition - boneA.localTailPosition
|
||||
val side = bodyPart.side
|
||||
// LEFT (or both)
|
||||
if (side != Side.RIGHT) {
|
||||
boneContribution(
|
||||
contribution,
|
||||
leftAnkleAToB,
|
||||
localBoneTailAToB,
|
||||
)
|
||||
}
|
||||
// RIGHT (or both)
|
||||
if (side != Side.LEFT) {
|
||||
boneContribution(
|
||||
contribution,
|
||||
rightAnkleAToB,
|
||||
localBoneTailAToB,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
package dev.slimevr.autobone
|
||||
|
||||
import dev.slimevr.skeleton.ComputedSkeleton
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import solarxr_protocol.datatypes.BodyPart
|
||||
|
||||
fun slideContributionWeight(ankleA: Vector3, ankleB: Vector3, localBoneTailA: Vector3, localBoneTailB: Vector3): Float {
|
||||
val ankleAToB = ankleB - ankleA
|
||||
val localBoneTailAToB = localBoneTailB - localBoneTailA
|
||||
|
||||
val boneToSlideDirectionRatio = ankleAToB.unit().dot(localBoneTailAToB.unit())
|
||||
|
||||
// if +, shorten bone, if -, lengthen bone
|
||||
// sum all contribution weights, divide each bone's weight by the sum, then multiply
|
||||
// by the slide magnitude in order to find the corresponding bone change
|
||||
return localBoneTailAToB.len() * boneToSlideDirectionRatio
|
||||
}
|
||||
|
||||
// TODO This is a placeholder
|
||||
val PLACEHOLDER_BODY_PARTS_TO_ADJUST = arrayOf(
|
||||
BodyPart.UPPER_CHEST,
|
||||
BodyPart.LOWER_CHEST,
|
||||
BodyPart.UPPER_WAIST,
|
||||
BodyPart.LOWER_WAIST,
|
||||
BodyPart.HIP,
|
||||
// etc.
|
||||
)
|
||||
|
||||
fun step(skeletonA: ComputedSkeleton, skeletonB: ComputedSkeleton) {
|
||||
// TODO We need to consider both ankles, there are two... We can do contribution per
|
||||
// ankle
|
||||
// TODO This is a placeholder
|
||||
val ankleA = Vector3.ZERO
|
||||
// TODO This is a placeholder
|
||||
val ankleB = Vector3.ZERO
|
||||
|
||||
// TODO Consider headset sliding; if HMD consistently aligns with sliding, then
|
||||
// either height is wrong, or the headset has weird movement
|
||||
val contributions = PLACEHOLDER_BODY_PARTS_TO_ADJUST.map { bodyPart ->
|
||||
val boneA = skeletonA[bodyPart] ?: return@map 0f
|
||||
val boneB = skeletonB[bodyPart] ?: return@map 0f
|
||||
|
||||
slideContributionWeight(
|
||||
ankleA,
|
||||
ankleB,
|
||||
boneA.localTailPosition,
|
||||
boneB.localTailPosition,
|
||||
)
|
||||
}.filter { it > 0f }
|
||||
|
||||
// TODO This is a placeholder
|
||||
val slideMag = 1f
|
||||
|
||||
val contributionSum = contributions.sum()
|
||||
val perBoneSlide = contributions.map {
|
||||
(it * slideMag) / contributionSum
|
||||
}
|
||||
|
||||
// TODO This is a placeholder
|
||||
val config = 1f
|
||||
val newConfigs = perBoneSlide.map {
|
||||
config + it
|
||||
}
|
||||
|
||||
// TODO Test new config to see if it actually reduces error? Or do we just
|
||||
// accept the changes? The contribution scales for each frame and considers
|
||||
// direction; we should be able to skip checking if it reduces error
|
||||
}
|
||||
@@ -117,7 +117,7 @@ data class SkeletonTogglesConfig(
|
||||
@Serializable
|
||||
data class SkeletonRatiosConfig(
|
||||
val smoothingStrength: Float = 0.15f,
|
||||
val predictionStrength: Float = 0.30f,
|
||||
val predictionStrength: Float = 0.25f,
|
||||
val spineCurvature: Float = 0.75f,
|
||||
val imputeSpineFromUpperToLower: Float = DEFAULT_SPINE_UPPER_LOWER,
|
||||
val interpolateUpperLegsTwistWithLowerLegs: Float = 0.85f,
|
||||
|
||||
@@ -47,7 +47,7 @@ import kotlin.time.Duration.Companion.seconds
|
||||
import kotlin.time.TimeMark
|
||||
|
||||
// Feet go slightly inwards on pose mounting
|
||||
private const val FEET_POSE_DEG_INWARDS = 15
|
||||
private const val FEET_POSE_DEG_INWARDS = 15 * FastMath.DEG_TO_RAD
|
||||
|
||||
data class ResetsState(
|
||||
val canDoYawReset: Boolean,
|
||||
@@ -237,9 +237,13 @@ class ResetsManager(
|
||||
|
||||
private fun getYawOffset(bodyPart: BodyPart?, armsResetMode: ArmsMountingResetMode) = when (bodyPart) {
|
||||
// Feet go back but a little inwards
|
||||
BodyPart.LEFT_FOOT -> FastMath.PI - FEET_POSE_DEG_INWARDS * FastMath.DEG_TO_RAD
|
||||
BodyPart.LEFT_FOOT -> FastMath.PI - FEET_POSE_DEG_INWARDS
|
||||
|
||||
BodyPart.RIGHT_FOOT -> FastMath.PI + FEET_POSE_DEG_INWARDS * FastMath.DEG_TO_RAD
|
||||
in ResetBodyParts.LEFT_TOES -> FastMath.PI - FEET_POSE_DEG_INWARDS
|
||||
|
||||
BodyPart.RIGHT_FOOT -> FastMath.PI + FEET_POSE_DEG_INWARDS
|
||||
|
||||
in ResetBodyParts.RIGHT_TOES -> FastMath.PI + FEET_POSE_DEG_INWARDS
|
||||
|
||||
// Going forward
|
||||
in ResetBodyParts.UPPER_LEGS -> 0f
|
||||
|
||||
@@ -75,6 +75,8 @@ class LocalizerResetBehaviour(val settings: Settings) : SkeletonBehaviour {
|
||||
*/
|
||||
class YouSpinMeRightRoundBehaviour(val inputHz: Int = 100, val speed: Float = 1f, val randomPacketLoss: Float = 0f, val constantPacketLoss: Float = 0f, val sendPosition: Boolean = false) : SkeletonBehaviour {
|
||||
override fun observe(receiver: Skeleton) {
|
||||
println("YouSpinMeRightRoundBehaviour sending fake bone data for simulation.")
|
||||
|
||||
receiver.context.scope.launch {
|
||||
val interval = (millisecondsInSecond / inputHz.toFloat()).toLong().milliseconds
|
||||
val startTime = timeSource.markNow()
|
||||
|
||||
@@ -36,7 +36,8 @@ private const val SMOOTHING_MS_MAX = 50.0
|
||||
|
||||
// Prediction
|
||||
private const val PREDICTION_MS_MAX = 30.0
|
||||
private const val PREVIOUS_PREDICTION_CARRYOVER = 0.2f
|
||||
private val PREDICTION_CARRYOVER_TIME = 25.milliseconds
|
||||
private const val MAX_PREDICTION_CARRYOVER_RATIO = 0.5
|
||||
|
||||
// Used to minimize latency even more for arm tracking where it is more noticeable
|
||||
private val PART_MULTIPLIER = BodyPartMap(
|
||||
@@ -100,7 +101,8 @@ private fun computePredictedRotation(
|
||||
if (previousRotation == null) return targetRotation
|
||||
|
||||
// Use some of the previous prediction
|
||||
val previousPredictionDelta = previousPredictedRotation?.localAbout(previousRotation)?.pow(PREVIOUS_PREDICTION_CARRYOVER)
|
||||
val carryoverRatio = (PREDICTION_CARRYOVER_TIME / poseTimeDelta).coerceAtMost(MAX_PREDICTION_CARRYOVER_RATIO).toFloat()
|
||||
val previousPredictionDelta = previousPredictedRotation?.localAbout(previousRotation)?.pow(carryoverRatio)
|
||||
?: Quaternion.IDENTITY
|
||||
|
||||
val currentDelta = if (poseTimeDelta > Duration.ZERO) {
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package dev.slimevr.skeleton.inputprocessors
|
||||
|
||||
import dev.slimevr.skeleton.BodyPartMap
|
||||
import dev.slimevr.skeleton.BoneInput
|
||||
import dev.slimevr.skeleton.InputSkeleton
|
||||
import dev.slimevr.skeleton.SkeletonInputProcessor
|
||||
import dev.slimevr.skeleton.bodyPartMap
|
||||
import kotlin.random.Random
|
||||
import kotlin.time.ComparableTimeMark
|
||||
|
||||
/**
|
||||
* Used for simulating packet drop, leave commented for production.
|
||||
*/
|
||||
class PacketDropSimulatorInputProcessor(val randomPacketDrop: Float) : SkeletonInputProcessor {
|
||||
init {
|
||||
println("PacketDropSimulatorInputProcessor simulating ${randomPacketDrop * 100}% packet drop.")
|
||||
}
|
||||
|
||||
val lastBone: BodyPartMap<BoneInput> = bodyPartMap()
|
||||
val lastPoseTime: BodyPartMap<ComparableTimeMark> = bodyPartMap()
|
||||
override fun process(mutableInputSkeleton: InputSkeleton, skeletonHeight: Float) {
|
||||
mutableInputSkeleton.forEach { (part, input) ->
|
||||
val isNewData = lastPoseTime[part] != mutableInputSkeleton[part]?.poseTime
|
||||
lastPoseTime[part] = mutableInputSkeleton[part]?.poseTime
|
||||
if (isNewData) {
|
||||
val dropPacket = Random.nextFloat() < randomPacketDrop
|
||||
if (!dropPacket) {
|
||||
lastBone[part] = input
|
||||
} else if (lastBone[part] != null) {
|
||||
mutableInputSkeleton[part] = lastBone[part]
|
||||
}
|
||||
} else if (lastBone[part] != null) {
|
||||
mutableInputSkeleton[part] = lastBone[part]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import dev.slimevr.skeleton.inputprocessors.FilteringInputProcessor
|
||||
import dev.slimevr.skeleton.inputprocessors.FingersInputProcessor
|
||||
import dev.slimevr.skeleton.inputprocessors.HeadPositionFallbackInputProcessor
|
||||
import dev.slimevr.skeleton.inputprocessors.NeckInputProcessor
|
||||
import dev.slimevr.skeleton.inputprocessors.PacketDropSimulatorInputProcessor
|
||||
import dev.slimevr.skeleton.inputprocessors.SpineInputProcessor
|
||||
import dev.slimevr.skeleton.inputprocessors.ToesInputProcessor
|
||||
import dev.slimevr.skeleton.targetprocessors.FloorClipTargetProcessor
|
||||
@@ -262,12 +263,13 @@ class Skeleton(
|
||||
ProportionsBehaviour(ctx.config.userConfig),
|
||||
HeightLogBehaviour(),
|
||||
LocalizerResetBehaviour(settings),
|
||||
// YouSpinMeRightRoundBehaviour(inputHz = 100, speed = 1f, randomPacketLoss = 0f, constantPacketLoss = 0f, sendPosition = true),
|
||||
// YouSpinMeRightRoundBehaviour(inputHz = 100, speed = 1f, randomPacketLoss = 0.9f, constantPacketLoss = 0f, sendPosition = false),
|
||||
ComputedSkeletonBehaviour(
|
||||
hz = hz,
|
||||
waiter = waiter,
|
||||
// Run before FK on the inputs
|
||||
inputProcessors = listOf(
|
||||
// PacketDropSimulatorInputProcessor(0.85f),
|
||||
FilteringInputProcessor(settings),
|
||||
HeadPositionFallbackInputProcessor(),
|
||||
FallbackInputProcessor(),
|
||||
|
||||
+6
-3
@@ -26,8 +26,13 @@ val POSITIONAL_IK_TARGETS = arrayOf(
|
||||
BodyPart.RIGHT_FOOT to BodyPart.RIGHT_LOWER_LEG,
|
||||
)
|
||||
|
||||
val requiredInactive = BodyPartMap(
|
||||
// TODO Use active rotations as IK constraints instead and fill in the blanks
|
||||
private val requiredInactive = BodyPartMap(
|
||||
mapOf(
|
||||
BodyPart.LEFT_LOWER_LEG to arrayOf(BodyPart.LEFT_UPPER_LEG),
|
||||
BodyPart.RIGHT_LOWER_LEG to arrayOf(BodyPart.RIGHT_UPPER_LEG),
|
||||
BodyPart.LEFT_FOOT to arrayOf(BodyPart.LEFT_LOWER_LEG, BodyPart.LEFT_UPPER_LEG),
|
||||
BodyPart.RIGHT_FOOT to arrayOf(BodyPart.RIGHT_LOWER_LEG, BodyPart.RIGHT_UPPER_LEG),
|
||||
BodyPart.LEFT_HAND to arrayOf(BodyPart.LEFT_SHOULDER, BodyPart.LEFT_UPPER_ARM, BodyPart.LEFT_LOWER_ARM),
|
||||
BodyPart.RIGHT_HAND to arrayOf(BodyPart.RIGHT_SHOULDER, BodyPart.RIGHT_UPPER_ARM, BodyPart.RIGHT_LOWER_ARM),
|
||||
),
|
||||
@@ -41,8 +46,6 @@ class PositionalTargetProcessor(
|
||||
override fun process(mutableIkTargets: IKTargets, inputSkeleton: InputSkeleton, fk: ComputedSkeleton, floorLevel: Float) {
|
||||
if (!settings.context.state.value.data.skeletonConfig.toggles.useTrackerPositions) return
|
||||
for ((bodyPart, target) in bodyParts) {
|
||||
// TODO Use active rotations as IK constraints instead and fill in the blanks
|
||||
// Disable if you have arm trackers
|
||||
if (requiredInactive[bodyPart]?.any { inputSkeleton[it]?.isRotationActive == true } == true) continue
|
||||
|
||||
mutableIkTargets[target] = inputSkeleton[bodyPart]?.position ?: continue
|
||||
|
||||
+5
-1
@@ -27,6 +27,7 @@ const val OFFSET_LIMIT_MAX = 0.20f
|
||||
const val COM_DISTANCE_MULTIPLIER = 1.5f
|
||||
const val LIFT_MIN = -0.85f
|
||||
const val LIFT_MAX = 0.4f
|
||||
const val ANKLE_MULTIPLIER = 1.25f
|
||||
|
||||
// Parameters to decide if a foot should be locked
|
||||
// Higher makes it harder to unlock after being locked
|
||||
@@ -226,6 +227,7 @@ class SkatingCorrectionTargetProcessor(val settings: Settings, val skeleton: Ske
|
||||
|
||||
for ((bodyPart, ikTargetBodyPart, liftBodyPart) in skatingBodyParts) {
|
||||
val bone = fk[bodyPart] ?: continue
|
||||
val inputBone = inputSkeleton[bodyPart] ?: continue
|
||||
val ikBone = fk[ikTargetBodyPart] ?: continue
|
||||
val liftBone = fk[liftBodyPart] ?: continue
|
||||
val curPosition = mutableIkTargets[ikTargetBodyPart] ?: ikBone.tailPosition
|
||||
@@ -235,8 +237,10 @@ class SkatingCorrectionTargetProcessor(val settings: Settings, val skeleton: Ske
|
||||
val comMultiplier = computeComMultiplier(comDistances[bodyPart] ?: continue, comDistancesAverage)
|
||||
// liftMultiplier decreases the threshold when the upper leg is lifted. Useful when sitting/lying down
|
||||
val liftMultiplier = computeLiftMultiplier(liftBone.localTailPosition)
|
||||
// ankleMultiplier increases the threshold if the foot doesn't have its own accel data
|
||||
val ankleMultiplier = if (inputBone.isAccelerationActive) 1f else ANKLE_MULTIPLIER
|
||||
// Apply multipliers to the acceleration threshold
|
||||
val scaledAccelerationThreshold = accelerationThreshold * comMultiplier * liftMultiplier
|
||||
val scaledAccelerationThreshold = accelerationThreshold * comMultiplier * liftMultiplier * ankleMultiplier
|
||||
|
||||
// Compute if the body part should be locked
|
||||
val floorLocked = floorLocked(lastState.locked, curPosition, floorLevel)
|
||||
|
||||
@@ -207,10 +207,7 @@ class DataFeedInitBehaviour(
|
||||
|
||||
receiver.datafeedTimers.forEach { it.cancelAndJoin() }
|
||||
|
||||
AppLogger.solarxr.info(
|
||||
"SolarXR[${receiver.id}] data feed started: " +
|
||||
dataFeeds.joinToString { "every ${it.minimumTimeSinceLast}ms" },
|
||||
)
|
||||
AppLogger.solarxr.info("Started ${dataFeeds.size} data feeds: " + dataFeeds.joinToString { "${it.minimumTimeSinceLast}ms" })
|
||||
|
||||
val timers = dataFeeds.mapIndexed { index, config ->
|
||||
receiver.context.scope.launch {
|
||||
|
||||
@@ -32,8 +32,6 @@ val DRIVER_SUPPORTED_BONES = setOf(
|
||||
BodyPart.RIGHT_UPPER_LEG,
|
||||
BodyPart.LEFT_FOOT,
|
||||
BodyPart.RIGHT_FOOT,
|
||||
BodyPart.LEFT_SHOULDER,
|
||||
BodyPart.RIGHT_SHOULDER,
|
||||
BodyPart.LEFT_HAND,
|
||||
BodyPart.RIGHT_HAND,
|
||||
)
|
||||
@@ -51,8 +49,6 @@ class DriverOutgoingTrackersBehaviour(
|
||||
BodyPart.RIGHT_UPPER_LEG to setOf(BodyPart.RIGHT_UPPER_LEG),
|
||||
BodyPart.LEFT_FOOT to setOf(BodyPart.LEFT_FOOT, BodyPart.LEFT_LOWER_LEG),
|
||||
BodyPart.RIGHT_FOOT to setOf(BodyPart.RIGHT_FOOT, BodyPart.RIGHT_LOWER_LEG),
|
||||
BodyPart.LEFT_SHOULDER to setOf(BodyPart.LEFT_SHOULDER, BodyPart.LEFT_UPPER_ARM, BodyPart.LEFT_LOWER_ARM),
|
||||
BodyPart.RIGHT_SHOULDER to setOf(BodyPart.RIGHT_SHOULDER, BodyPart.RIGHT_UPPER_ARM, BodyPart.RIGHT_LOWER_ARM),
|
||||
BodyPart.LEFT_UPPER_ARM to setOf(BodyPart.LEFT_UPPER_ARM, BodyPart.LEFT_SHOULDER, BodyPart.LEFT_LOWER_ARM),
|
||||
BodyPart.RIGHT_UPPER_ARM to setOf(BodyPart.RIGHT_UPPER_ARM, BodyPart.RIGHT_SHOULDER, BodyPart.RIGHT_LOWER_ARM),
|
||||
BodyPart.LEFT_HAND to setOf(BodyPart.LEFT_HAND, BodyPart.LEFT_LOWER_ARM),
|
||||
|
||||
@@ -68,11 +68,14 @@ class BoneRoutingBehaviour(
|
||||
).distinctUntilChanged()
|
||||
|
||||
receiver.onRpc<BoneRoutingSettingsRequest> { _, txId ->
|
||||
// TODO: is .first() right here? It seems to return a very outdated value.
|
||||
// This causes issues in the driver where, on some launches, trackers will
|
||||
// simply not show up if they were all connected prior to launching SteamVR
|
||||
receiver.sendRpc(responses.first(), txId)
|
||||
}.launchIn(receiver.context.scope)
|
||||
|
||||
responses
|
||||
.drop(1)
|
||||
// .drop(1) // FIXME: Commented out as a workaround for the mentioned bug
|
||||
.onEach(receiver::sendRpc)
|
||||
.launchIn(receiver.context.scope)
|
||||
|
||||
|
||||
@@ -22,6 +22,10 @@ import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import solarxr_protocol.datatypes.MagnetometerStatus
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
// When a tracker comes back from sleep, prevents a disproportionate correction
|
||||
private val MAX_DELTA_TIME = 0.5.seconds
|
||||
|
||||
class TrackerStayAlignedBehaviour(
|
||||
private val settings: Settings,
|
||||
@@ -72,20 +76,17 @@ class TrackerStayAlignedBehaviour(
|
||||
.flatMapLatest { (enabled, imuType, magStatus) ->
|
||||
if (magStatus == MagnetometerStatus.ENABLED || imuType == null || !enabled) return@flatMapLatest emptyFlow()
|
||||
|
||||
// Ignore every other emission for performance (50FPS instead of 100FPS when at 100TPS)
|
||||
var index = 0
|
||||
var lastRotationTime = timeSource.markNow()
|
||||
receiver.context.state
|
||||
.distinctUntilChangedBy { it.rawRotation }
|
||||
.filter { index++ % 2 == 0 }
|
||||
.onEach { state ->
|
||||
val yawCorrectionPerSec = IMU_TO_YAW_CORRECTION.getOrDefault(imuType, YAW_CORRECTION_DEFAULT)
|
||||
if (yawCorrectionPerSec == Angle.ZERO) return@onEach
|
||||
|
||||
val lastFrameTimeSeconds = lastRotationTime.elapsedNow().inFloatingSeconds
|
||||
val deltaTime = lastRotationTime.elapsedNow().coerceAtMost(MAX_DELTA_TIME).inFloatingSeconds
|
||||
lastRotationTime = timeSource.markNow()
|
||||
|
||||
val applyYawCorrection = yawCorrectionPerSec * lastFrameTimeSeconds
|
||||
val applyYawCorrection = yawCorrectionPerSec * deltaTime
|
||||
|
||||
val yawCorrectionResult = TrackerYawCorrection.computeYawCorrection(
|
||||
state,
|
||||
|
||||
@@ -183,8 +183,6 @@ class SteamVRHandsCheckBehaviour(
|
||||
routes: Routes,
|
||||
driverConnected: Boolean,
|
||||
): TrackingChecklistStep {
|
||||
// The skeleton computes a hand bone from the arm chain, so routing one sends a hand
|
||||
// tracker to SteamVR whether or not the user wears anything on that hand.
|
||||
val handsSentToDriver = HAND_BONES.any { hand -> routes[hand]?.contains(RoutingOutput.DRIVER) == true }
|
||||
val handTrackers = trackers.filter { tracker -> tracker.bodyPart in HAND_BONES }
|
||||
// Controllers reach us back through the driver, anything else on a hand is a
|
||||
|
||||
@@ -81,14 +81,35 @@ private fun tailLogFile(source: LogSource, path: Path): Flow<LogEvent> = flow {
|
||||
return complete.drop(1)
|
||||
}
|
||||
|
||||
readNewLines().takeLast(BACKLOG_SIZE).forEach { line -> lineEvent(source, line)?.let { emit(it) } }
|
||||
// If a line is invalid, it is likely from a single event that has newlines in the message
|
||||
// Reuse the time and log level from the last line event
|
||||
var lastEvent: LogEvent? = null
|
||||
val emitLogEvent = suspend emitLogEvent@{ raw: String ->
|
||||
val line = raw.trimEnd('\r')
|
||||
if (line.isEmpty()) return@emitLogEvent
|
||||
|
||||
val event = lineEvent(source, line)?.also { lastEvent = it } ?: run {
|
||||
lastEvent?.let { event ->
|
||||
LogEvent(
|
||||
source = source,
|
||||
timeMs = event.timeMs,
|
||||
level = event.level,
|
||||
logger = event.logger,
|
||||
message = line,
|
||||
)
|
||||
} ?: return@emitLogEvent
|
||||
}
|
||||
|
||||
emit(event)
|
||||
}
|
||||
|
||||
readNewLines().takeLast(BACKLOG_SIZE).forEach { line -> emitLogEvent(line) }
|
||||
while (true) {
|
||||
val key = runInterruptible { watcher.take() }
|
||||
val touched = key.pollEvents().any { (it.context() as? Path)?.fileName == path.fileName }
|
||||
key.reset()
|
||||
if (!touched) continue
|
||||
readNewLines().forEach { line -> lineEvent(source, line)?.let { emit(it) } }
|
||||
readNewLines().forEach { line -> emitLogEvent(line) }
|
||||
}
|
||||
}
|
||||
}.flowOn(Dispatchers.IO)
|
||||
@@ -114,14 +135,10 @@ private fun readFrom(path: Path, offset: Long): Pair<String, Long> {
|
||||
}
|
||||
}
|
||||
|
||||
private fun lineEvent(source: LogSource, raw: String): LogEvent? {
|
||||
val line = raw.trimEnd('\r')
|
||||
if (line.isEmpty()) return null
|
||||
|
||||
val match = DRIVER_LINE.matchEntire(line)
|
||||
?: return LogEvent(source = source, timeMs = System.currentTimeMillis().toULong(), level = LogLevel.INFO, logger = "", message = line)
|
||||
|
||||
private fun lineEvent(source: LogSource, line: String): LogEvent? {
|
||||
val match = DRIVER_LINE.matchEntire(line) ?: return null
|
||||
val (time, offset, level, message) = match.destructured
|
||||
|
||||
val zone = if (offset.isEmpty()) ZoneId.systemDefault() else ZoneOffset.of(offset)
|
||||
return LogEvent(
|
||||
source = source,
|
||||
|
||||
@@ -18,6 +18,7 @@ import dev.slimevr.solarxr.onSolarXRMessage
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.engine.cio.CIO
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.cancelChildren
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
@@ -31,6 +32,7 @@ import okio.Buffer
|
||||
import solarxr_protocol.MessageBundle
|
||||
import solarxr_protocol.rpc.EnableSteamVRDriverRequest
|
||||
import solarxr_protocol.rpc.OpenKeybindSettingsRequest
|
||||
import java.io.IOException
|
||||
import java.nio.ByteBuffer
|
||||
|
||||
class EnableSteamVRDriverBehaviour : SolarXRBridgeBehaviour {
|
||||
@@ -89,8 +91,9 @@ suspend fun handleSolarXRBridge(
|
||||
}
|
||||
},
|
||||
)
|
||||
val name = bridge.context.name
|
||||
|
||||
AppLogger.solarxr.info("SolarXR[${bridge.id}] connected ($transport)")
|
||||
AppLogger.solarxr.info("$name connected ($transport)")
|
||||
appContext.server.context.dispatch(VRServerActions.SolarXRConnected(bridge))
|
||||
|
||||
// One builder and one send buffer for the life of the connection. clear() keeps the buffer it has
|
||||
@@ -98,12 +101,24 @@ suspend fun handleSolarXRBridge(
|
||||
// share: this collector handles one bundle at a time, and send drains the buffer
|
||||
val fbb = FlatBufferBuilder(256)
|
||||
val sendBuffer = Buffer()
|
||||
// If a client connected, sent a message, then immediately disconnected, we want to
|
||||
// stop trying to write but still read the last message, so we can't cancel immediately.
|
||||
// We'll end up dropping the connection since the messages flow finishes collection
|
||||
// when an error happens
|
||||
var writeFailed = false
|
||||
|
||||
bridge.outbound.on<MessageBundle> { bundle ->
|
||||
if (writeFailed) return@on
|
||||
|
||||
fbb.clear()
|
||||
fbb.finish(bundle.encode(JvmFlatBufferWriter(fbb)))
|
||||
sendBuffer.write(fbb.dataBuffer())
|
||||
send(sendBuffer)
|
||||
try {
|
||||
send(sendBuffer)
|
||||
} catch (e: IOException) {
|
||||
AppLogger.solarxr.warn("Exception when sending bundle to $name: ${e.message}")
|
||||
writeFailed = true
|
||||
}
|
||||
}.launchIn(this)
|
||||
|
||||
bridge.startObserving()
|
||||
@@ -121,7 +136,7 @@ suspend fun handleSolarXRBridge(
|
||||
onSolarXRMessage(MessageBundle.decode(reader, reader.getInt(0)), bridge)
|
||||
}
|
||||
} finally {
|
||||
AppLogger.solarxr.info("SolarXR[${bridge.id}] disconnected ($transport)")
|
||||
AppLogger.solarxr.info("$name disconnected ($transport)")
|
||||
bridge.disconnect()
|
||||
coroutineContext.cancelChildren()
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ private fun readFramedMessages(channel: SocketChannel) = flow {
|
||||
emit(frame)
|
||||
}
|
||||
} catch (e: SocketException) {
|
||||
AppLogger.ipc.warn("Exception on socket: ${e.message}")
|
||||
} catch (e: ClosedByInterruptException) {
|
||||
AppLogger.ipc.warn("Exception reading from socket: ${e.message}")
|
||||
} catch (_: ClosedByInterruptException) {
|
||||
AppLogger.ipc.info("Socket read interrupted, dropping connection")
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ private suspend fun acceptUnixClients(
|
||||
while (isActive) {
|
||||
val client = try {
|
||||
runInterruptible { server.accept() }
|
||||
} catch (e: ClosedByInterruptException) {
|
||||
} catch (_: ClosedByInterruptException) {
|
||||
break
|
||||
}
|
||||
AppLogger.ipc.info("$name client connected")
|
||||
@@ -135,7 +135,7 @@ private suspend fun acceptUnixClients(
|
||||
AppLogger.ipc.info("$name client disconnected")
|
||||
try {
|
||||
client.close()
|
||||
} catch (ignored: IOException) {
|
||||
} catch (_: IOException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,20 @@ suspend fun startBindingsProvider() = withContext(Dispatchers.IO) {
|
||||
// For some users, starting the executable immediately may cause startup failures
|
||||
delay(3000L)
|
||||
val proc = try {
|
||||
ProcessBuilder(path.toString()).start()
|
||||
val b = ProcessBuilder(path.toString())
|
||||
|
||||
// Make the dynamic linker able to find bundled libopenvr_api.so
|
||||
if (CURRENT_PLATFORM == Platform.LINUX) {
|
||||
val parent = path.parent
|
||||
if (parent.resolve("libopenvr_api.so").exists()) {
|
||||
val libraryPath = System.getenv("LD_LIBRARY_PATH")?.let { curLibraryPath ->
|
||||
"$curLibraryPath:$parent"
|
||||
} ?: parent.toString()
|
||||
b.environment()["LD_LIBRARY_PATH"] = libraryPath
|
||||
}
|
||||
}
|
||||
|
||||
b.start()
|
||||
} catch (e: Exception) {
|
||||
AppLogger.steamvr.error(e, "Failed to start bindings provider")
|
||||
return@withContext
|
||||
|
||||
@@ -45,8 +45,15 @@ private val STEAMVR_WEB_SERVER_STARTUP = 1.seconds
|
||||
// Retry delay doubles from 1s up to 2^step seconds (16s)
|
||||
private const val DRIVERS_RETRY_MAX_BACKOFF_STEP = 4L
|
||||
|
||||
private fun isProcessRunning(name: String): Boolean = ProcessHandle.allProcesses().anyMatch { proc ->
|
||||
proc.info().command().orElse(null)?.substringAfterLast(File.separatorChar) == name
|
||||
private fun isProcessRunning(name: String): Boolean = try {
|
||||
ProcessHandle.allProcesses().anyMatch { proc ->
|
||||
proc.info().command().orElse(null)?.substringAfterLast(File.separatorChar) == name
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
// Implementation of ProcessHandle.allProcesses may throw
|
||||
// RuntimeException("snapshot not available") on Windows if
|
||||
// CreateToolhelp32Snapshot or Process32First fails, ignore it
|
||||
false
|
||||
}
|
||||
|
||||
// No OS event for process start/exit, so this polls
|
||||
|
||||
Reference in new issue
Block a user