arcore-android-sdk icon indicating copy to clipboard operation
arcore-android-sdk copied to clipboard

Feature Request: Provide a geo-oriented world coordinate space

Open mrrichardli opened this issue 7 years ago • 24 comments

hi,guys, I'm developing an demo about ar navigation based on arcore, in which , i need to transform a set of (latitude,longtitude) s to anchors in arcore. as we know, if we get latlng1 and latlng2, we can calculate the real distance between them and the angle between vector( latlng1,latlng2) and the north direction. so if the worldcoordinate in arcore can be configed to that the origin of the coordinate is the the device position now, and the y axis is parallel to gravity , z axis is parallel to true north direction, x axis is parallel to east direction, our function will be very easy to implement. I haven't found where to config for the scene mentioned above in javadoc. is there any solutions for the current version of arcore? @jguomoto @inio @gordonbrander @eitanme @richlowenberg Meanwhile , i found that arkit support the config now .

https://developer.apple.com/documentation/arkit/arconfiguration.worldalignment/2873776-gravityandheading

edit by @inio: replaced inline screenshot of ARKit documentation with link.

mrrichardli avatar Jan 09 '18 02:01 mrrichardli

the ARCore world coordinate space always has +Y pointing up relative to gravity. Currently we do not provide any global orientation of the X/Z axes, though you may be able to work something out using the magnetometer sensor (on devices that have one) on your own.

Note: to get a device pose (coordinate system of the magnetometer), you'd need to rotate frame.getDisplayOrientedPose() by the opposite of the current display rotation. Something like this seems to work on my Pixel:

static final float sqrtHalf = (float) Math.sqrt(0.5f);
....
Pose deviceOrientedPose = frame.getCamera().getDisplayOrientedPose().compose(
    Pose.makeInterpolated(
        Pose.IDENTITY, 
        Pose.makeRotation(0, 0, sqrtHalf, sqrtHalf),
        mDisplayRotationHelper.getRotation()));

The makeRotation call produces a 90° rotation about the Z axis, and makeInterpolated is effectively doing transform exponentiation to turn that into a 0°, 90°, 180°, or 270° rotation based on the current display rotation.

inio avatar Jan 09 '18 19:01 inio

i still have some confusions

1、about the rotation

public Pose (float[] translation, float[] rotation) Rotation is a quaternion following the Hamilton convention. Assume the destination and local coordinate spaces are initially aligned, and the local coordinate space is then rotated counter-clockwise about a unit-length axis, k, by an angle, theta. The quaternion parameters are hence: x = k.x * sin(theta/2) y = k.y * sin(theta/2) z = k.z * sin(theta/2) w = cos(theta/2)

is k a vector or a number, what's the meaning of it? the param (x,y,z) mean the axis rotate by and w mean the angle rotate?

2、about the deviceOrientedPose

2.1 dose the deviceOrientedPose mean the device heading from the true north direction

2.2 sqrtHalf. why do we use it in calvulate rotation quaternian

2.3 display.getrotation only return the display rotation values, not the device heading, so it's useless to calculate the vector to transfrom from true north to the device heading pose.

sorry , articles about arcore development is rare, my problems are a little bit too much, thank you very much if you can help me to understand the arcore system. @inio

mrrichardli avatar Jan 10 '18 09:01 mrrichardli

@mrrichardli

  1. k is, as described "a unit-length axis". That's the axis about which to rotate.

2.1. deviceOrientedPose just lets you put sensor values (e.g. magnetometer) into the ARCore coordinate space. By applying the rotation portion of this pose (.extractRotation()) to sensor readings you can get those readings in the world coordinate space instead of device coordinates.

2.2 Just an artifact of the way quaternions work. A 90° rotation quaternion about an axis will always have two values zero and two values sqrt(1/2).

2.3 as described above, it's needed to get device oriented pose. ARCore only provides display and camera oriented poses right now.

inio avatar Jan 10 '18 18:01 inio

Please add this feature to the 1.0 release. Correct real world north alignment should be handled by the system. ARKit already implements this successfully.

lee-carnevale avatar Feb 19 '18 19:02 lee-carnevale

+1 for this. Need to port the arkit app in arcore.

abbana avatar Feb 28 '18 18:02 abbana

Here's a helper class that aggregates magnetometer data in world space and example use orienting a compass needle:

https://github.com/inio/arcore-android-sdk/commit/e829c05cef0b42f882a7b896e41f66f311fffb71

This sample code is not an official release and is totally unsupported.

inio avatar Mar 01 '18 22:03 inio

@inio It's a good start Inio ! Thanks a lot for that. Will test in the next weeks.

abbana avatar Mar 01 '18 22:03 abbana

Please add this feature in upcoming release, cause it's really needed

kdk96 avatar Apr 19 '18 16:04 kdk96

I second that of @kdk96 . @inio , is this on the radar for an upcoming release of ARCore? On a different note, thank you very much for all your contributions thus far. You and the AR team are doing some pretty incredible work.

ta10212 avatar May 23 '18 18:05 ta10212

We're looking at it. It's likely to show up as more formal sample code at some point, but becoming a first-class part of the ARCore API is looking unlikely. There's too much variation in magnetometer behavior across our supported device set, and using the magnetometer also can require user interaction to calibrate before you start getting good data.

inio avatar May 23 '18 19:05 inio

Thanks @inio , I suppose ARKit has the luxury of fewer devices to support. Appreciate the quick response and look forward to more formal sample code in the future.

ta10212 avatar May 23 '18 20:05 ta10212

For people using the above linked code, as of ARCore 1.3 CompassHelper.getDevicePose() can be replaced with Frame.getAndroidSensorPose().

inio avatar Jun 22 '18 14:06 inio

@mrrichardli hello, have you finished the ar navigation demo? i have the same issue now.

morevar avatar Jul 19 '18 12:07 morevar

Thanks @inio, awesome compass demo! I can not understand how it works, mDisplayRotationHelper.getRotation() always returns 0. And why we rotate around Z axis? I tried to get euler angles from result Pose and it have some mismatching (yaw is pitch, pitch is roll, roll is yaw).

image

How can I rotate coordinate system to force Y axis to true north?

AlexeyZatsepin avatar Aug 21 '18 09:08 AlexeyZatsepin

@inio anything official yet?

dev-aritra avatar Nov 28 '18 09:11 dev-aritra

@AlexeyZatsepin Can't help with your earlier questions, but in ARCore +Y is always up.

@dev-aritra Nope.

inio avatar Dec 01 '18 01:12 inio

@inio So I figured if I align my model in the ARCore scene according to the phone's Pose, and then calculate the magnetic orientation of the phone and rotate my model accordingly, that solves my problem. In order to do that I was using the Magnetometer sensor, but observed if I take a clockwise spin around the y-axis, the values changes like this 0(at 0 degrees) --> -45(at 90 degrees) --> 0 (at 180 degrees ) --> 33 (at 270 degrees )--> 0 Why is it 45 on 90 but only goes max up to 33 in 270? Is this supposed to be like this only? P.S. I tested on Pixel and S8 Edge And values differ by a small margin on different devices, in your idea how to tackle this problem? And what sensor would you use? Anything from you would help a lot 👍

dev-aritra avatar Dec 01 '18 12:12 dev-aritra

Please add this feature in upcoming release, cause it's really needed

AlexLiuSheng avatar Jan 21 '19 03:01 AlexLiuSheng

@nvictornvictor @fredsa @inio Will this feature be released in the upcoming Arcore 2.0? Can we know when to release Arcore 2.0? Because this feature is really needed.

ghost avatar May 30 '19 11:05 ghost

@nvictornvictor @fredsa @inio Anything up to date?

nhatvuminh avatar Jan 15 '21 03:01 nhatvuminh

Any news on this issue? It was opened 5 years ago...

telpat0298 avatar May 26 '23 14:05 telpat0298

Check out the ARCore Geospatial API: https://developers.google.com/ar/develop/geospatial

barbeau avatar May 26 '23 23:05 barbeau

Thx @barbeau. But enabling the geospatial api by generating an api key, enabling location services and adding other gradle dependencies seems a little excessive for just wanting to know where north is. I did it my self now with the device sensors. But i guess it would be an easy addition for ArCore. ARKit's already doing it

telpat0298 avatar May 27 '23 09:05 telpat0298

Thx @barbeau. But enabling the geospatial api by generating an api key, enabling location services and adding other gradle dependencies seems a little excessive for just wanting to know where north is. I did it my self now with the device sensors. But i guess it would be an easy addition for ArCore. ARKit's already doing it

Excuse me for interrupting. I'm also facing a similar issue, and I was wondering if you could share how you solved it? If it's not convenient to share here, would you mind emailing me at [email protected]? Thank you very much.

Could you also share your solution with me? [email protected]

konrad-thoc avatar Jul 31 '24 16:07 konrad-thoc