Skip to content

Commit

Permalink
[VisionGlasss] Start the IMU service when a new Display is added
Browse files Browse the repository at this point in the history
The Vision SDK is providing us wrong position data in the callback
passed to the startIMU method. This is happening only the first
time Wolvic is laucnhed after connecting the device to the USB port.

We were calling to the startIMU() method as part of the showPresentation
logic. It's only called if the display received as argument is different
to the current presentationDisplay and or if there isn't an instance
of the VisionGlassPresentation class yet.

It seems that calling the startUMI() method everytime a new display
is added solves the issue. We need to do it independently of whether
the display has the FLAG_PRESENTATION bit enabled or not. Actually,
we need to call it at least once if both cases.

It's important to know that this is just a workaround, since we
don't understand completely the root cause of the issue, or why
this change solve it. However, I haven't seen any regression caused
but this change, so I believe it's a safe approach.

I also want to mention that before this change, in the case of the
subsequent launches of Wolvic, after having granted USB persisions
and the Wired Projection, the startIMU() method is called as part of
the updateDisplays() call form the onResume() method. In this case,
the Presentation display from the previous execution is still handled
by the DisplayManager. As a matter of fact, we use that one to create
the new VisionGlassPresentation instance. This PR changes that case
as well, since now the startIMU() method is called only after a new
display is added, in this case it'd be one with the FLAG_PRESENTAITON
bit disabled.
  • Loading branch information
javifernandez authored and svillar committed Feb 24, 2025
1 parent acbbe1d commit daaa1d5
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,11 @@ boolean onBackPressed() {
}
}

private void startIMUService() {
Log.d(LOGTAG, "Starting IMU service");
VisionGlass.getInstance().startImu((w, x, y, z) -> queueRunnable(() -> setHead(x, y, z, w)));
}

private final DisplayManager.DisplayListener mDisplayListener =
new DisplayManager.DisplayListener() {
private void callUpdateIfIsPresentation(int displayId) {
Expand All @@ -796,6 +801,7 @@ private void callUpdateIfIsPresentation(int displayId) {
@Override
public void onDisplayAdded(int displayId) {
Log.d(LOGTAG, "display listener: onDisplayAdded displayId = " + displayId);
startIMUService();
callUpdateIfIsPresentation(displayId);
}

Expand Down Expand Up @@ -828,9 +834,6 @@ private void showPresentation(@NonNull Display presentationDisplay) {
return;
}

Log.d(LOGTAG, "Starting IMU");
VisionGlass.getInstance().startImu((w, x, y, z) -> queueRunnable(() -> setHead(x, y, z, w)));

VisionGlassPresentation presentation = new VisionGlassPresentation(this, presentationDisplay);
Display.Mode[] modes = presentationDisplay.getSupportedModes();
Log.d(LOGTAG, "showPresentation supported modes: " + Arrays.toString(modes));
Expand Down

0 comments on commit daaa1d5

Please sign in to comment.