Search Unity

ARAnchor to improve tracking [ARFoundation]

Discussion in 'Handheld AR' started by eco_bach, Mar 12, 2019.

  1. eco_bach

    eco_bach

    Joined:
    Jul 8, 2013
    Posts:
    1,352
  2. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    518
    Yes, we call them "reference points" in ARFoundation. There is documentation for adding and removing them here.
     
  3. eco_bach

    eco_bach

    Joined:
    Jul 8, 2013
    Posts:
    1,352
    Awesome. Thanks. however that is the method documentation only.
    Are there any actual code examples in the context of an actual application?
     
    Last edited: Mar 13, 2019
  4. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
  5. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    110
    I would hope so @GreeneMachine , I'm trying to figure these out myself too.

    I'm trying to remove a reference point TryRemoveReferencePoint -> but this takes the refPoint trackableID which seems not exposed, how do I get a refPoint trackableID? I tried to casting from the refPoint name but doesn't work.

    Cheers
     
  6. tdmowrer

    tdmowrer

    Unity Technologies

    Joined:
    Apr 21, 2017
    Posts:
    518
    There is a version which takes an
    ARReferencePoint
    .
     
  7. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    110
    Yay I miss that, so silly, thank you @tdmowrer !

    Can I also please get your two cents, does this make sense: When the user moves an object that has an AR Ref Point I want to update the ARReferencePoint to this new location. So I'd delete the previous ARReferencePoint, creating a new one, and re-parenting the gameobject to this new point? I couldn't figure out if there is a way to update the ARReferencePoint position to a new raycasted hitPoint which could save on performance.

    Thanks a bunch for your thoughts!
     
    Last edited: May 23, 2019
  8. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    110
    Hello @tdmowrer

    Unfortunately TryRemoveReferencePoint(ARReferencePoint) is freezing Unity.

    Each time I racyast and touch I can create a ARReferencePoint.

    I can store the ARReferencePoint and reparent an object to this point each time.
    upload_2019-5-27_7-44-24.png

    upload_2019-5-27_7-45-29.png

    But if I then add another line of code to actually remove the previous ARReferencePoint, Unity freezes, doesn't crash but freezes indefinitely (code at end of post).

    m_ARRefPointMgr.TryRemoveReferencePoint(prevRefPoint);

    Console debug or VS Attach to Unity doesn't show any results cos Unity freezes and can't see what the problem maybe, can you please shed some light?

    Thank you for your help, Sergio
    Unity 2019.1.1f1, ARFoundation 1.1.0 preview.6, lwrp 5.6.1, XRRemoting 0.0.1 preview .10

    sample code using ARRemote:
    if (m_SessionOrigin.Raycast(ray, s_Hits, TrackableType.PlaneWithinPolygon))
    if (spawnedObject == null)
    {
    spawnedObject = Instantiate(m_PlacedPrefab, hitPose.position, Quaternion.identity);
    spawnedObject.transform.SetParent(m_CurrentRefPoint.transform);
    Debug.Log("Instantiated");
    }
    else
    {
    spawnedObject.transform.position = m_CurrentRefPoint.transform.position;
    spawnedObject.transform.SetParent(m_CurrentRefPoint.transform);
    Debug.Log("Current Ref Point: " + m_CurrentRefPoint + " Removing RefPoint:" + prevRefPoint);
    m_ARRefPointMgr.TryRemoveReferencePoint(prevRefPoint);
    }
    prevRefPoint = m_CurrentRefPoint;
     
  9. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    110
    Hi @tdmowrer , using ARF 2.1 RemoveReferencePoint works :)

    One question to clarify the use of Anchors please: is it generally the case that after an initial anchor has been created and parented to an object that when moving the object a new RefPoint is created for the new position or rather keep using the initial RefPoint?

    Thank you for your help, Sergio
     
  10. ArmanUnity

    ArmanUnity

    Joined:
    Nov 29, 2015
    Posts:
    21
    ArCore doc says:
    When anchoring objects, make sure that they are close to the anchor you are using. Avoid placing objects farther than a few meters from the anchor to prevent unexpected rotational movement due to ARCore's updates to world space coordinates.

    If you need to place an object more than a few meters away from an existing anchor, create a new anchor closer to this position and attach the object to the new anchor
    @Tarrag
     
  11. Tarrag

    Tarrag

    Joined:
    Nov 7, 2016
    Posts:
    110
  12. hitenyudiz

    hitenyudiz

    Joined:
    May 11, 2017
    Posts:
    4
    One more question to the ARReferencePoint is how to scale the object inside the ARReferencePoint.. what i have did is i have created ar reference point and put some game object inside it. but when i try to scale the origin then it doesn't scale anymore.
     
  13. liccarry

    liccarry

    Joined:
    Jul 25, 2019
    Posts:
    1
    Hi, There is a ARParticipantAnchor that represents another user in a multiuser AR experience in ARKit, You can see it here:https://developer.apple.com/documentation/arkit/arparticipantanchor?language=objc
    But I can't find it in ARFoundation.I run the ARFoundation Demo. I still can't find it. So where can I find it.
     
    ambergarage likes this.