3

When I tap a particular point in an ARKit scene, I get the X, Y, and Z coordinates of the point relative to the position of my device (Am I right?) I'd like to know the absolute position of the point on earth, not just relative to my device.

So far, my logic is to get the longitude, latitude, altitude, heading (compass direction), and attitude (rotation) of the device and calculate the absolute position of the point based on that.

Wondering if there is a simpler way than that.

1 Answer 1

3

ARKit doesn't have any features for tracking device position or placing content in "absolute" geospatial coordinates. Actually doing that (and doing it well) is sort of a hard problem... but there are a few things to help you on your way.

First, check out the ARSessionConfiguration worldAlignment setting. With the default gravity option, x and z directions are relative to the device's original heading, as of when you started the session. Getting from there to geospatial coordinates is next to impossible.

But with the gravityAndHeading option, the axes are fixed to north/south and east/west — the position of the ARKit coordinate system's origin is still relative to where the device is at the beginning of the session, but the directions are absolute. That gives you a basis for converting to/from geospatial coordinates.

But there's still a question of precision. ARKit tracks features up to a few meters away, down to a precision of a couple millimeters. Core Location tracks the device to a precision of several meters. So, if you have a real-world feature and you want to put virtual content on top of it... you could convert a lat/long to a position in ARKit space, but then you're likely to find that your content doesn't really line up close enough.

It's not an unsolvable problem, but not an easy one either. Good luck!

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.