Compare commits

..
Author SHA1 Message Date
Sapphire 48255272d2 Put exit code and received signal in Sentry event tags instead of extra 2026-11-23 04:23:52 -05:00
Sapphire e4b0d0a58e Catch exceptions in implementation of ProcessHandle::allProcesses 2026-11-21 20:16:00 -05:00
Sapphire ae9efb1a92 Clean up conditions in TrackerBattery a bit 2026-11-21 17:39:48 -05:00
Sapphire 0368292bf1 Toggle to show battery runtime estimate instead of percentage 2026-11-21 17:37:05 -05:00
Sapphire d55c0ef494 Don't snap skeleton height when switching units
This ends up showing the 'are you sure you want to do this' popup
when switching units, which is annoying. Feel free to revert if this has
bad side effects.
2026-11-21 17:15:00 -05:00
Butterscotch! 7bc6d99f09 AutoBone weighted average bone contribution 2026-11-20 01:35:27 -05:00
10 changed files with 170 additions and 98 deletions

No files matched your search

+1
View File
@@ -1154,6 +1154,7 @@ 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-battery_runtime_estimate = Battery runtime estimate
settings-home-tracker_display-battery_voltage = Battery voltage
settings-home-tracker_display-numeric_signal = Numeric signal strength
@@ -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);
};
@@ -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>
+2
View File
@@ -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,
};
+12 -5
View File
@@ -178,7 +178,8 @@ 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 };
}
@@ -192,10 +193,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;
@@ -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
}
@@ -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