Search Unity

Question How to prevent app from moving world origin?

Discussion in 'AR' started by MabelChoi, Jul 14, 2020.

  1. MabelChoi

    MabelChoi

    Joined:
    Jun 8, 2020
    Posts:
    4
    Hi, I've wanted to fix transform of attached object on marker, and I guessed the solution is stop update trackables position.
    I've already tried to disable ARTrackedImageManager. However, world origin transform was continuously moving due to the update method in ARSessionOrigin method.
    So I thought skipping the method might be a solution. (Also not a solution I guess)

    This one is what I tried to.
    Code (CSharp):
    1.  
    2. private bool isPinned = false;
    3. public bool IsPinned     { get { return isPinned; } set { isPinned = value; } }
    4.  
    5. void Update()
    6.         {
    7.             if (camera && ! isPinned)
    8.             {
    9.                 var pose = GetCameraOriginPose();
    10.                 trackablesParent.position = pose.position;
    11.                 trackablesParent.rotation = pose.rotation;
    12.             }
    13.         }
    And this way didn't work. ARTrackedImageManager was disabled, isPinned was true, and world vector still moved.
    Is there any way to prevent moving world origin vector/transform?

    FYI, I use Unity 2019.4.1f & AR Foundation v3.1.3
     
    Last edited: Jul 14, 2020
  2. KyryloKuzyk

    KyryloKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    1,144
    Could you please elaborate on what you're trying to achieve?
    Do you use Image Tracking and want to spawn some GameObject on top of a detected image?
     
  3. MabelChoi

    MabelChoi

    Joined:
    Jun 8, 2020
    Posts:
    4
    It is my goal to fix some GameObject on top of a detected image, and prevent moving unity world according to the camera position/rotation.
    For now, I succeeded to spawn some GameObject on top of a marker using Image Tracking, and set disable ARTrackedImageManager.cs to pin the GameObjects.

    This video might be helpful to understand the issue what I've faced.
    Watch after 0:16.
    Video flow is like this: An object is attached to the html marker. And I push the "pin" button on the right upper side to set disable ARTrackedImageManager. You can see the position on the left upper side in the screen. It doesn't change even the GameObject move to strange position.

    (You can reach bigger video from here: https://player.vimeo.com/video/438116809 )

    I think this issue is caused by updating ARSession. It continuosly reset position/rotation of the world origin pos.
     
  4. KyryloKuzyk

    KyryloKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    1,144
    I don't think ARSession is to blame here. What I saw in the video is an issue with ARKit/ARCore drifting. The underlying subsystem doesn't have enough feature points do determine its position in space and it tries to guess it.

    Please try not to hold your image marker in front of your phone. The image marker is constantly moving and AR Subsystem can't understand its location properly.
     
  5. MabelChoi

    MabelChoi

    Joined:
    Jun 8, 2020
    Posts:
    4
    Thank you for your advice. But it makes me confused. So let me explain what I understood.

    I'd like to move my image marker, cause it is necessary to check whether the gameobject is fixed in the world or not after turning off the Tracked Image Manager script.
    Just for make sure, let me elaborate my goal once more. My goal is anchoring object using marker, and if the object spawned and be fixed, people could be watching it while walking around the object without detect any markers.
    I knew that there is an issue with AR sdk drifting, but didn't think this is also the same issue because I already turned the manager script off.

    Is there no way to prevent drifting object when I turn off image tracking? Did I understand right?
     
    Last edited: Jul 14, 2020
  6. KyryloKuzyk

    KyryloKuzyk

    Joined:
    Nov 4, 2013
    Posts:
    1,144
    Although you turned the ARTrackedImageManager off, the AR System keeps running to update its position in space.
    The drifting is not related to Image Tracking. To reduce drifting and to improve tracking quality it's not recommended for moving objects to be in camera frame.
     
  7. MabelChoi

    MabelChoi

    Joined:
    Jun 8, 2020
    Posts:
    4
    Thanks again! I'd try other way to achieve it.