Fixed trackers mounting adjustments not calculating yaw properly

Added Unit tests for trackers adjustments
This commit is contained in:
Eiren Rain committed 2021-07-03 01:47:33 +03:00
1 parent feb14109d2
commit 172e45db4b
4 files changed
+412 -9

No files matched your search

+3 -2
View File
@@ -48,6 +48,7 @@ public class VRServer extends Thread {
super("VRServer");
hmdTracker = new HMDTracker("HMD");
hmdTracker.position.set(0, 1.8f, 0); // Set starting position for easier debugging
// TODO Multiple processors
humanPoseProcessor = new HumanPoseProcessor(this, hmdTracker);
List<? extends Tracker> shareTrackers = humanPoseProcessor.getComputedTrackers();
@@ -191,7 +192,7 @@ public class VRServer extends Thread {
}
@VRServerThread
private void autoAssignTracker(Tracker tracker) {
private void trackerAdded(Tracker tracker) {
humanPoseProcessor.trackerAdded(tracker);
}
@@ -201,7 +202,7 @@ public class VRServer extends Thread {
tracker.loadConfig(config);
queueTask(() -> {
trackers.add(tracker);
autoAssignTracker(tracker);
trackerAdded(tracker);
for(int i = 0; i < newTrackersConsumers.size(); ++i)
newTrackersConsumers.get(i).accept(tracker);
});
@@ -29,6 +29,13 @@ public class ReferenceAdjustedTracker implements Tracker {
public void saveConfig(TrackerConfig config) {
}
/**
* Reset the tracker so that it's current rotation
* is counted as (0, <HMD Yaw>, 0). This allows tracker
* to be strapped to body at any pitch and roll.
* <p>Performs {@link #resetYaw(Quaternion)} for yaw
* drift correction.
*/
@Override
public void resetFull(Quaternion reference) {
resetYaw(reference);
@@ -36,15 +43,27 @@ public class ReferenceAdjustedTracker implements Tracker {
Quaternion sensorRotation = new Quaternion();
tracker.getRotation(sensorRotation);
adjustmentYaw.mult(sensorRotation, sensorRotation);
adjustmentAttachment.set(sensorRotation).inverseLocal();
}
@Override
public void resetYaw(Quaternion reference) {
Quaternion targetTrackerRotation = new Quaternion(reference);
// Use only yaw HMD rotation
Quaternion targetTrackerRotation = new Quaternion(reference);
float[] angles = new float[3];
targetTrackerRotation.toAngles(angles);
targetTrackerRotation.fromAngles(0, angles[1], 0);
adjustmentAttachment.set(sensorRotation).inverseLocal().multLocal(targetTrackerRotation);
}
/**
* Reset the tracker so that it's current yaw rotation
* is counted as <HMD Yaw>. This allows the tracker
* to have yaw independant of the HMD. Tracker should
* still report yaw as if it was mounted facing HMD,
* mounting position should be corrected in the source.
*/
@Override
public void resetYaw(Quaternion reference) {
// Use only yaw HMD rotation
Quaternion targetTrackerRotation = new Quaternion(reference);
float[] angles = new float[3];
targetTrackerRotation.toAngles(angles);
targetTrackerRotation.fromAngles(0, angles[1], 0);