Skip to content

Don't filter non-temporal trackers #1255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ data class TrackerFrames(val name: String = "", val frames: FastList<TrackerFram
// Make sure this is false!! Otherwise HumanSkeleton ignores it
isInternal = false,
isComputed = true,
trackRotDirection = false,
)

tracker.status = TrackerStatus.OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ class Tracker @JvmOverloads constructor(
val needsReset: Boolean = false,
val needsMounting: Boolean = false,
val isHmd: Boolean = false,
/**
* Whether to track the direction of the tracker's rotation
* (positive vs negative rotation). This needs to be disabled for AutoBone and
* unit tests, where the rotation is absolute and not temporal.
*/
val trackRotDirection: Boolean = true,
magStatus: MagnetometerStatus = MagnetometerStatus.NOT_SUPPORTED,
/**
* Rotation by default.
Expand Down Expand Up @@ -310,7 +316,9 @@ class Tracker @JvmOverloads constructor(
fun dataTick() {
timer.update()
timeAtLastUpdate = System.currentTimeMillis()
filteringHandler.dataTick(_rotation)
if (trackRotDirection) {
filteringHandler.dataTick(_rotation)
}
}

/**
Expand All @@ -320,6 +328,19 @@ class Tracker @JvmOverloads constructor(
timeAtLastUpdate = System.currentTimeMillis()
}

private fun getFilteredRotation(): Quaternion = if (trackRotDirection) {
if (filteringHandler.filteringEnabled) {
// Get filtered rotation
filteringHandler.getFilteredRotation()
} else {
// Get unfiltered rotation
filteringHandler.getTrackedRotation()
}
} else {
// Get raw rotation
_rotation
}

/**
* Gets the adjusted tracker rotation after all corrections
* (filtering, reset, mounting and drift compensation).
Expand All @@ -328,13 +349,7 @@ class Tracker @JvmOverloads constructor(
* it too much should be avoided for performance reasons.
*/
fun getRotation(): Quaternion {
var rot = if (allowFiltering && filteringHandler.filteringEnabled) {
// Get filtered rotation
filteringHandler.getFilteredRotation()
} else {
// Get unfiltered rotation
filteringHandler.getTrackedRotation()
}
var rot = getFilteredRotation()

// Reset if needed and is not computed and internal
if (needsReset && !(isComputed && isInternal) && trackerDataType == TrackerDataType.ROTATION) {
Expand All @@ -360,13 +375,7 @@ class Tracker @JvmOverloads constructor(
* This is used for debugging/visualizing tracker data
*/
fun getIdentityAdjustedRotation(): Quaternion {
var rot = if (filteringHandler.filteringEnabled) {
// Get filtered rotation
filteringHandler.getFilteredRotation()
} else {
// Get unfiltered rotation
filteringHandler.getTrackedRotation()
}
var rot = getFilteredRotation()

// Reset if needed or is a computed tracker besides head
if (needsReset && !(isComputed && trackerPosition != TrackerPosition.HEAD) && trackerDataType == TrackerDataType.ROTATION) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class MountingResetTests {
imuType = IMUType.UNKNOWN,
needsReset = true,
needsMounting = true,
trackRotDirection = false,
)

// Apply full reset and mounting
Expand Down Expand Up @@ -130,6 +131,7 @@ class MountingResetTests {
imuType = IMUType.UNKNOWN,
needsReset = true,
needsMounting = true,
trackRotDirection = false,
)

// Apply full reset and mounting
Expand Down
Loading