Skip to content

Commit

Permalink
show drift compensation in tracker preview (#937)
Browse files Browse the repository at this point in the history
  • Loading branch information
Erimelowo authored Feb 16, 2024
1 parent d9955d1 commit d3f90b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ class Tracker @JvmOverloads constructor(
* Gets the adjusted tracker rotation after all corrections
* (filtering, reset, mounting and drift compensation).
* This is the rotation that is applied on the SlimeVR skeleton bones.
* Warning: This may perform several Quaternion multiplications, so calling
* Warning: This performs several Quaternion multiplications, so calling
* it too much should be avoided for performance reasons.
*/
fun getRotation(): Quaternion {
Expand Down Expand Up @@ -316,8 +316,8 @@ class Tracker @JvmOverloads constructor(
}

/**
* Gets the identity-adjusted tracker rotation after some corrections
* (filtering, identity reset and identity mounting).
* Gets the identity-adjusted tracker rotation after corrections
* (filtering, identity reset, drift and identity mounting).
* This is used for debugging/visualizing tracker data
*/
fun getIdentityAdjustedRotation(): Quaternion {
Expand All @@ -331,7 +331,7 @@ class Tracker @JvmOverloads constructor(

if (needsReset && trackerPosition != TrackerPosition.HEAD) {
// Adjust to reset and mounting
rot = resetsHandler.getIdentityAdjustedRotationFrom(rot)
rot = resetsHandler.getIdentityAdjustedDriftRotationFrom(rot)
}

return rot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,15 @@ class TrackerResetsHandler(val tracker: Tracker) {
* and drift compensation, with the HMD as the reference.
*/
fun getReferenceAdjustedDriftRotationFrom(rotation: Quaternion): Quaternion {
var rot = adjustToReference(rotation)
rot = adjustToDrift(rot)
return rot
return adjustToDrift(adjustToReference(rotation))
}

/**
* Takes a rotation and adjusts it to resets and mounting,
* with the identity Quaternion as the reference.
*/
fun getIdentityAdjustedRotationFrom(rotation: Quaternion): Quaternion {
return adjustToIdentity(rotation)
fun getIdentityAdjustedDriftRotationFrom(rotation: Quaternion): Quaternion {
return adjustToDrift(adjustToIdentity(rotation))
}

/**
Expand Down Expand Up @@ -235,8 +233,8 @@ class TrackerResetsHandler(val tracker: Tracker) {

calculateDrift(rot)

// Let's just remove the status if you do yaw reset if the tracker was
// disconnected and then connected back
// Remove the status if yaw reset was performed after the tracker
// was disconnected and connected.
if (this.tracker.lastResetStatus != 0u && this.tracker.statusResetRecently) {
VRServer.instance.statusSystem.removeStatus(this.tracker.lastResetStatus)
this.tracker.statusResetRecently = false
Expand Down

0 comments on commit d3f90b8

Please sign in to comment.