google-ar / arcore-android-sdk

ARCore SDK for Android Studio
https://developers.google.com/ar
Other
4.95k stars 1.22k forks source link

ArCamera_getViewMatrix doesn't starts at identity and is rotated around Y, after while jumps to identity , v1.39 #1613

Open Sumbera opened 1 year ago

Sumbera commented 1 year ago

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

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]);

  1. use device holder and place there android

  2. 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

  3. 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.

  1. 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):

jumpInViewMatrix