Locating MLSpatialAnchor in OpenXR

Hi,

[This is a follow-up to ML Compat Extension (XR_ML_compat) support, as suggested by @etucker]

I'm trying to locate in OpenXR the reference space associated with an anchor.

The anchor was created successfully as MLSpatialAnchor from MLPerception module as I can't find any way to do this in OpenXR. The anchor expiration date was set to 0 (i.e. no expiration) in MLSpatialAnchorCreateInfo. The anchor reference space was then created with xrCreateSpaceFromCoordinateFrameUIDML from ML Compat (XR_ML_compat) extension. The MLCoordinateFrameUID passed to xrCreateSpaceFromCoordinateFrameUIDML is given by anchor's cfuid member.

It's kinda working as xrLocateSpace returns a non-null/non-identity location. But neither XR_SPACE_LOCATION_POSITION_VALID_BIT nor XR_SPACE_LOCATION_POSITION_TRACKED_BIT is set. Is this expected? This is with latest ML SDK 1.4.0 and ML OS 1.4.1.

Out of curiosity, since creating an anchor requires to set up MLPerception and create a spatial anchor tracker, does it mean that both the MLPerception module and OpenXR runtime are concurrently tracking the world in background?

Thanks.

Hi @emaschino,

Thank you for creating a separate thread. This helps us keep the forums organized.

I have reached out to our team regarding your issue and I will report back as soon as I learn more.

Best,

El

Hi @emaschino,

Is the anchor locatable using C-API functions?

Are you calling MLPerceptionGetSnapshot every frame? This will update the position of the anchor in the PIL which needs to be updated manually.

Best,

El

Hi @etucker,

Thanks for the update.

Well, I don't know if the anchor is locatable using the C API. I started to develop from scratch with OpenXR, as my app is cross-platform and also runs on Microsoft HoloLens 2 device.

I'm not calling MLPerceptionGetSnapshot at the moment. As there's no OpenXR sample in ML SDK showing how to use spatial anchors in OpenXR, I wasn't aware of this.

Now, looking at ML SDK C API spatial_anchor sample, I'm wondering where to stop using C API vs OpenXR. I mean, OK I must call MLPerceptionGetSnapshot. And also get the anchor transform with MLSnapshotGetTransform? What's then the purpose/benefit of using OpenXR's xrLocateSpace if I must stick that much with the C API?

I did have time to test calling MLPerceptionGetSnapshot prior to calling xrLocateSpace. No improvement, the returned location still has XR_SPACE_LOCATION_POSITION_VALID_BIT and XR_SPACE_LOCATION_POSITION_TRACKED_BIT unset.

Hi @emaschino,

I wanted to let you know that we are currently working on getting answers for you.

I just noticed the experimental XR_ML_spatial_anchors extension with Magic Leap OS/SDK update 1.5.0 (January 2024). Looks promising.

@etucker, just to let you know that I rewrote my code leveraging XR_ML_spatial_anchors extension. The XR_SPACE_LOCATION_POSITION_VALID_BIT and XR_SPACE_LOCATION_POSITION_TRACKED_BIT are now correctly set :slightly_smiling_face:

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.