World pose

Hi,

I am able to estimate (quite accurately) the pose of the ML2 WorldCamera in my own metric world coordinate frame that is based on a laser scanned point cloud. This point cloud represents the room, where the AR headset user is standing.

My question is: how should I use this pose in my Unity project so that all the virtual game objects aligned with the point cloud / world coordinate frame would show up in correct places?

In ARFoundation for Android mobile phones, I just set the ARSessionOrigin to the inverse of the estimated camera pose in world frame.

Due to some legacy code, I am still using Magic Leap SDK v1.4.0 and Unity 2022.3.17f1.

I have XR Rig in my scene and Session Origin as a child for it. Setting up the the Session Origin transform to the inverse of the camera pose in world frame does not work.

Best Regards,
Paul

I don't know if I fully understand your question, so please correct me if we are talking about different things. Are you trying to align your point cloud in the same location across multiple sessions? Are you using the extrinsic and intrinsic values of the world cameras provided by the Magic Leap SDK?

Have you tried disabling the reset origin setting on the Magic Leap camera component? When you say "does not work" what do you see?

Hi. Sorry about being unclear. I was not talking about ML2 point cloud. The goal is to localize ML2 headset against third party (laser scanned) colored point cloud simply by using the world camera image (+ intrinsics and distortion coefficients) from ML2 and then adjust the session origin in such a way that virtual objects (that are in the same building coordinate frame than the colored point cloud) are seen in their correct places in the environment.

I had a mistake in code, where I adjust the transform of the SessionOrigin game object. This is how I did it finally:

Vector3 worldPos = ..; // Camera position in building coordinate frame
Quaternion worldRot = ..; // Camera rotation in building coordinate frame
Vector3 cameraPos = ..; // Camera local position tracked by ML2 at image capture time
Quaternion cameraRot = ..; // Camera local rotation tracked by ML2 at image capture time

Quaternion rotOffset = worldRot * Quaternion.Inverse(cameraRot);
sessionOrigin.transform.localPosition = worldPos - rotOffset * cameraPos;
sessionOrigin.transform.localRotation = rotOffset;

The localization work amazingly well! Nice replacement for markers and way less work (this way I don't have to print markers, place them and define their pose in the building coordinate frame).

This thread can be closed.

Regards,
Paul

1 Like