MixedRealityToolkit-Unity icon indicating copy to clipboard operation
MixedRealityToolkit-Unity copied to clipboard

Working with multiple Azure Spatial Anchors

Open snavas opened this issue 1 year ago • 4 comments

Describe the problem

In the "Use Azure Spatial Anchors to anchor objects in the real world" tutorial from the MS documentation, it is explained how to create and manage a single Azure Spatial Anchor. However, there is no information in the tutorial, nor have I found any further information in the MRTK documentation or elsewhere about how to extend that workflow in order to make it work with multiple Azure Spatial Anchors.

I have tried to add the AnchorModuleScript from RTK.HoloLens2.Unity.Tutorials.Assets.AzureSpatialAnchors.XRplugginManagement.2.5.3.unitypackage to each of the objects I want to anchor in my scene thus creating multiple Azure Spatial Anchors. All the anchors share the same Spatial Anchors Account id, key and domain.

The problem with this approach is that for each object I'm anchoring, I need to start an Azure Session, create an anchor and save the anchor ID to disk or to the Azure cloud. First of all, starting multiple Azure Sessions is not ideal, but apparently, it doesn't suppose any problem to do so. The issue arises when I attempt to save multiple anchor IDs to disk or network.

When I attempt to save the anchor IDs to the Azure cloud using the ShareAzureAnchorIdToNetwork function, I get the 404 error as already documented here https://github.com/microsoft/MixedRealityToolkit-Unity/issues/10426. When I attempt to save the multiple azure IDs to disk, all of them try to save their anchor id into a SavedAzureAnchorID.txt file which gets overwritten multiple times, resulting in only one anchor ID being saved.

Describe alternatives you've considered

The problem of the multiples SavedAzureAnchorID.txt files being overwritten is easy to fix by just modifying the original ShareAzureAnchorIdToNetwork function to generate those files with different unique names like:

string filename = "SavedAzureAnchorID_" + publicSharingPin + ".txt";

Describe the solution you'd like

However, my questions are:

Is the AnchorModuleScript from RTK.HoloLens2.Unity.Tutorials.Assets.AzureSpatialAnchors.XRplugginManagement.2.5.3.unitypackage the "official" way to manage Azure Spatial Anchors or just an example code that shows you how create a simple implementation of it with a single anchor?

Is there any other way or workflow to create multiple Azure Spatial Anchors only starting one Azure Session that I am unaware of?

snavas avatar Sep 12 '22 10:09 snavas

Hey there! Have you taken a look at https://github.com/microsoft/MixedReality-WorldLockingTools-Unity? WLT is a library for combining multiple spatial anchors to localize a large-scale experience.

Zee2 avatar Sep 12 '22 23:09 Zee2

I didn't know about the existence of the WLT library. I'll check it out, it looks promising. Thanks!

snavas avatar Sep 20 '22 09:09 snavas

Bear in mind @Zee2 that WLT hasn't been updated for a while and isn't compatible with MRTK3 as far as I'm aware. Also incorporating it with MRTK3 will not be easy from the last time I looked in to this, hoping it gets come love soon.

SimonDarksideJ avatar Sep 25 '22 10:09 SimonDarksideJ

I can confirm that WLT 1.5.9 is working fine with MRTK3. Make sure that you set MRTK XR Rig as Camera Parent in WorldLockingContext (not the Camera Offset that is the real parent). image

dudziakl avatar Dec 20 '22 14:12 dudziakl

I can confirm that WLT 1.5.9 is working fine with MRTK3. Make sure that you set MRTK XR Rig as Camera Parent in WorldLockingContext (not the Camera Offset that is the real parent). image

Thanks for that. I am struggling to get this working. I have Unity 2022.3.9LTS and MRTK3 and ARFoundation 5.1.0 What is your exact setup to get this running? Which Anchor Management system are you using? I have tried all of them but Unity keeps complaining that it doesn't have a ARAnchoring subsystem. I am trying to get this working with Holographic remoting

pixelblue avatar Oct 05 '23 06:10 pixelblue

We appreciate your feedback and thank you for reporting this issue.

Microsoft Mixed Reality Toolkit version 2 (MRTK2) is currently in limited support. This means that Microsoft is only fixing high priority security issues. Unfortunately, this issue does not meet the necessary priority and will be closed. If you strongly feel that this issue deserves more attention, please open a new issue and explain why it is important.

Microsoft recommends that all new HoloLens 2 Unity applications use MRTK3 instead of MRTK2.

Please note that MRTK3 was released in August 2023. It features an all-new architecture for developing rich mixed reality experiences and has a minimum requirement of Unity 2021.3 LTS. For more information about MRTK3, please visit https://www.mixedrealitytoolkit.org.

Thank you for your continued support of the Mixed Reality Toolkit!

IssueSyncBot avatar Jan 13 '24 01:01 IssueSyncBot