Compare commits

..
Author SHA1 Message Date
Erimel 476d81584d 25ms PREDICTION_CARRYOVER_TIME 2026-11-30 17:06:05 +01:00
Erimel 9937b42c46 skating correction stronger when no feet 2026-11-30 16:57:26 +01:00
Erimel a0f6bbfd92 PacketDropSimulatorInputProcessor 2026-11-30 16:50:35 +01:00
10 changed files with 50 additions and 31 deletions

No files matched your search

-2
View File
@@ -586,8 +586,6 @@ settings-driver-bones-description = Which bones this output sends is configured
settings-driver-bones-link = Open Bone Routing settings-driver-bones-link = Open Bone Routing
settings-driver-velocity = Send velocity settings-driver-velocity = Send velocity
settings-driver-velocity-description = Send linear and angular velocity data to the driver. Allows SteamVR/Monado tracker pose prediction and compatibility with applications that expect this data. settings-driver-velocity-description = Send linear and angular velocity data to the driver. Allows SteamVR/Monado tracker pose prediction and compatibility with applications that expect this data.
settings-driver-controller_tracking_fallback = Controller tracking fallback
settings-driver-controller_tracking_fallback-description = Override your controllers' tracking, with trackers mounted on your arms and hands, when your controllers lose tracking
## Tracker mechanics ## Tracker mechanics
settings-general-mounting_method = Mounting calibration method settings-general-mounting_method = Mounting calibration method
@@ -33,14 +33,12 @@ import { defineSettingsPage } from '@/components/settings/settings-definitions';
type DriverForm = { type DriverForm = {
enabled: boolean; enabled: boolean;
sendVelocity: boolean; sendVelocity: boolean;
controllerTrackingFallback: boolean;
}; };
function toForm(settings: DriverSettingsResponseT): DriverForm { function toForm(settings: DriverSettingsResponseT): DriverForm {
return { return {
enabled: settings.enabled, enabled: settings.enabled,
sendVelocity: settings.sendVelocity, sendVelocity: settings.sendVelocity,
controllerTrackingFallback: settings.controllerTrackingFallback,
}; };
} }
@@ -110,11 +108,6 @@ export const driverSettingsPage = defineSettingsPage({
title: 'settings-driver-velocity', title: 'settings-driver-velocity',
description: 'settings-driver-velocity-description', description: 'settings-driver-velocity-description',
}, },
controllerTrackingFallback: {
title: 'settings-driver-controller_tracking_fallback',
description:
'settings-driver-controller_tracking_fallback-description',
},
}, },
}, },
}, },
@@ -144,7 +137,6 @@ export function DriverSettings() {
const settingsReq = new ChangeDriverSettingsRequestT(); const settingsReq = new ChangeDriverSettingsRequestT();
settingsReq.enabled = values.enabled; settingsReq.enabled = values.enabled;
settingsReq.sendVelocity = values.sendVelocity; settingsReq.sendVelocity = values.sendVelocity;
settingsReq.controllerTrackingFallback = values.controllerTrackingFallback;
sendRPCPacket(RpcMessage.ChangeDriverSettingsRequest, settingsReq); sendRPCPacket(RpcMessage.ChangeDriverSettingsRequest, settingsReq);
}; };
@@ -251,19 +243,6 @@ export function DriverSettings() {
/> />
} }
/> />
<SettingRow
setting={groups.data.rows.controllerTrackingFallback}
controlId="driver-controller-tracking-fallback"
{...resetTo('controllerTrackingFallback')}
control={
<CheckBox
variant="toggle"
control={control}
name="controllerTrackingFallback"
id="driver-controller-tracking-fallback"
/>
}
/>
</SettingsGroup> </SettingsGroup>
</SettingsAdvanced> </SettingsAdvanced>
</div> </div>
@@ -46,7 +46,6 @@ data class BoneRoutingConfig(
data class DriverConfig( data class DriverConfig(
val enabled: Boolean = true, val enabled: Boolean = true,
val sendVelocity: Boolean = false, val sendVelocity: Boolean = false,
val controllerTrackingFallback: Boolean = false,
) )
// Used in TrackerActionConfig // Used in TrackerActionConfig
@@ -118,7 +117,7 @@ data class SkeletonTogglesConfig(
@Serializable @Serializable
data class SkeletonRatiosConfig( data class SkeletonRatiosConfig(
val smoothingStrength: Float = 0.15f, val smoothingStrength: Float = 0.15f,
val predictionStrength: Float = 0.30f, val predictionStrength: Float = 0.25f,
val spineCurvature: Float = 0.75f, val spineCurvature: Float = 0.75f,
val imputeSpineFromUpperToLower: Float = DEFAULT_SPINE_UPPER_LOWER, val imputeSpineFromUpperToLower: Float = DEFAULT_SPINE_UPPER_LOWER,
val interpolateUpperLegsTwistWithLowerLegs: Float = 0.85f, val interpolateUpperLegsTwistWithLowerLegs: Float = 0.85f,
@@ -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 { 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) { override fun observe(receiver: Skeleton) {
println("YouSpinMeRightRoundBehaviour sending fake bone data for simulation.")
receiver.context.scope.launch { receiver.context.scope.launch {
val interval = (millisecondsInSecond / inputHz.toFloat()).toLong().milliseconds val interval = (millisecondsInSecond / inputHz.toFloat()).toLong().milliseconds
val startTime = timeSource.markNow() val startTime = timeSource.markNow()
@@ -36,7 +36,7 @@ private const val SMOOTHING_MS_MAX = 50.0
// Prediction // Prediction
private const val PREDICTION_MS_MAX = 30.0 private const val PREDICTION_MS_MAX = 30.0
private val PREDICTION_CARRYOVER_TIME = 20.milliseconds // TODO might need to be tuned private val PREDICTION_CARRYOVER_TIME = 25.milliseconds
private const val MAX_PREDICTION_CARRYOVER_RATIO = 0.5 private const val MAX_PREDICTION_CARRYOVER_RATIO = 0.5
// Used to minimize latency even more for arm tracking where it is more noticeable // Used to minimize latency even more for arm tracking where it is more noticeable
@@ -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.FingersInputProcessor
import dev.slimevr.skeleton.inputprocessors.HeadPositionFallbackInputProcessor import dev.slimevr.skeleton.inputprocessors.HeadPositionFallbackInputProcessor
import dev.slimevr.skeleton.inputprocessors.NeckInputProcessor import dev.slimevr.skeleton.inputprocessors.NeckInputProcessor
import dev.slimevr.skeleton.inputprocessors.PacketDropSimulatorInputProcessor
import dev.slimevr.skeleton.inputprocessors.SpineInputProcessor import dev.slimevr.skeleton.inputprocessors.SpineInputProcessor
import dev.slimevr.skeleton.inputprocessors.ToesInputProcessor import dev.slimevr.skeleton.inputprocessors.ToesInputProcessor
import dev.slimevr.skeleton.targetprocessors.FloorClipTargetProcessor import dev.slimevr.skeleton.targetprocessors.FloorClipTargetProcessor
@@ -262,12 +263,13 @@ class Skeleton(
ProportionsBehaviour(ctx.config.userConfig), ProportionsBehaviour(ctx.config.userConfig),
HeightLogBehaviour(), HeightLogBehaviour(),
LocalizerResetBehaviour(settings), 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( ComputedSkeletonBehaviour(
hz = hz, hz = hz,
waiter = waiter, waiter = waiter,
// Run before FK on the inputs // Run before FK on the inputs
inputProcessors = listOf( inputProcessors = listOf(
// PacketDropSimulatorInputProcessor(0.85f),
FilteringInputProcessor(settings), FilteringInputProcessor(settings),
HeadPositionFallbackInputProcessor(), HeadPositionFallbackInputProcessor(),
FallbackInputProcessor(), FallbackInputProcessor(),
@@ -27,6 +27,7 @@ const val OFFSET_LIMIT_MAX = 0.20f
const val COM_DISTANCE_MULTIPLIER = 1.5f const val COM_DISTANCE_MULTIPLIER = 1.5f
const val LIFT_MIN = -0.85f const val LIFT_MIN = -0.85f
const val LIFT_MAX = 0.4f const val LIFT_MAX = 0.4f
const val ANKLE_MULTIPLIER = 1.25f
// Parameters to decide if a foot should be locked // Parameters to decide if a foot should be locked
// Higher makes it harder to unlock after being 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) { for ((bodyPart, ikTargetBodyPart, liftBodyPart) in skatingBodyParts) {
val bone = fk[bodyPart] ?: continue val bone = fk[bodyPart] ?: continue
val inputBone = inputSkeleton[bodyPart] ?: continue
val ikBone = fk[ikTargetBodyPart] ?: continue val ikBone = fk[ikTargetBodyPart] ?: continue
val liftBone = fk[liftBodyPart] ?: continue val liftBone = fk[liftBodyPart] ?: continue
val curPosition = mutableIkTargets[ikTargetBodyPart] ?: ikBone.tailPosition 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) val comMultiplier = computeComMultiplier(comDistances[bodyPart] ?: continue, comDistancesAverage)
// liftMultiplier decreases the threshold when the upper leg is lifted. Useful when sitting/lying down // liftMultiplier decreases the threshold when the upper leg is lifted. Useful when sitting/lying down
val liftMultiplier = computeLiftMultiplier(liftBone.localTailPosition) 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 // 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 // Compute if the body part should be locked
val floorLocked = floorLocked(lastState.locked, curPosition, floorLevel) val floorLocked = floorLocked(lastState.locked, curPosition, floorLevel)
@@ -24,7 +24,6 @@ import solarxr_protocol.rpc.RoutingOutputState
internal fun buildDriverSettingsResponse(config: DriverConfig) = DriverSettingsResponse( internal fun buildDriverSettingsResponse(config: DriverConfig) = DriverSettingsResponse(
enabled = config.enabled, enabled = config.enabled,
sendVelocity = config.sendVelocity, sendVelocity = config.sendVelocity,
controllerTrackingFallback = config.controllerTrackingFallback,
) )
class DriverSettingsBehaviour( class DriverSettingsBehaviour(
@@ -51,7 +50,6 @@ class DriverSettingsBehaviour(
driverConfig = driverConfig.copy( driverConfig = driverConfig.copy(
enabled = req.enabled, enabled = req.enabled,
sendVelocity = req.sendVelocity, sendVelocity = req.sendVelocity,
controllerTrackingFallback = req.controllerTrackingFallback,
), ),
) )
}, },