Spacial anchor positioning

I had a few questions on what is possible with spatial anchors/mapping. I had wanted very accurate placement of certain objects in my space, but because I am not using AR cloud, the anchors don't persist. I thought that maybe placing objects by coordinate upon start in the space might work but have found that the coordinates only stay consistent for a few sessions. I am wondering if anyone has suggestions for this.

I tried using ArUco markers as well but found that the objects didn't exactly match the true positioning of the anchor and would be placed differently based on where the user was standing relative to the marker. I'm wondering if there's some user error regarding that and if there's a way to have the positioning be more accurate. The object seemed to always be offset towards the user.

Is the only solution to use AR cloud?

Hi @kritig
you can persist anchors without AR cloud, AR cloud just allows for a much larger space. Spatial Anchor Overview | MagicLeap Developer Documentation
This is the current documentation on it, but that api will be changing in the next release to get a bit simpler. The ideas will stay the same though so it would be a good start. If you have any questions about it I am happy to help.

Thank you! I am looking into it. I'm wondering if some of the recent changes have affected the api already? I tried installing OpenXR so that this script (Spatial Anchors Storage Example | MagicLeap Developer Documentation) would compile, but am having compilation issues with the OpenXR stuff.

In the script, the following are not identified:

private MagicLeapSpatialAnchorsStorageFeature anchorStorageFeature;
private MLXrAnchorSubsystem activeSubsystem;

Are there some settings I need to change for OpenXR?

That script should still work if the environment is setup correctly for ML2 and openxr. Upgrading a project from mlsdk to openxr is possible, but there are some difficulties, if possible I would suggest starting a fresh project and then using the setup tool Magic Leap Setup Tool | Integration | Unity Asset Store to get the environment setup correctly for openxr.

I have attempted to switch following the settings guides and scene set up (Building a Simple App with OpenXR | MagicLeap Developer Documentation, Configure Project Settings | MagicLeap Developer Documentation). However, when I try to build the scene to the headset, the app doesn't even launch. Do you have any tips on setup? I've worked for months on this project and would like to keep using it if possible.

Sidenote: everything looks good in the Magic Leap Setup Tool. The only prompt left is it wants me to update MLSDK. I have a slightly older version because I had seen somewhere that for Unity version 1.4 is better.

Edit: Could there be issues if using Unity 2022.2 instead of 2022.3?

Sidenote: everything looks good in the Magic Leap Setup Tool. The only prompt left is it wants me to update MLSDK. I have a slightly older version because I had seen somewhere that for Unity version 1.4 is better.

version 1.4 of what?

I was referring to the Magic Leap SDK. I ended up updating it and making a few other changes and the project builds, but I'm having some trouble configuring the objects/controllers to act the same way as with MLSDK. The controllers no longer have ray casting and the objects stay static in the headset field of view instead of static in its position in the room--I set up the scene as instructed here ( Building a Simple App with OpenXR | MagicLeap Developer Documentation). I am wondering if there are some simple steps I have overlooked of if this is truly a set up issue.

In addition to this behavior, I am finding that about every other time I try to build the build gets stuck at the script compilation stage regardless if I even changed something or not. Could this be related to some incorrect set up?

It sounds like things are not tracking at all. Double check your OpenXR settings and make sure you have the correct Rig prefab in the scene. You may need to remove all references to the old legacy sdk. If you could post some screenshots of your xr settings that could help. Also yes especially with OpenXR try to keep up to date with the sdk.

I believe I have the correct rig prefab. I attached the screenshots below:

One issue I am having is I cannot launch Magic Leap Hub via the project anymore. Could this be an indication of what is going wrong? I changed the settings there so that the most updated SDK was being used.

And just to confirm your XR plugin management looks like this ?

This is what my settings looks like. The one difference I'm seeing is that the xr interaction tool kit is not under xr plug in management. Could this be an issue?

Everything looks correct. Are you getting any errors in logcat?

Thanks for your help! I ended up following your previous advice and starting a new project.

I do have another question regarding anchor storage--is the following script supposed to work out of the box: Spatial Anchor Storage API Overview | MagicLeap Developer Documentation

To test, I put it in a basic scene just to see if the anchors would persist. However, it seems that I can create anchors but not delete them. When I close the app and open the app again, the anchors I created also no longer exist.

The script should work as long as all the correct permissions are in place and it has the correct references. Are you getting any errors in log?

The script works now that I downgraded to the version of Unity specified in this post: Spatial Anchors Not Tracking - #8 by dilmer

I guess the 2022.3.3 versions have issues with saving/tracking the anchors.

Thank you for all your help!

1 Like