Exported Sapce with Spatial Anchors

Hi, I scanned the space with the Space application on the magic leap 2 device, and I created a few anchors using the Achor scene from the Magic Leap Examples. I exported the map following the instructions from this website: Import and Export Spaces | MagicLeap Developer Documentation.
Then I imported the .json file into Unity. In a new scene, i created a script that reads the .json file to extract the anchor positions and instantiate a game object at each anchor position to visualize them. However, the location of the game objects is off by 1-2 meters. I'm wondering if this is due to the precision of the mapping, or I missed a coordinate conversion from the magic leap 2 frame to the unity frame.
Thank you!
MLSDK version: 1.3.0-dev1
Host OS: Windows

Error messages from logs : No error message. It's a question about the precision of map scanning included in the Spaces application and spatial anchors.

Hi @ineedhelpty,

Welcome to the Magic Leap 2 Developer forums. We are so happy to have you here engaging with us.

It seems like the "error messages from logs" portion is missing from your post. Would you mind reposting them?

Thanks,

El

Hi etucker! There is no error message from logs. It's a question related to the precision of the spatial anchors. @etucker Thank you!

Okay I see. I will reach out to our developers and see what may be going on and report back as soon as possible.

Thank you so much! @etucker

Hi @ineedhelpty 1-2 meters is definitely not something I would expect so lets see if we can unravel whats going on.

Would you be willing to share a Bug Report, the Map in question, and a simple sample of what you are trying to do? Any additional information about whether the scene is outdoors or indoors would be super helpful.

If you aren't comfortable sharing the map then just a bug report / sample / description of the conditions of the space would suffice.

Edit: Though one thing that seems suspicious is that you are using a script to read the .json file with the anchors, I would use the MLAnchors api directly as it will adjust the positions for the current tracking map. If this doesn't fix your issue then please follow the above.

1 Like

the scene is indoors. The map is with 3 anchors. I'm trying to instantiate a game object at these anchor positions that will always stay at the same location.

I think we responded at similar times but I edited my above comment as I think the error is due to your use of the contextless offsets in the JSON. If you use the ML Anchors API in your app youll get the correct offsets. :slight_smile:

1 Like

Thank you for the reply. Can you give an example of how to use the ML Anchors API? I exported the map.


How can I use the information from the map if I don't read information form the JSON file?

Does the information above help? If you have more specific questions @etucker or myself can help you navigate further. Once you have imported your map your app would check if you are localized into that imported map and query the anchors. You can also just query for anchors as you will get none until the device recognizes the space.

1 Like

Thank you. Does "importing map" mean that you have the map stored in the Space application? Also, Can the magic leap 2 device recognize the space directly without opening the Space application for the localization if I use MLAnchors.GetLocalizationInfo API? What if i have more than one map saved in the Space application? How can the device know which one to use? @mrushton Thanks

Thanks @mrushton Also as a follow-up. If you find anything in the documentation hard to follow please let us know. Any feedback on documentation is greatly appreciated.

Thank you. Does "importing map" mean that you have the map stored in the Space application? Also, Can the magic leap 2 device recognize the space directly without opening the Space application for the localization if I use MLAnchors.GetLocalizationInfo API? What if i have more than one map saved in the Space application? How can the device know which one to use? @mrushton @etucker Thanks

You can use the Spaces application to select it or you can do it programmatically in your own app @ineedhelpty , see the spaces documentation here if you want to have your app do the management. You will need to use Spaces to create it initially and map the room but once that is complete your app has control to import / export / localize into a specific saved / imported map.