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

Question About Creating Space pin to persist some object ? #224

Closed hanjianwei92 closed 2 years ago

hanjianwei92 commented 2 years ago

Dear Developer: I'm a rookie about MR developing. After learning WorldLockingTools, I try to create space pin to persist some object by imitating SpacePinManipulation.cs in space pin samples , main Code is if (WorldLockingManager.GetInstance().ApplyAdjustment) { SetFrozenPose(ExtractModelPose()); } else {SetSpongyPose(ExtractModelPose()); }, but when I execute this code, the objects in the scene drift, and when I restart the app, the space pin does not work in Hololens2. Here is my complete configuration:

Is there any error in my code or configuration? If so, please tell me the correct way, and Is the space pin unavailable in holographic remote?

I'd be grateful if you can reply

fast-slow-still commented 2 years ago

Hi @hanjianwei92 ,

Your settings look correct. The answers to the following questions might help identify the problem.

Have you tried running the unmodified sample, for example the SpacePin scene? Did it behave as expected?

Have you run deployed to HoloLens2 device? Or only with holographic remote?

Do you have a UnityPlayer.log you could share?

I'll probably have more questions depending on your answers to the above.

hanjianwei92 commented 2 years ago

Thanks for your reply.

I had running the unmodified sample in both of them (holographic remote and HoloLens2 ),

  1. In holographic remote, I tried to run unmodified sample ,but it not work. Then, I tried to change Anchor Subsystem from WSA to XRSDK in holographic remote, it`s also not work.
  2. In Hololens2, I tried to run sample that only changed Anchor Subsystem from WSA to XRSDK , but space pin also not work when i restart app.

3.UnityPlayer.log

fast-slow-still commented 2 years ago

The log looks mostly okay, but there is an unusual warning about "Max proximity light count (2) exceeded."

Can you include a screenshot of your build settings? It should look something like this: image

Also, when you say that the space pin does not work when you restart the app, can you give me more detail about what happens? Is the space pin ignored? Does it pin the world to the wrong place? Does the space pin work the way you expect before you quit and restart the app?

Finally, thank you for the UnityPlayer.log. Is it the from the first run, or from when you restart the app?

Thank you for your patience answering all of these questions. I hope we can get you up and running soon!

hanjianwei92 commented 2 years ago

1. 2021-10-28 090457

  1. When I firstly open the app, sphere appeared in my head and I drag sphere to to a certain position in the physical world.(At this time the world locking should work, I move more than 5 meters, and the sphere can still remain in this place). Then, I close app and open it again(In a position different from the last time), sphere still appeared in my head and didn`t return to the position of the physical world at the end of the last time. Is there anything wrong with my understanding and way about space pin? Is it the correct way that I persist an object.

  2. UnityPlayer.log is got after I restart app.

Thank you for your reply,

fast-slow-still commented 2 years ago

I think you have a good understanding.

I apologize, I missed an important point. Save/Load is not supported under XRSDK for Unity 2019. The Windows XR Plugin and the Microsoft OpenXR Plugin for Unity 2019 do not support save and load of anchors.

You can get Save/Load on HoloLens2 with Unity 2019 by using the Legacy XR setting (WSA).

Or, you can get Save/Load on HoloLens2 with XR SDK by using Unity 2020.

You can check whether Save/Load (persistence) is supported at runtime with: WorldLockingManager.GetInstance().AnchorManager.SupportsPersistence property.

Finally, you don't need a SpacePin to persist an object. If you run WLT with AutoSave/AutoLoad enabled, then the entire space is persisted across sessions. So if the coordinates of the corner of your physical table are (x,y,z) in this session, then the coordinates will still be (x,y,z) next session. But only on platforms where persistence is supported.

Persistence is currently supported locally on HoloLens: Unity 2018 - Legacy XR (WSA) Unity 2019 - Legacy XR (WSA) Unity 2020 - XR SDK (Windows XR Plugin or Microsoft OpenXR Plugin) Unity 2020 - AR Foundation (Microsoft OpenXR Plugin)

Persistence on other platforms/configurations requires the use of Azure Spatial Anchors.

Here is a related issue: #198

Please let me know if this fixes your problem. Thanks!

hanjianwei92 commented 2 years ago

Thank you for your detailed reply. I will try the method you described. If I can well run my app, I will tell you and share my code.
Thank you very much again.

hanjianwei92 commented 2 years ago

Hi @fast-slow-still In HoloLens2, APP as a UWP application can not use System.IO(it not work). Should I use Windows.Storage as an interface for file reading and writing?

fast-slow-still commented 2 years ago

I use System.IO in HoloLens2 Unity UWP apps, as does MRTK. I believe that since IL2CPP, System.IO is Unity's preferred file access method. See this thread for example.

What is the problem you are having with System.IO?

hanjianwei92 commented 2 years ago

Hi @fast-slow-still I am so sorry for the above fault question. SystemIO can work in HoloLens 2 as a UWP, and I made a foolish error (Variable initialize wrong that Start() Misspelled as start() ) lead to task of file writing and reading not working .

Apologize again and Thank you for your reply

fast-slow-still commented 2 years ago

There is no problem. I am happy that you have it working now.

Thank you for the update!