- {!charging && runtime != null && runtime > 0 && (
+ {!charging && showRuntime && (
{(runtime / BigInt(3600000000)).toString() +
'h ' +
@@ -61,7 +64,7 @@ export function TrackerBattery({
'min'}
)}
- {!charging && (!runtime || debug) && (
+ {!charging && !showRuntime && (
{percentFormatter.format(pct)}
diff --git a/gui/app/src/hooks/config.ts b/gui/app/src/hooks/config.ts
index dabaf1322..a3af47acd 100644
--- a/gui/app/src/hooks/config.ts
+++ b/gui/app/src/hooks/config.ts
@@ -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,
};
diff --git a/gui/app/src/hooks/tracker-picker.ts b/gui/app/src/hooks/tracker-picker.ts
index 26dbc70c2..bed04d865 100644
--- a/gui/app/src/hooks/tracker-picker.ts
+++ b/gui/app/src/hooks/tracker-picker.ts
@@ -75,7 +75,7 @@ const ASSIGNABLE_PARTS = new Set(ALL_ASSIGNABLE_PARTS);
type SetupRegionName =
| 'legs'
- | 'chest'
+ | 'upperChest'
| 'hip'
| 'feet'
| 'upperArms'
@@ -96,12 +96,12 @@ const SETUP_REGIONS: {
needs: SetupRegionName[];
}[] = [
{ id: 'legs', parts: [...LEGS_PARTS], needs: [] },
- { id: 'chest', parts: [BodyPart.UPPER_CHEST], needs: [] },
- { id: 'hip', parts: [BodyPart.HIP], needs: ['chest'] },
+ { id: 'upperChest', parts: [BodyPart.UPPER_CHEST], needs: [] },
+ { id: 'hip', parts: [BodyPart.HIP], needs: ['upperChest'] },
// one spine point at a time, each halving the largest remaining gap
- { id: 'lowerWaist', parts: [BodyPart.LOWER_WAIST], needs: ['hip'] },
- { id: 'lowerChest', parts: [BodyPart.LOWER_CHEST], needs: ['lowerWaist'] },
- { id: 'upperWaist', parts: [BodyPart.UPPER_WAIST], needs: ['lowerChest'] },
+ { id: 'upperWaist', parts: [BodyPart.UPPER_WAIST], needs: ['hip'] },
+ { id: 'lowerChest', parts: [BodyPart.LOWER_CHEST], needs: ['upperWaist'] },
+ { id: 'lowerWaist', parts: [BodyPart.LOWER_WAIST], needs: ['lowerChest'] },
{
id: 'feet',
parts: [BodyPart.LEFT_FOOT, BodyPart.RIGHT_FOOT],
@@ -110,7 +110,7 @@ const SETUP_REGIONS: {
{
id: 'upperArms',
parts: [BodyPart.LEFT_UPPER_ARM, BodyPart.RIGHT_UPPER_ARM],
- needs: ['legs', 'chest'],
+ needs: ['legs', 'upperChest'],
},
{
id: 'lowerArms',
diff --git a/gui/electron/main/sentry.ts b/gui/electron/main/sentry.ts
index 7e488f894..2b7c39669 100644
--- a/gui/electron/main/sentry.ts
+++ b/gui/electron/main/sentry.ts
@@ -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;
diff --git a/server/core/src/main/java/dev/slimevr/autobone/WeightedAverage.kt b/server/core/src/main/java/dev/slimevr/autobone/WeightedAverage.kt
new file mode 100644
index 000000000..ecf8aa79c
--- /dev/null
+++ b/server/core/src/main/java/dev/slimevr/autobone/WeightedAverage.kt
@@ -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
+ }
+}
diff --git a/server/core/src/main/java/dev/slimevr/autobone/behaviours.kt b/server/core/src/main/java/dev/slimevr/autobone/behaviours.kt
new file mode 100644
index 000000000..54fa0d838
--- /dev/null
+++ b/server/core/src/main/java/dev/slimevr/autobone/behaviours.kt
@@ -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
+// TODO Figure out actually doing the recording
+
+typealias BoneContribution = WeightedAverage
+typealias BoneContributions = BodyPartMap
+
+fun process(recording: BodyPartMap) {
+ // 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,
+ )
+ }
+ }
+}
diff --git a/server/core/src/main/java/dev/slimevr/autobone/functions.kt b/server/core/src/main/java/dev/slimevr/autobone/functions.kt
deleted file mode 100644
index ea51b28ce..000000000
--- a/server/core/src/main/java/dev/slimevr/autobone/functions.kt
+++ /dev/null
@@ -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
-}
diff --git a/server/core/src/main/java/dev/slimevr/skeleton/fkprocessors/foot-plant.kt b/server/core/src/main/java/dev/slimevr/skeleton/fkprocessors/foot-plant.kt
index f63bbde5a..c165edd61 100644
--- a/server/core/src/main/java/dev/slimevr/skeleton/fkprocessors/foot-plant.kt
+++ b/server/core/src/main/java/dev/slimevr/skeleton/fkprocessors/foot-plant.kt
@@ -1,23 +1,36 @@
package dev.slimevr.skeleton.fkprocessors
+import com.jme3.math.FastMath
import dev.slimevr.skeleton.ComputedSkeleton
import dev.slimevr.skeleton.InputSkeleton
import dev.slimevr.skeleton.Skeleton
import dev.slimevr.skeleton.SkeletonFkProcessor
import io.github.axisangles.ktmath.Quaternion
+import io.github.axisangles.ktmath.Vector3
import solarxr_protocol.datatypes.BodyPart
+import kotlin.math.abs
// The max height to plant feet by
-const val ROTATION_CORRECTION_VERTICAL = 0.1f
+private const val ROTATION_CORRECTION_VERTICAL = 0.1f
+private const val ANKLE_DOWN_MIN = 0.35f
+private const val ANKLE_DOWN_MAX = 0.63f
fun computeFootPlantRatio(
ankleHeight: Float,
floorLevel: Float,
+ ankleLocalPosition: Vector3,
): Float {
val ankleHeightAboveFloor = ankleHeight - floorLevel
val ratioOfRangeFromFloor = (ankleHeightAboveFloor / ROTATION_CORRECTION_VERTICAL).coerceIn(0f, 1f)
+
// Ratio of range *to* floor
- return 1f - ratioOfRangeFromFloor
+ val rangeToFloorRatio = 1f - ratioOfRangeFromFloor
+
+ // Lessen the ratio as the ankle doesn't point down
+ val ankleDownDirection = abs(ankleLocalPosition.unit().y.coerceAtMost(0f))
+ val ankleDownRatio = FastMath.remapClamped(ankleDownDirection, ANKLE_DOWN_MIN, ANKLE_DOWN_MAX, 0f, 1f)
+
+ return rangeToFloorRatio * ankleDownRatio
}
fun correctFootAttitude(
@@ -27,21 +40,26 @@ fun correctFootAttitude(
): Quaternion = rotation.interpQ(rotation.eulerHeading(), correctionRatio)
class FootPlantFkProcessor(val skeleton: Skeleton) : SkeletonFkProcessor {
- val bodyParts: Array = arrayOf(BodyPart.LEFT_FOOT, BodyPart.RIGHT_FOOT)
-
+ val bodyParts = arrayOf(
+ BodyPart.LEFT_LOWER_LEG to BodyPart.LEFT_FOOT,
+ BodyPart.RIGHT_LOWER_LEG to BodyPart.RIGHT_FOOT,
+ )
override fun process(mutableInputSkeleton: InputSkeleton, fk: ComputedSkeleton, floorLevel: Float) {
if (!skeleton.effectiveFootPlant) return
- for (bodyPart in bodyParts) {
- val input = mutableInputSkeleton[bodyPart] ?: continue
+ for ((anklePart, footPart) in bodyParts) {
+ val input = mutableInputSkeleton[footPart] ?: continue
if (input.isRotationActive) continue
- val output = fk[bodyPart] ?: continue
- mutableInputSkeleton[bodyPart] = input.copy(
+
+ val foot = fk[footPart] ?: continue
+ val ankle = fk[anklePart] ?: continue
+ mutableInputSkeleton[footPart] = input.copy(
rotation = correctFootAttitude(
input.rotation,
computeFootPlantRatio(
- output.headPosition.y,
+ foot.headPosition.y,
floorLevel,
+ ankle.localTailPosition,
),
),
)
diff --git a/server/core/src/main/java/dev/slimevr/skeleton/fkprocessors/toe-snap.kt b/server/core/src/main/java/dev/slimevr/skeleton/fkprocessors/toe-snap.kt
index 515791c3e..53cef8dd4 100644
--- a/server/core/src/main/java/dev/slimevr/skeleton/fkprocessors/toe-snap.kt
+++ b/server/core/src/main/java/dev/slimevr/skeleton/fkprocessors/toe-snap.kt
@@ -10,10 +10,10 @@ import io.github.axisangles.ktmath.Vector3
import solarxr_protocol.datatypes.BodyPart
import kotlin.math.abs
-const val TOE_SNAP_RANGE_MULTIPLIER = 2f
-const val MAX_TOE_SNAP_RATIO = 0.8f
-const val ANKLE_DOWN_MIN = 0.65f
-const val ANKLE_DOWN_MAX = 0.85f
+private const val TOE_SNAP_RANGE_MULTIPLIER = 1.64f
+private const val MAX_TOE_SNAP_RATIO = 0.8f
+private const val ANKLE_DOWN_MIN = 0.75f
+private const val ANKLE_DOWN_MAX = 0.94f
fun computeToeSnapRatio(
ankleHeight: Float,
@@ -65,6 +65,7 @@ class ToeSnapFkProcessor(val skeleton: Skeleton) : SkeletonFkProcessor {
if (input.isRotationActive) continue
val length = input.offset.len()
if (length <= 0f) continue
+
val ankle = fk[anklePart] ?: continue
val foot = fk[footPart] ?: continue
mutableInputSkeleton[footPart] = input.copy(
diff --git a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/spine.kt b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/spine.kt
index c0510d5e3..8eb3bbd4d 100644
--- a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/spine.kt
+++ b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/spine.kt
@@ -43,7 +43,7 @@ private val SPINE_SOURCE_RELIABILITY = arrayOf(
SpineSource.UPPER_CHEST to Reliability(-11.5f, -20f), // Itself
// To
SpineSource.LOWER_CHEST to Reliability(-6f, -15f, 0f),
- SpineSource.UPPER_WAIST to Reliability(1.5f, 4f, 0.4f),
+ SpineSource.UPPER_WAIST to Reliability(1.5f, 4f, 0.44f),
SpineSource.LOWER_WAIST to Reliability(2f, 5f, 0.4f),
SpineSource.HIP to Reliability(4f, 6.25f, 0.4f),
SpineSource.UPPER_LEGS to Reliability(4f, 5f),
@@ -53,7 +53,7 @@ private val SPINE_SOURCE_RELIABILITY = arrayOf(
SpineSource.UPPER_CHEST to Reliability(-18f, 40f),
SpineSource.LOWER_CHEST to Reliability(30f), // Itself
// To
- SpineSource.UPPER_WAIST to Reliability(1.5f, 10f, 0.4f),
+ SpineSource.UPPER_WAIST to Reliability(1.5f, 10f, 0.44f),
SpineSource.LOWER_WAIST to Reliability(2f, 8f, 0.4f),
SpineSource.HIP to Reliability(4f, 7.25f, 0.4f),
SpineSource.UPPER_LEGS to Reliability(4f, 6f),
diff --git a/server/desktop/src/main/java/dev/slimevr/desktop/trackingchecklist/behaviours.kt b/server/desktop/src/main/java/dev/slimevr/desktop/trackingchecklist/behaviours.kt
index 1e663643d..44c4c1767 100644
--- a/server/desktop/src/main/java/dev/slimevr/desktop/trackingchecklist/behaviours.kt
+++ b/server/desktop/src/main/java/dev/slimevr/desktop/trackingchecklist/behaviours.kt
@@ -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