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

Getting the Frowen pose instead of the Spongy one #276

Closed aless98 closed 2 years ago

aless98 commented 2 years ago

Hello! I am trying to access the frozen pose of the QRcode using Pose frozen_pose = WorldLockingManager.GetInstance().FrozenFromSpongy; Unluckily there is no so much on the internet as i could see. Is it the correct way to do it? I have also tried to use WorldLockingManager.GetInstance().FrozenFromSpongy.Multiply(CurrentspongyPose) but the pose is pretty much the same as the spongy one. Do you have any suggestion? Thank you in advance!

Alessandro.

genereddick commented 2 years ago

You can wait until someone more knowledgeable responds, however, I believe that the form below is what you want:

WorldLockingManager.GetInstance().FrozenFromSpongy.Multiply(CurrentspongyPose)  

I think the spongyPose and the frozenPose should be the same until you start to see sensor drift (reflected in the WLT pose adjustment, and assuming you are not getting your pose from an underlying sensor API that doesn't respect the WLT).

You can test this by running your app and checking the frozen and spongy poses. Then walk away from where you started (on an iPhone you don't have to go too far, 5 meters or so will usually do it, may be more on HL; turning the device around a lot, moving up and down, usually also will get some drift for me), then walk back to where you started and check the poses again.

aless98 commented 2 years ago

Thanks! i will try it for sure and let you know. So basically i am updating the position of a holographic cube to align it with a real one according to some incoming data from a sensor. If i use the Frozen pose instead of the Spongy pose even when i move around or away from the hologram it should remain fixed and aligned to that object is that correct?

fast-slow-still commented 2 years ago

@aless98, yes, @genereddick 's comments are correct.

You should check what space your QR code reading API is returning the pose of the QR code in. This will vary. For example, the legacy WSA API SpatialCoordinateSystem.TryGetTransformTo returned a transform relative to the camera's parent, i.e. in SpongySpace. The new OpenXR API, SpatialGraphNode.TryLocate, returns a transform pose relative to Unity's global coordinate space, i.e. FrozenSpace.

The WLT APIs WorldLockingManager.GetInstance().FrozenFromSpongy/SpongyFromFrozen provide transforms between the two spaces. However, WLT can't know what space a pose you give it is in, you are responsible for transforming poses into the appropriate space before passing them to WLT.

Pose frozen_pose = WorldLockingManager.GetInstance().FrozenFromSpongy;

This is almost certainly not what you want. As mentioned, FrozenFromSpongy is a transform between two spaces. It is not the pose of an object in a meaningful or useful way.

Here is some more documentation on the different spaces: https://docs.microsoft.com/en-us/mixed-reality/world-locking-tools/documentation/concepts/advanced/coordinatespaces

The QR code sample is a very advanced sample. Have you tried some of the more basic samples? I would suggest that you do. The basic samples will help familiarize you with the setup of WLT in a project, and also familiarize you with what WLT does at the most basic level. Once you are comfortable with basic world locking, and then basic space pinning, then the QR sample will be much easier to get working and understand.

I would suggest the following progression:

  1. WorldLockingPhysics - the basic system world locking a scene via an internally maintained graph of anchors, including manual Save/Load of state, with lots of visualization to help you see what's going on.

  2. SpacePin - basic space pinning, orienting and positioning the global coordinate space, which is then automatically world locked. Here, you manually drag markers into their relative positions. You might need to reposition the space pin objects in the Unity scene to fit the physical space you are working in. They are currently 6-10 meters apart, you can bring them into about 2 meter separation.

  3. QRSpacePins - after you have the above working as expected, then move to scanning the space pin positions out of QR codes instead of manually manipulating them.

Let me know if you get stuck along the way. I'm going to close this issue now, so if you hit a problem, just open a new issue on that specific problem.

Thanks!