Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question ARFoundation - AnchorManager.anchorsChanged - Tracking stability indicator

Discussion in 'AR' started by AlexisDelforges, Mar 30, 2022.

  1. AlexisDelforges

    AlexisDelforges

    Joined:
    Nov 30, 2021
    Posts:
    22
    Hello,
    We are placing a building model in 1:1 scale in AR using ARFoundation. Once the initial position is set by the user, we anchor (using ARFoundation anchor creation) the model to the real life position.
    Depending on several factors, the model might drift (difference between real life position and AR position). Some factors are covered by ARFoundation tracking state (fast motion, no light, no textures...); but little drifts can be detected using this method.

    We've found that once AnchorManager.anchorsChanged is triggered and that the anchor is included in the update list in the event (position of the anchor has changed); the position of the model will not be recalculated and the drift is permanent.

    Has anyone experience this as a tracking stability indicator ? Saying that if the anchor has been updated in terms of position, we should no longer consider model to be at the correct life position ?


    Code (CSharp):
    1.  
    2. //somewhere in the app
    3. anchorManager.anchorsChanged += AnchorManagerOnanchorsChanged;
    4.  
    5. private void AnchorManagerOnanchorsChanged (ARAnchorsChangedEventArgs obj) {
    6.             Debug.Log ($"Added {obj.added.Count}  * Updated {obj.updated.Count}  * Removed {obj.removed.Count}");
    7.             if (obj.updated != null && obj.updated.Count > 0) {
    8.                 foreach (ARAnchor anchor in obj.updated) {
    9.                     Debug.Log ($"updated this anchor :  {anchor}");
    10.                     Debug.Log (anchor.gameObject.transform.position.x + " * " + anchor.gameObject.transform.position.y + " * " + anchor.gameObject.transform.position.z);
    11.                     ARQualityTracking.Instance.ForceAnchorTracking (true);
    12.                 }
    13.             }
    14.  }
    15.  
    Anchor drift is for example :
    Anchor drift :
    -0.5840324 -0.883183 -0.6342438
    -0.5819342 -0.884117 -0.6348923
    -0.581746 -0.8842891 -0.6351437
    ..

    which is enough is our use case for the model to be unaligned with real life.

    Tested on :
    Softs :
    ARFoundation 4.2.2 (and 4.1.9)
    ARKit 4.2.2 (and 4.1.9)
    Unity 2020.3.31f1
    Xcode 13.3

    Hardware :
    Ipad Pro 2021
    Iphone 13 Pro Max