mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-04-06 02:01:58 +02:00
Compare commits
1 Commits
TheButlah-
...
height-con
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c9cdf71a7 |
@@ -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?
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user