Unity AR foundation Anchors

Does Unity AR foundation ARAnchor works with magic leap 2 ? Or we need to use Spatial anchor ?

I need to position a big object on the current scene without any movement or jitter.
What are the best practices?

For this, we do recommend using Spatial Anchors. Here is a guide to help walk you through it: Spatial anchors - Unity Learn

Let me know if you have any further questions.

Best,

El

Is it necessary to store the anchors or can I just add an anchor to a game object as I am adding ARAnchor component ?

While using spatial anchor is it necessary to scan the place ?

As of now not necessary to save to local space.
Do i need to publish or can i just add the anchor ?

I need to create an anchor and bind it to a Game object for the current session.

Please advise the best approach.

Creating a space using the Spaces Application and using Magic Leap's Spatial Anchors allows the device to correct for head pose drift by allowing the device to localize to a known location.

Unlike other devices, anchors are not required to improve content stability. Instead, anchors work like empty transforms on a map. These points can then be used to position content at the correct location and for the content to maintain position even when headpose was lost and to account for possible drift when navigating large locations.

In the upcoming version of the Magic Leap OpenXR Unity SDK, developers will be able to use ARAnchors via the AR Foundation API. However, publishing will need to be done using Magic Leap's platform feature.

Ok
Do I need to calculate head pose and update the anchors or it will happen internally ?

If you do not publish the anchors to a space they will update with head pose automatically. In Unity, you can place an object in the scene and build the application. Objects will stay in place as the user moves around without any additional logic.

Can you point me to some sample. ?
All the sample publishes the anchors and its tricky for me to test .
I am using MRTK3 and its not supporting app sim .
I need to place an object at run time .

  Pose pose = new Pose(m_spawnedCourtReference.transform.position, m_spawnedCourtReference.transform.rotation);
                MLResult creationResult =
                 MLAnchors.Anchor.Create(pose, (long)TimeSpan.FromDays(365).TotalSeconds, out MLAnchors.Anchor anchor);
                if (creationResult.IsOk)
                {
                    Debug.Log($"Anchor created with ID {anchor.Id}");
                    m_anchorId = anchor.Id;
                    DeviceManager.Instance.DebugText.text = $"Anchor created with ID {m_anchorId}";
                    
                    var publishResult = anchor.Publish();
                    if (publishResult.IsOk)
                    {
                        m_spawnedCourtReference.transform.SetPositionAndRotation(anchor.Pose.position, anchor.Pose.rotation);
                    }
                }
                else
                {
                    Debug.LogError($"Failed to create anchor: {creationResult}");
                    DeviceManager.Instance.DebugText.text = $"Failed to create anchor: {creationResult}";
                }

is this the proper way to ?
I am getting the anchor id but the stability is not that great. The object i am positioning is kind of big court.

The stability or jitter that you are seeing might be a result of the performance of the application. Do you mind testing with a simple object such a a cube that renders both exterior and interior faces?

i have to instantiate an object at run time and make sure its in the position.
I am following this sample code

Pose pose = new Pose(m_spawnedCourtReference.transform.position, m_spawnedCourtReference.transform.rotation);
                MLResult creationResult =
                 MLAnchors.Anchor.Create(pose, (long)TimeSpan.FromDays(365).TotalSeconds, out MLAnchors.Anchor anchor);
                if (creationResult.IsOk)
                {
                    Debug.Log($"Anchor created with ID {anchor.Id}");
                    m_anchorId = anchor.Id;
                    DeviceManager.Instance.DebugText.text = $"Anchor created with ID {m_anchorId}";
                    
                    var publishResult = anchor.Publish();
                    if (publishResult.IsOk)
                    {
                        m_spawnedCourtReference.transform.SetPositionAndRotation(anchor.Pose.position, anchor.Pose.rotation);
                    }
                }
                else
                {
                    Debug.LogError($"Failed to create anchor: {creationResult}");
                    DeviceManager.Instance.DebugText.text = $"Failed to create anchor: {creationResult}";
                }

Advice me for the right approach.
The court is quite big and when i am moving over to other side its doesnt seems to be stable.
Small objects seems stable.

Is there any other settings to tweak like Fov ?

Regarding spatial anchors, here is a sample script that shows how to create and query spatial anchors. Note, you must create a Space in the spaces app before publishing the anchor. : Spatial Anchors Examples | MagicLeap Developer Documentation

Large objects can use a lot of resources to render. We recommend splitting the large object into multiple meshes so it can be culled when not in view. When the application performance is low, objects can appear to jitter due to a drop in frame rate.

You may also want to adjust your focus distance to improve stability further: Stabilization Overview | MagicLeap Developer Documentation

Cool . Can i just use it without publishing the anchors? I dont need to be persistent ? And using the space app is mandatory even though i am not publishing ?

That package is using MagicLeap camera script which is deprecated and i am not using it with MRTK3
Any alternative ?
@kbabilinski