microsoft / MixedReality-WorldLockingTools-Unity

Unity tools to provide a stable coordinate system anchored to the physical world.
https://microsoft.github.io/MixedReality-WorldLockingTools-Unity/README.html
MIT License
188 stars 45 forks source link

Object offset and drift over time #301

Open genereddick opened 2 years ago

genereddick commented 2 years ago

I'm trying to find the possible source of some serious drift we are seeing in our app. This is on an iOS app using WLT. We create space pins on top of a bunch of physical image markers, in a process structurally somewhat similar to the QRCode sample project. The virtual markers are meant to stay on top of, and aligned with, the physical images. But, instead they may stick for awhile, but as we move around the space, or sometimes just sitting idle for a bit, the markers will drift off their pinned locations. This happens on both single devices as well as multiple devices with a shared coordinate space.

Sometimes when you move around and look at the original pinned locations they will snap back into place as you might expect if the space was getting recalculated, but sometimes they will simply move off permanently.

I'm having trouble finding the source of the problem. I'm not sure if I'm implementing the space pins incorrectly, if there is some other error source, or if my understanding of how things are expected to work is flawed.

A few questions:

  1. Do the WLT interact with or require the spatial awareness systems? We use MRTK for this but I believe this is just a layer on top of the underlying AR Foundation implementation?

  2. To what are space pins actually pinned? I had assumed they were attached to feature points detected in the environment, but perhaps they are just at some measured distance point between the WLT anchors and so shift with those anchors?

  3. Having read through all the the issues in the project, this one seemed the closest to replicating what we are seeing (https://github.com/microsoft/MixedReality-WorldLockingTools-Unity/issues/234). We tried the first solution -- turning off Auto Merge and Refreeze -- and it seemed to make no difference. The second solution with an Adjuster Moving on the holograms I'm a little unclear about as it is actually the space pins themselves (or at least their visual representation) that is drifting. The space pins already have attachments points associated with them and I would have thought this would already be handled? And, were the two suggested solutions mutually exclusive or meant to be done together?

  4. Could there be an issue with the refit operation on AR Foundation / iOS where refreezes aren't happening when they should or giving bad data?

  5. If two different devices scan a space, and set space pins that align their coordinate systems with each other, could a refit operation cause them to resolve / move the space pins -- or I suppose the WLT Adjustment object -- in different directions?

  6. Is it a mistake to use space pins with a holographic marker (like an axis) -- perhaps the visual marker needs to not be a child of the space pin and having them together is an incorrect usage?

Really, I'm grasping at straws, so any explanations or suggestions or alternatives would be much appreciated.

fieldsJacksonG commented 2 years ago

Were you experiencing similar drift in the QR sample, or the first time you launch your project?

A potential source of drift could be from moving the physical marker in the real world between runs. I believe that when a space pin is found, the alignment manager will infer previously saved space pin locations relative to this one, so if it is in a different location (either moved, or previously saved in a different room), this could cause drift as you walk toward where the game thinks the other space pins are. You can reset your session to a clean state by calling ClearAlignmentAnchors: https://github.com/microsoft/MixedReality-WorldLockingTools-Unity/blob/0f88bfc471c79920ac7c008132169bce16cffb93/Assets/WorldLocking.Core/Scripts/IAlignmentManager.cs#L91

genereddick commented 2 years ago

"A potential source of drift could be from moving the physical marker in the real world between runs."

We do physically remove the markers after pinning. But we tape the positions in case we need to start over, and we get drift whether they were left in place or not.

Does this refer to introducing error by creating a space pin from a marker at some position in a room, and then replacing it at but with some offset to that position when pinning a second time? Or can even moving the markers during a session cause issues? For example, if the space pin is tied to feature points created from the physical marker and that marker gets removed.

Does the alignment manager persist space pin poses across app opens? I recall this being an issue with QR scanning on the HoloLens and SpectatorView.