Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Geo-localised objects in AR core.

Discussion in 'ARCore' started by rguenon, Jul 12, 2018.

  1. rguenon

    rguenon

    Joined:
    Jul 2, 2018
    Posts:
    3
    Hi.

    I am trying to place geo-localized augmented object using ARCore.

    To do so, I would need the scene Z axis to point north which I didn't found how to do (without breaking the tracking).

    I tried to place the objects relatively to the camera but I couldn’t get a good "north direction" by comparing the camera angle and the compass.

    Would anyone have some hint on how to do so?

    Thank you in advance for your answers.
     
  2. JVaughan

    JVaughan

    Joined:
    Feb 6, 2013
    Posts:
    20
    *Bumping this thread*. Cloud anchors are nice but sometimes we need something much more persistent.
     
  3. danielesuppo

    danielesuppo

    Joined:
    Oct 20, 2015
    Posts:
    130
    Place objects in georeferenced position, as child of a transform that you can rotate to point the north.
    Hope this help
     
  4. rguenon

    rguenon

    Joined:
    Jul 2, 2018
    Posts:
    3
    I managed to get a good-enough geo-localised placement.

    Some tricks I used:
    I placed the objects relatively to the camera. To do so, I use UTM projection coordinates to get a cartesian space with the same units as the “ARCore world”.

    I don’t use the compass but the gyroscope. The angle between the gyroscope and the north doesn’t change so it is usable (Although I read somewhere that it can be dependent on the captor) and it is easier to compare it with the angle of the Camera in the Unity scene.

    So, using the gyroscope and the GPS, I can have a north direction, and a vector between the camera and the geo-localised object, allowing me to place it at the right place.


    With some filtering to de-noise the captor, I have an object placed in the AR view with the same precision as the GPS (around 5 or 6 meters most of the time).
     
  5. danielesuppo

    danielesuppo

    Joined:
    Oct 20, 2015
    Posts:
    130
    It's a really good idea to use gyroscope in place of compass, maybe do you have some advice on how to get north from it?
    About gps, are you actually using iPhone? I have a Samsung S8 and gps "precision" is around 5 up to 20 meters (!), despite the accuracy reported by the sensor...
     
  6. rguenon

    rguenon

    Joined:
    Jul 2, 2018
    Posts:
    3
    As the Gyroscope is pointing to the north (I got a (0,0,0) angle when pointing north), what I do is calculate the delta angle between the camera/phone and the north.

    Here is the code I use (there is probably a cleaner and better way to do it, without using the transform, but it works):


    Code (CSharp):
    1. Vector3 previousObjectAngle = transform.eulerAngles;
    2.  
    3. transform.localRotation = Input.gyro.attitude;
    4. transform.Rotate(0f, 0f, 180f, Space.Self); // Swap "handedness" of quaternion from gyro.
    5. transform.Rotate(90f, 180f, 0f, Space.World); // Rotate to make sense as a camera pointing out the back of your device.
    6.  
    7. float deltaAngle = Mathf.DeltaAngle(transform.eulerAngles.y, transform.eulerAngles.y);
    8.  
    9. transform.eulerAngles = previousObjectAngle;
    10.  
    To get a stable position in ARCore, you might want to de-noise the angle before using it (I use lerp. It does the trick).


    I use a Samsung S9, but the 5-6 meters GPS precision was measured on a cleared ground. It goes around 20-30 meters if I go near tall buildings, trees or obstacles.