arcore-android-sdk
arcore-android-sdk copied to clipboard
ArCamera_getViewMatrix doesn't starts at identity and is rotated around Y, after while jumps to identity , v1.39
Edit: TL;DR: not calling ArSession_configure or calling it only with ArConfig_setxx defaults will cause view matrix returned from ArCamera_getViewMatrix (at the session start and good tracking state) to be in non-identity for X-axis and jumps back into identity after few move-arounds or by itself.
SPECIFIC ISSUE ENCOUNTERED
Updated from arcore 1.33 to 1.39 ,and found that when session starts and camera is in tracking state,ArCamera_getViewMatrix returns matrix where x-axis is not in identity unlike my previous 1.33 version, but is rotated.(cca 90deg counterclockwise) after a while it returns back into identity or after little move-around with the device. Jump is very visible on the content in AR - content rotates clockwise around Y. However it can be observed directly in valuse of the returned viewMatrix from the ArCamera_getViewMatrix.
VERSIONS USED
-
Android Studio: - Java 17 NDK 25.1.8937393 AndroidStudio Giraffe Android Studio Giraffe | 2022.3.1 Patch 1 Build #AI-223.8836.35.2231.10671973, built on August 17, 2023 Runtime version: 17.0.6+0-17.0.6b829.9-10027231 aarch64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
-
ARCore SDK for Android: 1.39 Device manufacturer, model, and O/S: Pixel 7 Pro Android v 13, can reproduce on Galaxy S8 too
-
Google Play Services for AR (ARCore):
Packages: versionName=1.39.232070593 Hidden system packages: versionName=0 mLastCancelledPackages: -
Output of
adb shell getprop ro.build.fingerprint
: google/cheetah/cheetah:13/TQ2A.230305.008.C1/9619669:user/release-keys
STEPS TO REPRODUCE THE ISSUE
Edit: in the hello_ar_c disable configSession or ArSession_configure to reproduce it. see workaround below
this is easily reproducable on above device. use for example stock example hello_ar_c and log first element of the viewMatrix (X component of the X-axis) - place after this line: https://github.com/google-ar/arcore-android-sdk/blob/master/samples/hello_ar_c/app/src/main/cpp/hello_ar_application.cc#L182 LOGE("--- View Matrix [0] = %0.5f",view_mat[0][0]);
-
use device holder and place there android
-
run the app and observe initial log of the viewMatrix reports 0.0xx so is not close at all to 1.0, is not in identity (or close to it) e.g. E --- View Matrix [0] = -0.00493
-
pick the device from the holder, and move around with it little bit - observe how the log of the x correctly changes based on your rotation.
-
Place device back into the holder and observe jump after few seconds, observe the log (log matrix) and see log reports after ar_core logs "pose_manager.cc:330] World pose node changing to MapId..." to see sudden jump into X-axis identity .e.g. you will see:
E --- View Matrix [0] = -0.03680 I I0000 00:00:1695108431.210609 12201 pose_manager.cc:330] World pose node changing to MapId:65099514-3a50-2f76-897e-a2f144548fe2 with 4 opt. E --- View Matrix [0] = 0.99876
sometimes device doesn't need to be moved around and jumps to X-identity by itself after some time.
WORKAROUNDS (IF ANY)
no known, version 1.33 of arcore from google play didn't have this issue. Edit : this is related to not calling ArSession_configure with assumptions that defaults are ok or calling it but with default values.
following workaround works: for example: default value for ArConfig_setInstantPlacementMode is AR_INSTANT_PLACEMENT_MODE_DISABLED, lets change it to non default:
ArConfig_setInstantPlacementMode(ar_session_, ar_config, AR_INSTANT_PLACEMENT_MODE_LOCAL_Y_UP);
ArSession_configure(ar_session_, ar_config);
and above will workaround the problem.
ADDITIONAL COMMENTS
attached log (as example of the above steps to reproduce):