mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-20 17:11:20 -08:00
Temp patch for accel / Step Mounting
This commit is contained in:
1 parent
3d17273916
commit
6c25eae4f0
2 files changed
+9
-7
No files matched your search
@@ -60,7 +60,7 @@ val COEFFICIENTS = ButterworthCoefficients(
|
||||
const val START_THRESHOLD = 0.4f // in m/s^2
|
||||
const val END_THRESHOLD = 0.3f // in m/s^2
|
||||
const val MIN_MOVEMENT_DURATION_MS = 3000L
|
||||
const val ERROR_THRESHOLD = 0.3f
|
||||
const val ERROR_THRESHOLD = 0.4f // TODO increased temporarily. Used to be 0.3m
|
||||
|
||||
fun movementDetector(updates: Flow<TrackerSnapshot>) = flow {
|
||||
val lowpass = Vector3Butterworth(COEFFICIENTS)
|
||||
|
||||
@@ -23,13 +23,15 @@ import kotlin.random.Random
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
/**
|
||||
* Change between IMU axes and OpenGL/SteamVR axes
|
||||
*/
|
||||
/** Convert from IMU axes to OpenGL/SteamVR axes */
|
||||
internal val AXES_OFFSET = Quaternion.fromRotationVector(-FastMath.HALF_PI, 0f, 0f)
|
||||
|
||||
// TODO: Only apply this to firmwares <=0.7.3
|
||||
private val ACCEL_SENSOR_OFFSET_CORRECTION = Quaternion.rotationAroundZAxis(-FastMath.PI)
|
||||
|
||||
internal const val CONNECTION_TIMEOUT_MS = 5000L
|
||||
|
||||
internal suspend fun assignTracker(receiver: UDPConnection, device: Device, info: SensorInfo): Pair<Tracker, Boolean> {
|
||||
internal fun assignTracker(receiver: UDPConnection, device: Device, info: SensorInfo): Pair<Tracker, Boolean> {
|
||||
val deviceState = device.context.state.value
|
||||
val deviceHardwareId = deviceState.hardwareId ?: udpHardwareId(deviceState.macAddress, deviceState.address)
|
||||
val hardwareId = "$deviceHardwareId:${info.sensorId}"
|
||||
@@ -393,12 +395,12 @@ class SensorRotationBehaviour : UDPConnectionBehaviour {
|
||||
|
||||
receiver.packetEvents.onPacket<RotationAndAccel> { event ->
|
||||
val tracker = receiver.getTracker(event.data.sensorId) ?: return@onPacket
|
||||
tracker.context.dispatch(TrackerActions.SetRotation(rotation = AXES_OFFSET * event.data.rotation, acceleration = event.data.acceleration))
|
||||
tracker.context.dispatch(TrackerActions.SetRotation(rotation = AXES_OFFSET * event.data.rotation, acceleration = ACCEL_SENSOR_OFFSET_CORRECTION.sandwich(event.data.acceleration)))
|
||||
}.launchIn(receiver.context.scope)
|
||||
|
||||
receiver.packetEvents.onPacket<Accel> { event ->
|
||||
val tracker = receiver.getTracker(event.data.sensorId) ?: return@onPacket
|
||||
tracker.context.dispatch(TrackerActions.SetRotation(acceleration = event.data.acceleration))
|
||||
tracker.context.dispatch(TrackerActions.SetRotation(acceleration = ACCEL_SENSOR_OFFSET_CORRECTION.sandwich(event.data.acceleration)))
|
||||
}.launchIn(receiver.context.scope)
|
||||
|
||||
receiver.packetEvents.onPacket<Rotation2> { event ->
|
||||
|
||||
Reference in new issue
Block a user