OpenXR Marker Understanding Feature finding markers, but returning a zeroed out pose

Give us as much detail as possible regarding the issue you're experiencing:

Unity Editor version: 2022.3.5f1
ML2 OS version: 1.6.0
Unity SDK version: 2.1.0
Host OS: Windows

Error messages from logs (syntax-highlighting is supported via Markdown): None

I've been working on switching our project from the MLSDK to OpenXR for the past week or so and I'm currently working on getting our marker tracking switched over. Everything seems to work, except that when a marker is found, its position and rotation are always zeroed out.

For reference, we're using an Aruco code on the floor with the ID of 100. The type and number on the marker are recognized, but as stated, the pose is always zeroed out.

This occurs in our own custom solution and the example script on the documentation page.

Hi @chaseryals219,
welcome to the developer forum. I approved your post but could you please add some more information to it; it seems like you didn't finish it, but we would be happy to help you with whatever issue you are facing.
-Sidney

The post has been updated. Also updated the title of the post to be more accurate.

1 Like

For reference, this is our Update method that we're using

public override void Update()
{
    if (!IsScanning)
        return;

    MarkerFeature.UpdateMarkerDetectors();
    foreach (var markerDetector in MarkerFeature.MarkerDetectors)
    {
        if (markerDetector.Status != MarkerDetectorStatus.Ready) 
            continue;
        
        if (markerDetector.Data.Count <= 0) 
            continue;
            
        foreach (var marker in markerDetector.Data)
        {
            Debug.Log("Marker found.");
            if (marker.MarkerNumber != (ulong)markerNumber)
                continue; 
            
            Debug.Log("Marker ID matches");
            
            //This is always zeroed out
            Pose? markerPose = marker.MarkerPose;
            if(markerPose is null)
                continue;
            
            Debug.Log($"Marker Position: {markerPose.Value.position.ToString()} Marker Rotation: {markerPose.Value.rotation.ToString()}");
            Transform originTransform = _xrOrigin.CameraFloorOffsetObject.transform;
            Pose offsetPose = new Pose(
                originTransform.TransformPoint(markerPose.Value.position),
                originTransform.rotation * markerPose.Value.rotation
            );
            MarkerFound?.Invoke(offsetPose);
            return;
        }
    }
}

Hi @chaseryals219
would it be possible for you to update sdk and os to the latest. there was a bug in the openxr marker tracking and I think it might be impacting you.
-Sidney

Yep, I was just going through the update docs and noticed the marker tracking fix, so I'll try that and get back to you.

1 Like

Unfortunately, after updating to 1.7 for the ML OS and 2.2.0 for the Unity SDK, the issue still persists.

Interesting, is this script deeply connected to your scene or could you post a minimal repro so I can test it? Feel free to DM me if that works better for you.

The script is part of a more complex marker-tracking system, so I'll need to make a repro of it.

Here is a rough reproduction of what our system is doing. I tested this and it gives the same results as our main system.

using System;
using System.Collections;
using Unity.XR.CoreUtils;
using UnityEngine;
using UnityEngine.XR.Management;
using UnityEngine.XR.OpenXR;
using UnityEngine.XR.OpenXR.Features.MagicLeapSupport;
using static UnityEngine.XR.OpenXR.Features.MagicLeapSupport.MagicLeapMarkerUnderstandingFeature;

public class OpenXR_MLMarkerTracker : MonoBehaviour
{
    [SerializeField] private MarkerType type;
    [SerializeField] private int markerNumber;
    [SerializeField] private MarkerDetectorProfile profile;
    [SerializeField] private float markerSize;
    [SerializeField] private ArucoType arucoType;
    
    private MarkerDetectorSettings _detectorSettings;
    private XROrigin _xrOrigin;
    
    public MagicLeapMarkerUnderstandingFeature MarkerFeature { get; private set; }

    public event Action<Pose> MarkerFound;

    private IEnumerator Start()
    {
        XRManagerSettings manager = XRGeneralSettings.Instance.Manager;
        yield return new WaitUntil(() => manager.isInitializationComplete &&
                                         manager.activeLoader);

        if (manager.activeLoader.GetType() != typeof(OpenXRLoader))
        {
            Debug.LogError("OpenXRLoader is not the current XR loader. Disabling script.");
            enabled = false;
            yield break;
        }

        MarkerFeature = OpenXRSettings.Instance.GetFeature<MagicLeapMarkerUnderstandingFeature>();
        if (!MarkerFeature)
        {
            Debug.LogError("Could not find MagicLeapMarkerUnderstandingFeature. Disabling script.");
            enabled = false;
            yield break;
        }

        switch (type)
        {
            case MarkerType.Aruco:
                SetupArucoSettings();
                break;
            case MarkerType.AprilTag:
            case MarkerType.QR:
            case MarkerType.EAN13:
            case MarkerType.UPCA:
            case MarkerType.Code128:
            default:
                break;
        }

        MarkerDetector markerDetector = MarkerFeature.CreateMarkerDetector(_detectorSettings);
        if (markerDetector == null)
        {
            Debug.LogError("Could not create a marker detector. Disabling script.");
            enabled = false;
            yield break;
        }

        _xrOrigin = FindAnyObjectByType<XROrigin>();
        if (_xrOrigin == null)
        {
            Debug.LogError("There is no XR Origin in the scene. Disabling script.");
            enabled = false;
        }
    }
    
    private void SetupArucoSettings()
    {
        _detectorSettings.MarkerType = MarkerType.Aruco;
        _detectorSettings.MarkerDetectorProfile = profile;
        _detectorSettings.ArucoSettings.ArucoType = arucoType;
        _detectorSettings.ArucoSettings.EstimateArucoLength = true;
        _detectorSettings.ArucoSettings.ArucoLength = markerSize;

        _detectorSettings.AprilTagSettings.EstimateAprilTagLength = false;
        _detectorSettings.QRSettings.EstimateQRLength = false;
    }
    
    public void Update()
    {
        
        MarkerFeature.UpdateMarkerDetectors();
        foreach (var markerDetector in MarkerFeature.MarkerDetectors)
        {
            if (markerDetector.Status != MarkerDetectorStatus.Ready) 
                continue;
                
            if (markerDetector.Data.Count <= 0) 
                continue;
                    
            foreach (var marker in markerDetector.Data)
            {
                Debug.Log("Marker found.");
                if (marker.MarkerNumber != (ulong)markerNumber)
                    continue; 
                    
                Debug.Log("Marker ID matches");
                    
                //This is always zeroed out
                Pose? markerPose = marker.MarkerPose;
                if(markerPose is null)
                    continue;
                    
                Debug.Log($"Marker Position: {markerPose.Value.position.ToString()}, Marker Rotation: {markerPose.Value.rotation.ToString()}");
                Transform originTransform = _xrOrigin.CameraFloorOffsetObject.transform;
                Pose offsetPose = new Pose(
                    originTransform.TransformPoint(markerPose.Value.position),
                    originTransform.rotation * markerPose.Value.rotation
                );
                MarkerFound?.Invoke(offsetPose);
                return;
            }
        }
    }
}

And this is what I'm currently using in the inspector.
image

Also experiencing this issue as well in my own project. I have verified that my SDK is up to date as well as my OS. I am using a nearly identical script to the example given on the docs, replacing line 140 with SetTransformToMarkerPose(marker.transform, data.MarkerPose.Value, markerSize);

Aside from this and a method to move game objects to the marker's position, the script is the same.

Looks like the pose isn't getting set correctly in Marker Space, as in MagicLeapMarkerUnderstandingMarkerDetector.cs, all pose values are returning 0's. Unsure if this would impact it, but this is an MRTK project. @chaseryals219 are you also using MRTK? Asking to narrow down potential conflicts.

Yes, we're currently using the 1.0.0 MRTK3 package

Just making another comment, but the Spectator App also has an offset when scanning and connecting to the headset. I'm assuming this is placing the objects at 0, 0, 0 for the Spectator App as well

Interesting, this is sounding very much like a bug. If possible could I get some bug report captures from you both? Capture Bug Reports | MagicLeap Developer Documentation
Thank you,
-Sidney

Sure thing, do we need to run our projects again before doing so? Or will just sending it as it suffice?

if you could run your project and then immediately after collect the bug report that would be best

1 Like

Looks like the zip is larger than what is allowed to be uploaded here. How should we submit these?

Go ahead and send them to me at sfernandez@magicleap.com

I tried sending it, but it's giving me a message size violation error.

@chaseryals219 you could try a googledrive or onedrive link. that worked for Tyler