mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-12-01 22:32:35 -08:00
Fix acceleration adjustement and add to visualizer (#804)
This commit is contained in:
1 parent
cdb4d15d60
commit
975f340a63
4 files changed
+45
-14
No files matched your search
@@ -292,15 +292,14 @@ class Tracker @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the adjusted tracker acceleration after mounting corrections.
|
||||
* Gets the world-adjusted acceleration
|
||||
*/
|
||||
fun getAcceleration(): Vector3 {
|
||||
var vec = acceleration
|
||||
if (needsReset) {
|
||||
vec = resetsHandler.getMountingAdjustedRotationFrom(rotation).sandwich(vec)
|
||||
return if (needsReset) {
|
||||
resetsHandler.getReferenceAdjustedAccel(rotation, acceleration)
|
||||
} else {
|
||||
acceleration
|
||||
}
|
||||
|
||||
return vec
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -111,10 +111,10 @@ class TrackerResetsHandler(val tracker: Tracker) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a rotation and adjusts it to mounting
|
||||
* Get the adjusted accel from yawFixZeroReference
|
||||
*/
|
||||
fun getMountingAdjustedRotationFrom(rotation: Quaternion): Quaternion {
|
||||
return rotation * mountingOrientation * mountRotFix
|
||||
fun getReferenceAdjustedAccel(rawRot: Quaternion, accel: Vector3): Vector3 {
|
||||
return (adjustToReference(rawRot) / yawFix).sandwich(accel)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,6 +9,7 @@ import io.eiren.util.Util
|
||||
import io.eiren.util.collections.FastList
|
||||
import io.eiren.util.logging.LogManager
|
||||
import io.github.axisangles.ktmath.Quaternion.Companion.fromRotationVector
|
||||
import io.github.axisangles.ktmath.Vector3
|
||||
import org.apache.commons.lang3.ArrayUtils
|
||||
import solarxr_protocol.rpc.ResetType
|
||||
import java.net.DatagramPacket
|
||||
@@ -276,7 +277,7 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
tracker = connection?.getTracker(packet.sensorId)
|
||||
if (tracker == null) return
|
||||
var rot17 = packet.rotation
|
||||
rot17 = AXES_OFFSET.times(rot17)
|
||||
rot17 = AXES_OFFSET * rot17
|
||||
when (packet.dataType) {
|
||||
UDPPacket17RotationData.DATA_TYPE_NORMAL -> {
|
||||
tracker.setRotation(rot17)
|
||||
@@ -297,7 +298,8 @@ class TrackersUDPServer(private val port: Int, name: String, private val tracker
|
||||
is UDPPacket4Acceleration -> {
|
||||
tracker = connection?.getTracker(packet.sensorId)
|
||||
if (tracker == null) return
|
||||
tracker.setAcceleration(packet.acceleration)
|
||||
// Switch x and y around to adjust for different axes
|
||||
tracker.setAcceleration(Vector3(packet.acceleration.y, packet.acceleration.x, packet.acceleration.z))
|
||||
}
|
||||
is UDPPacket10PingPong -> {
|
||||
if (connection == null) return
|
||||
|
||||
Reference in new issue
Block a user