Compare commits

...

1 Commits

Author SHA1 Message Date
Butterscotch!
5c9cdf71a7 Block out height config 2025-08-05 21:27:49 -04:00
2 changed files with 71 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
package dev.slimevr.protocol.rpc.heightconfig
import dev.slimevr.protocol.GenericConnection
import dev.slimevr.protocol.ProtocolAPI
import dev.slimevr.protocol.rpc.RPCHandler
import solarxr_protocol.rpc.RpcMessageHeader
class RPCHeightConfig(
rpcHandler: RPCHandler,
val api: ProtocolAPI,
) {
init {
rpcHandler.registerPacketListener(
0,
this::onStartHeightConfig,
)
rpcHandler.registerPacketListener(
0,
this::onStopHeightConfig,
)
rpcHandler.registerPacketListener(
0,
this::onRequestHeightConfigStatus,
)
}
private fun onStartHeightConfig(conn: GenericConnection, messageHeader: RpcMessageHeader) {
// Start process for both hmd height or floor height, this will run in the
// background and report the status
}
private fun onStopHeightConfig(conn: GenericConnection, messageHeader: RpcMessageHeader) {
// Stop height config process? May automatically report this, or just have this
// to cancel it
}
private fun onRequestHeightConfigStatus(conn: GenericConnection, messageHeader: RpcMessageHeader) {
// Return a status packet with info about the current measurements and status,
// this will be the same packet that we send during measurement?
}
}

View File

@@ -0,0 +1,30 @@
package dev.slimevr.setup
import dev.slimevr.autobone.StatsCalculator
import dev.slimevr.tracking.trackers.Tracker
class HeightConfigHandler(val tracker: Tracker) {
val maxDeviation = 0.1f
val stableTimeS = 3f
// TODO: Collect mean, max, and min values, use max/min to enforce max deviation
var accumulator = StatsCalculator()
var accumulatedTime = 0f
fun tick() {
val trackerHeight = tracker.position.y
// Accumulate height and track stability
accumulator.addValue(trackerHeight)
// TODO: Actual tick time
accumulatedTime += 0.1f
// If the height stability
if (accumulator.standardDeviation > maxDeviation) {
accumulator.reset()
accumulator.addValue(trackerHeight)
accumulatedTime = 0f
} else if (accumulatedTime >= stableTimeS) {
}
}
}