From 6e336310055dcd7aa3a2f52b5d98c8b385d91983 Mon Sep 17 00:00:00 2001 From: Erimel Date: Mon, 2 Nov 2026 15:53:01 -0500 Subject: [PATCH] Simplify filtering --- .../main/java/dev/slimevr/config/settings.kt | 2 +- .../java/dev/slimevr/skeleton/behaviours.kt | 14 +-- .../skeleton/computedprocessors/velocity.kt | 25 ++-- .../skeleton/inputprocessors/filtering.kt | 110 ++++++++---------- .../main/java/dev/slimevr/skeleton/module.kt | 5 +- .../main/java/dev/slimevr/skeleton/reducer.kt | 3 +- .../dev/slimevr/solarxr/driver/incoming.kt | 3 - .../tracker/behaviours/rotation-refresh.kt | 9 +- .../slimevr/tracker/behaviours/to-skeleton.kt | 6 - .../main/java/dev/slimevr/tracker/module.kt | 6 +- .../main/java/dev/slimevr/tracker/reducer.kt | 2 - 11 files changed, 74 insertions(+), 111 deletions(-) diff --git a/server/core/src/main/java/dev/slimevr/config/settings.kt b/server/core/src/main/java/dev/slimevr/config/settings.kt index 0255f4a3d..210eac9af 100644 --- a/server/core/src/main/java/dev/slimevr/config/settings.kt +++ b/server/core/src/main/java/dev/slimevr/config/settings.kt @@ -117,7 +117,7 @@ data class SkeletonTogglesConfig( @Serializable data class SkeletonRatiosConfig( val smoothingStrength: Float = 0.15f, - val predictionStrength: Float = 0.25f, + val predictionStrength: Float = 0.3f, val spineCurvature: Float = 0.75f, val imputeSpineFromUpperToLower: Float = DEFAULT_SPINE_UPPER_LOWER, val interpolateUpperLegsTwistWithLowerLegs: Float = 0.85f, diff --git a/server/core/src/main/java/dev/slimevr/skeleton/behaviours.kt b/server/core/src/main/java/dev/slimevr/skeleton/behaviours.kt index d33186022..1f3fd63e9 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/behaviours.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/behaviours.kt @@ -73,14 +73,7 @@ class LocalizerResetBehaviour(val settings: Settings) : SkeletonBehaviour { * randomPacketLoss and constantPacketLoss are from 0 to 1 * sendPosition is for the head data. */ -class YouSpinMeRightRoundBehaviour( - val inputHz: Int = 100, - val speed: Float = 1f, - val randomPacketLoss: Float = 0f, - val constantPacketLoss: Float = 0f, - val sendPosition: Boolean = false, - val timeAgo: Duration = Duration.ZERO, -) : 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) { receiver.context.scope.launch { val interval = (millisecondsInSecond / inputHz.toFloat()).toLong().milliseconds @@ -98,7 +91,6 @@ class YouSpinMeRightRoundBehaviour( SkeletonActions.SetBonePose( BodyPart.LOWER_CHEST, Vector3.ZERO, - timeSource.markNow() - timeAgo, Quaternion.fromRotationVector(Vector3(cos(elapsed), sin(elapsed), 0f)), Vector3.ZERO, null, @@ -108,7 +100,6 @@ class YouSpinMeRightRoundBehaviour( SkeletonActions.SetBonePose( BodyPart.LEFT_LOWER_LEG, Vector3.ZERO, - timeSource.markNow() - timeAgo, Quaternion.fromRotationVector(Vector3(cos(elapsed + 1000), sin(elapsed + 1000), 0f)), Vector3.ZERO, null, @@ -124,7 +115,6 @@ class YouSpinMeRightRoundBehaviour( SkeletonActions.SetBonePose( BodyPart.HEAD, Vector3.ZERO, - timeSource.markNow() - timeAgo, Quaternion.IDENTITY, Vector3.ZERO, Vector3(circleX, state.skeletonHeight + jumpHeight, circleZ), @@ -309,7 +299,7 @@ class ComputedSkeletonBehaviour( // If head changed position, set the new position in state (for Localizer). if (bodyPart == BodyPart.HEAD && !boneInput.isPositionActive && boneInput.position != previous?.position) { - receiver.context.dispatch(SkeletonActions.SetBonePose(BodyPart.HEAD, Vector3.ZERO, null, null, null, boneInput.position, false)) + receiver.context.dispatch(SkeletonActions.SetBonePose(BodyPart.HEAD, Vector3.ZERO, null, null, boneInput.position, false)) } } // Inputs changed; re-run FK diff --git a/server/core/src/main/java/dev/slimevr/skeleton/computedprocessors/velocity.kt b/server/core/src/main/java/dev/slimevr/skeleton/computedprocessors/velocity.kt index b2df48c8c..5ac0d5f12 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/computedprocessors/velocity.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/computedprocessors/velocity.kt @@ -20,12 +20,17 @@ private data class BoneSample( val position: Vector3, ) -private fun computeVelocity(currentVelocityData: BoneSample, lastVelocityData: BoneSample, deltaTime: Float): Velocity { - val deltaPosition = currentVelocityData.position - lastVelocityData.position - val deltaRotation = currentVelocityData.rotation / lastVelocityData.rotation +private data class VelocitySample( + val boneSample: BoneSample, + val velocity: Velocity, +) + +private fun computeVelocity(currentBoneSample: BoneSample, lastBoneSample: BoneSample, deltaTime: Float): Velocity { + val deltaPosition = currentBoneSample.position - lastBoneSample.position + val deltaRotation = currentBoneSample.rotation / lastBoneSample.rotation return Velocity( linear = deltaPosition / deltaTime, - angular = currentVelocityData.rotation.sandwich(deltaRotation.toRotationVectorQ()) / deltaTime, + angular = currentBoneSample.rotation.sandwich(deltaRotation.toRotationVectorQ()) / deltaTime, ) } @@ -44,7 +49,7 @@ private fun smoothVelocity(currentVelocity: Velocity, lastVelocity: Velocity, de class VelocityComputedProcessor : SkeletonComputedProcessor, ResettableSkeletonProcessor { - private val lastVelocities: BodyPartMap> = bodyPartMap() + private val lastVelocities: BodyPartMap = bodyPartMap() private var lastProcessTime = timeSource.markNow() override fun process(mutableComputedSkeleton: ComputedSkeleton, inputSkeleton: InputSkeleton) { @@ -54,14 +59,16 @@ class VelocityComputedProcessor : lastProcessTime = now for ((bodyPart, bone) in mutableComputedSkeleton) { + val lastVelocitySample = lastVelocities[bodyPart] + // Compute current velocity val currentBoneSample = BoneSample(bone.rotation, bone.tailPosition) - val currentVelocity = lastVelocities[bodyPart]?.second?.let { computeVelocity(currentBoneSample, it, deltaTime) } ?: ZERO_VELOCITY - val smoothedVelocity = smoothVelocity(currentVelocity, lastVelocities[bodyPart]?.first ?: ZERO_VELOCITY, deltaTime) + val currentVelocity = lastVelocitySample?.boneSample?.let { computeVelocity(currentBoneSample, it, deltaTime) } ?: ZERO_VELOCITY + val smoothedVelocity = smoothVelocity(currentVelocity, lastVelocitySample?.velocity ?: ZERO_VELOCITY, deltaTime) + mutableComputedSkeleton[bodyPart] = bone.copy(velocity = smoothedVelocity) - - lastVelocities[bodyPart] = smoothedVelocity to currentBoneSample + lastVelocities[bodyPart] = VelocitySample(currentBoneSample, smoothedVelocity) } } diff --git a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/filtering.kt b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/filtering.kt index 01a564c5d..3241858a8 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/filtering.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/inputprocessors/filtering.kt @@ -21,16 +21,16 @@ import kotlin.time.Duration.Companion.seconds // Upsampling private val UPSAMPLING_EXTRAPOLATION_MAX_DURATION = 0.8.seconds -// Upsampling (technically Prediction but always on) +// Upsampling (technically Prediction but always active) private const val UPSAMPLING_EXTRAPOLATION_LOG_BASE_MIN = 7f private const val UPSAMPLING_EXTRAPOLATION_LOG_BASE_MAX = 3f -// Upsampling (technically Smoothing but always on) +// Upsampling (technically Smoothing but always active) private const val UPSAMPLING_TIME_CARRYOVER_MIN = 0.6f private const val UPSAMPLING_TIME_CARRYOVER_MAX = 0.9f // Smoothing -private const val SMOOTHING_MS_MAX = 70.0 +private const val SMOOTHING_MS_MAX = 75.0 // Prediction private const val PREDICTION_MS_MAX = 30.0 @@ -49,12 +49,10 @@ private data class BoneSample( private data class BoneSamples( // These get assigned everytime we get a new pose for a bone val fromSample: BoneSample?, - val targetSample: BoneSample?, + val targetSample: BoneSample, val poseTime: ComparableTimeMark, - val timeBetweenSamples: Duration, - val timeBetweenRotations: Duration, - val poseDelay: Duration, - val predictedRotationDelta: Quaternion?, + val sampleTime: ComparableTimeMark, + val timeBetweenPoses: Duration, val predictedRotation: Quaternion, // Mutable since these get changed every skeleton frame even if no new pose is received var runningSample: BoneSample?, @@ -78,31 +76,39 @@ private fun computeTimeBetweenPoses( return (lastPoseCarryoverTime + poseTimeDelta).coerceAtLeast(Duration.ZERO) } -private fun computePredictedRotationDelta( +private fun computePredictedRotation( previousRotation: Quaternion?, - previousPredictedRotationDelta: Quaternion?, + previousPredictedRotation: Quaternion?, targetRotation: Quaternion, - rotationPredictionTime: Duration, + predictionTime: Duration, poseTimeDelta: Duration, -) = previousRotation?.let { +): Quaternion { + if (previousRotation == null) return targetRotation + // Use some of the previous prediction - val previousDeltaDecayed = previousPredictedRotationDelta?.pow(PREVIOUS_PREDICTION_DECAY) ?: Quaternion.IDENTITY - if (poseTimeDelta <= Duration.ZERO) return@let previousDeltaDecayed - val currentDelta = (it.inv() * targetRotation).pow((rotationPredictionTime / poseTimeDelta).toFloat()) - previousDeltaDecayed * currentDelta + val previousPredictionDelta = previousPredictedRotation?.localAbout(previousRotation)?.pow(PREVIOUS_PREDICTION_DECAY) + ?: Quaternion.IDENTITY + + val currentDelta = if (poseTimeDelta > Duration.ZERO) { + val t = (predictionTime / poseTimeDelta).toFloat() + targetRotation.localAbout(previousRotation).pow(t) + } else { + Quaternion.IDENTITY + } + + return targetRotation * previousPredictionDelta * currentDelta } private fun computeInterpolationRatio( timeSinceLastPose: Duration, - smoothedTimeBetweenPoses: Duration, + timeBetweenPoses: Duration, extrapolationLogBase: Double, - multiplier: Float = 1f, ): Float { // Time between now and tracker data. - val clampedTimeSinceLastPose = timeSinceLastPose.coerceAtMost(smoothedTimeBetweenPoses + UPSAMPLING_EXTRAPOLATION_MAX_DURATION) + val timeSinceLastPoseClamped = timeSinceLastPose.coerceAtMost(timeBetweenPoses + UPSAMPLING_EXTRAPOLATION_MAX_DURATION) // Ratio of how close we should be to the next pose. // 0 = we just got started, 1 = we should have the next one, >1 = we didn't get it yet; packet lost or late - val rawRatio = (if (smoothedTimeBetweenPoses > Duration.ZERO) clampedTimeSinceLastPose / smoothedTimeBetweenPoses else 1.0) * multiplier + val rawRatio = if (timeBetweenPoses > Duration.ZERO) timeSinceLastPoseClamped / timeBetweenPoses else 1.0 // In case the rawRatio is >1, we extrapolate using log to keep some smooth perceived movement. val extrapolationAmount = log((rawRatio).coerceAtLeast(1.0), extrapolationLogBase) // Resulting ratio to use for interpolation, including extrapolation if any. @@ -131,28 +137,21 @@ private fun computeInterpolationRatio( * * ----- Prediction ----- * Prediction decides how far away the target rotation is using an average of past rotation deltas. - * - * - * This is human slop. - Erimel */ class FilteringInputProcessor(val settings: Settings) : SkeletonInputProcessor, ResettableSkeletonProcessor { private val boneSamples: BodyPartMap = bodyPartMap() - var lastProcessTime = timeSource.markNow() + private var lastProcessEndTime = timeSource.markNow() override fun process(mutableInputSkeleton: InputSkeleton, skeletonHeight: Float) { val now = timeSource.markNow() - val deltaTime = now - lastProcessTime - lastProcessTime = now val skeletonRatios = settings.context.state.value.data.skeletonConfig.ratios val timeCarryover = FastMath.remapClamped(skeletonRatios.smoothingStrength, 0f, 1f, UPSAMPLING_TIME_CARRYOVER_MIN, UPSAMPLING_TIME_CARRYOVER_MAX).toDouble() val extrapolationLogBase = FastMath.remapClamped(skeletonRatios.predictionStrength, 0f, 1f, UPSAMPLING_EXTRAPOLATION_LOG_BASE_MIN, UPSAMPLING_EXTRAPOLATION_LOG_BASE_MAX).toDouble() val smoothingTime = (skeletonRatios.smoothingStrength * SMOOTHING_MS_MAX).milliseconds val predictionTime = (skeletonRatios.predictionStrength * PREDICTION_MS_MAX).milliseconds - val smoothingEnabled = skeletonRatios.smoothingStrength > 0 - val predictionEnabled = skeletonRatios.predictionStrength > 0 for ((bodyPart, bone) in mutableInputSkeleton) { if (bone.poseTime == null) { @@ -160,57 +159,51 @@ class FilteringInputProcessor(val settings: Settings) : continue } - // Get our samples for this bone - var samples = boneSamples[bodyPart] + val previousSamples = boneSamples[bodyPart] // New pose data updates the samples - if (bone.poseTime != samples?.poseTime) { + val samples = if (bone.poseTime != previousSamples?.poseTime) { // Use the runningSample as starting point if any to resume where we were at last frame - val fromSample = samples?.runningSample ?: samples?.targetSample + val fromSample = previousSamples?.runningSample ?: previousSamples?.targetSample // Need to store this data in time because we mutate the skeleton bones val targetSample = BoneSample.fromBone(bone) // How much time has passed between the last 2 bone poses - val poseTimeDelta = computePoseTimeDelta(samples?.poseTime, bone.poseTime) + val poseTimeDelta = computePoseTimeDelta(previousSamples?.poseTime, bone.poseTime) // The time we'll take to interpolate to the new pose - val timeBetweenSamples = computeTimeBetweenPoses(poseTimeDelta, samples?.timeLeftForLastPose, timeCarryover) - val timeBetweenRotations = timeBetweenSamples + smoothingTime - val poseDelay = now - bone.poseTime + val timeBetweenPoses = computeTimeBetweenPoses(poseTimeDelta, previousSamples?.timeLeftForLastPose, timeCarryover) - // The predicted target rotation change - val predictedRotationDelta = if (predictionEnabled) { - computePredictedRotationDelta( - samples?.targetSample?.rotation, - samples?.predictedRotationDelta, + // The predicted target rotation + val predictedRotation = if (predictionTime > Duration.ZERO) { + // Prediction enabled + computePredictedRotation( + previousSamples?.targetSample?.rotation, + previousSamples?.predictedRotation, targetSample.rotation, predictionTime, poseTimeDelta, ) } else { - null + targetSample.rotation } - // The predicted target rotation - val predictedRotation = predictedRotationDelta?.let { targetSample.rotation * it } ?: targetSample.rotation // New samples - samples = BoneSamples(fromSample, targetSample, bone.poseTime, timeBetweenSamples, timeBetweenRotations, poseDelay, predictedRotationDelta, predictedRotation, null, Duration.ZERO) + BoneSamples(fromSample, targetSample, bone.poseTime, lastProcessEndTime, timeBetweenPoses, predictedRotation, null, Duration.ZERO) + } else { + previousSamples } // Filtering - if (samples.fromSample != null && samples.targetSample != null) { - // Calculate the delay multiplier using the ratio math to prevent it being too big - val delayMultiplier = 1f + computeInterpolationRatio(samples.poseDelay, samples.timeBetweenSamples, extrapolationLogBase) - // Add deltaTime because else it'd be 0 on the frame we get a new pose - val timeSinceLastPose = now - (bone.poseTime + samples.poseDelay - deltaTime) - val upsamplingRatio = computeInterpolationRatio(timeSinceLastPose, samples.timeBetweenSamples, extrapolationLogBase, delayMultiplier) + if (samples.fromSample != null) { + val timeSinceLastPose = now - samples.sampleTime + val upsamplingRatio = computeInterpolationRatio(timeSinceLastPose, samples.timeBetweenPoses, extrapolationLogBase) // Rotation val rotation = if (bone.isRotationActive) { - val smoothingRatio = if (smoothingEnabled) { - // Compute ratio with smoothing time. - // timeBetweenRotations has some carry over from previous poses - computeInterpolationRatio(timeSinceLastPose, samples.timeBetweenRotations + smoothingTime, extrapolationLogBase, delayMultiplier) + val smoothingRatio = if (smoothingTime > Duration.ZERO) { + // Smoothing enabled + computeInterpolationRatio(timeSinceLastPose, samples.timeBetweenPoses + smoothingTime, extrapolationLogBase) } else { upsamplingRatio } @@ -240,19 +233,18 @@ class FilteringInputProcessor(val settings: Settings) : // Update running sample so that we resume from where we left off if we get a new pose next frame samples.runningSample = BoneSample.fromBone(newBone) - // Time left for this pose, using the ratio to account for non-linear extrapolation - val timeLeftRatio = computeInterpolationRatio(timeSinceLastPose, samples.timeBetweenSamples, extrapolationLogBase).toDouble() - samples.timeLeftForLastPose = samples.timeBetweenSamples - (samples.timeBetweenSamples * timeLeftRatio) + samples.timeLeftForLastPose = samples.timeBetweenPoses - (samples.timeBetweenPoses * upsamplingRatio.toDouble()) } // Save updated samples boneSamples[bodyPart] = samples } + + lastProcessEndTime = now } override fun reset(resetType: ResetType) { boneSamples.clear() - lastProcessTime = timeSource.markNow() } } diff --git a/server/core/src/main/java/dev/slimevr/skeleton/module.kt b/server/core/src/main/java/dev/slimevr/skeleton/module.kt index e6244e603..22fba43af 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/module.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/module.kt @@ -32,8 +32,6 @@ import solarxr_protocol.datatypes.BodyPart import solarxr_protocol.rpc.ResetType import solarxr_protocol.rpc.SkeletonBone import kotlin.time.ComparableTimeMark -import kotlin.time.Duration -import kotlin.time.Duration.Companion.milliseconds data class Velocity( /** In meters/s */ @@ -183,7 +181,6 @@ sealed interface SkeletonActions { data class SetBonePose( val bodyPart: BodyPart, val boneOffset: Vector3?, - val poseTime: ComparableTimeMark?, val rotation: Quaternion?, val acceleration: Vector3?, val position: Vector3?, @@ -269,7 +266,7 @@ class Skeleton( ProportionsBehaviour(ctx.config.userConfig), HeightLogBehaviour(), LocalizerResetBehaviour(settings), -// YouSpinMeRightRoundBehaviour(inputHz = 100, speed = 1f, randomPacketLoss = 0f, constantPacketLoss = 0f, sendPosition = false, 10.milliseconds), +// YouSpinMeRightRoundBehaviour(inputHz = 100, speed = 1f, randomPacketLoss = 0f, constantPacketLoss = 0f, sendPosition = true), ComputedSkeletonBehaviour( hz = hz, waiter = waiter, diff --git a/server/core/src/main/java/dev/slimevr/skeleton/reducer.kt b/server/core/src/main/java/dev/slimevr/skeleton/reducer.kt index dc70f326a..365a0d210 100644 --- a/server/core/src/main/java/dev/slimevr/skeleton/reducer.kt +++ b/server/core/src/main/java/dev/slimevr/skeleton/reducer.kt @@ -4,7 +4,6 @@ import dev.slimevr.util.timeSource import io.github.axisangles.ktmath.Quaternion import io.github.axisangles.ktmath.Vector3 import solarxr_protocol.datatypes.BodyPart -import kotlin.time.Duration.Companion.milliseconds fun reduce(state: SkeletonState, action: SkeletonActions): SkeletonState = when (action) { is SkeletonActions.SetBonePose -> { @@ -13,7 +12,7 @@ fun reduce(state: SkeletonState, action: SkeletonActions): SkeletonState = when boneInputs = state.boneInputs.mutateCopy { it[action.bodyPart] = bone.copy( boneOffset = action.boneOffset ?: bone.boneOffset, - poseTime = action.poseTime ?: bone.poseTime, + poseTime = timeSource.markNow(), rotation = action.rotation ?: bone.rotation, acceleration = action.acceleration ?: bone.acceleration, position = action.position ?: bone.position, diff --git a/server/core/src/main/java/dev/slimevr/solarxr/driver/incoming.kt b/server/core/src/main/java/dev/slimevr/solarxr/driver/incoming.kt index 88d3311a7..94e4f064b 100644 --- a/server/core/src/main/java/dev/slimevr/solarxr/driver/incoming.kt +++ b/server/core/src/main/java/dev/slimevr/solarxr/driver/incoming.kt @@ -24,8 +24,6 @@ import solarxr_protocol.driver_protocol.UpdateTrackerBattery import solarxr_protocol.driver_protocol.UpdateTrackerPosition import solarxr_protocol.driver_protocol.UpdateTrackerStatus import kotlin.time.ComparableTimeMark -import kotlin.time.Duration.Companion.milliseconds -import kotlin.time.Duration.Companion.seconds import kotlin.to // These are all only defaults and the user can edit any and they will save. @@ -212,7 +210,6 @@ class DriverIncomingTrackersBehaviour( rotation = event.rotation?.toQuaternion()?.times(rotationOffset), acceleration = acceleration, position = event.position?.toVector3(), - poseTime = timeSource.markNow() - 5.milliseconds, // TODO can we get this from driver? ), ) }.launchIn(receiver.context.scope) diff --git a/server/core/src/main/java/dev/slimevr/tracker/behaviours/rotation-refresh.kt b/server/core/src/main/java/dev/slimevr/tracker/behaviours/rotation-refresh.kt index 29b036be5..e7342d942 100644 --- a/server/core/src/main/java/dev/slimevr/tracker/behaviours/rotation-refresh.kt +++ b/server/core/src/main/java/dev/slimevr/tracker/behaviours/rotation-refresh.kt @@ -23,13 +23,6 @@ class TrackerRotationRefreshBehaviour : TrackerBehaviour { } companion object { - fun getRotationRefreshAction(trackerState: TrackerState) = TrackerActions.SetRotation( - trackerState.rawRotation, - trackerState.rawAcceleration, - trackerState.rawMagnetometer, - trackerState.position, - _root_ide_package_.dev.slimevr.util.timeSource.markNow(), - false, - ) + fun getRotationRefreshAction(trackerState: TrackerState) = TrackerActions.SetRotation(trackerState.rawRotation, trackerState.rawAcceleration, trackerState.rawMagnetometer, trackerState.position, false) } } diff --git a/server/core/src/main/java/dev/slimevr/tracker/behaviours/to-skeleton.kt b/server/core/src/main/java/dev/slimevr/tracker/behaviours/to-skeleton.kt index 5378268e5..2f2bd81e6 100644 --- a/server/core/src/main/java/dev/slimevr/tracker/behaviours/to-skeleton.kt +++ b/server/core/src/main/java/dev/slimevr/tracker/behaviours/to-skeleton.kt @@ -4,9 +4,7 @@ import dev.slimevr.skeleton.SkeletonActions import dev.slimevr.tracker.Tracker import dev.slimevr.tracker.TrackerActions import dev.slimevr.tracker.TrackerBehaviour -import dev.slimevr.tracker.TrackerState import dev.slimevr.util.isActive -import dev.slimevr.util.timeSource import io.github.axisangles.ktmath.Vector3 import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.distinctUntilChanged @@ -15,10 +13,7 @@ import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import solarxr_protocol.datatypes.BodyPart -import solarxr_protocol.datatypes.DeviceOrigin import solarxr_protocol.datatypes.TrackerStatus -import kotlin.time.ComparableTimeMark -import kotlin.time.Duration.Companion.milliseconds class TrackerToSkeletonBehaviour : TrackerBehaviour { var lastBodyPartSent: BodyPart? = null @@ -52,7 +47,6 @@ class TrackerToSkeletonBehaviour : TrackerBehaviour { val bonePoseActions = SkeletonActions.SetBonePose( bodyPart, trackerState.boneOffsets[bodyPart], - trackerState.lastPoseTime, trackerState.rotation, trackerState.acceleration, trackerState.position, diff --git a/server/core/src/main/java/dev/slimevr/tracker/module.kt b/server/core/src/main/java/dev/slimevr/tracker/module.kt index 5f86cb81c..3137822b9 100644 --- a/server/core/src/main/java/dev/slimevr/tracker/module.kt +++ b/server/core/src/main/java/dev/slimevr/tracker/module.kt @@ -18,7 +18,6 @@ import dev.slimevr.tracker.behaviours.TrackerToSkeletonBehaviour import dev.slimevr.tracker.behaviours.TrackerTpsBehaviour import dev.slimevr.tracker.behaviours.TrackerYawResetSmoothingBehaviour import dev.slimevr.util.isActive -import dev.slimevr.util.timeSource import io.github.axisangles.ktmath.Quaternion import io.github.axisangles.ktmath.Vector3 import kotlinx.coroutines.CoroutineScope @@ -30,7 +29,6 @@ import solarxr_protocol.datatypes.TrackerStatus import solarxr_protocol.datatypes.hardware_info.ImuType import solarxr_protocol.datatypes.hardware_info.TrackerDataType import solarxr_protocol.rpc.ResetType -import kotlin.time.ComparableTimeMark import kotlin.time.Duration // A tracker is initialized as ROTATING to prevent TapDetection and Stay Aligned from running immediately. @@ -83,7 +81,6 @@ data class TrackerState( val imuTemp: Float?, val accumulatedTicks: UShort, val tps: UShort, - val lastPoseTime: ComparableTimeMark, val status: TrackerStatus, val completedRestCalibration: Boolean?, val magStatus: MagnetometerStatus, @@ -112,7 +109,7 @@ sealed interface TrackerActions { data class SetMagStatus(val status: MagnetometerStatus) : TrackerActions data class SetStatus(val status: TrackerStatus) : TrackerActions data class SetDriverName(val driverName: String?) : TrackerActions - data class SetRotation(val rotation: Quaternion? = null, val acceleration: Vector3? = null, val magnetometer: Vector3? = null, val position: Vector3? = null, val poseTime: ComparableTimeMark = timeSource.markNow(), val increaseTps: Boolean = true) : TrackerActions + data class SetRotation(val rotation: Quaternion? = null, val acceleration: Vector3? = null, val magnetometer: Vector3? = null, val position: Vector3? = null, val increaseTps: Boolean = true) : TrackerActions data class SetMountingOrientation(val mountingOrientation: HeadingAlignment) : TrackerActions data class FullReset(val referenceRotation: Quaternion?, val resetHmdAttitude: Boolean = false) : TrackerActions data class YawReset(val referenceRotation: Quaternion?, val smoothTime: Duration = Duration.ZERO) : TrackerActions @@ -227,7 +224,6 @@ class Tracker( imuTemp = null, accumulatedTicks = 0u, tps = 0u, - lastPoseTime = timeSource.markNow(), status = TrackerStatus.DISCONNECTED, completedRestCalibration = null, magStatus = MagnetometerStatus.NOT_SUPPORTED, diff --git a/server/core/src/main/java/dev/slimevr/tracker/reducer.kt b/server/core/src/main/java/dev/slimevr/tracker/reducer.kt index 44f17bee0..8401d76e3 100644 --- a/server/core/src/main/java/dev/slimevr/tracker/reducer.kt +++ b/server/core/src/main/java/dev/slimevr/tracker/reducer.kt @@ -1,6 +1,5 @@ package dev.slimevr.tracker -import dev.slimevr.util.timeSource import io.github.axisangles.ktmath.Quaternion import solarxr_protocol.datatypes.MountingMethod import solarxr_protocol.rpc.ResetType @@ -77,7 +76,6 @@ fun reduce( position = position, accumulatedTicks = accumulatedTicks, rotationDirty = false, - lastPoseTime = action.poseTime, lastReference = null, ) }