Include the following details (edit as applicable):
- Issue category: ARDK Documentation / VPS
- Device type & OS version: Android
- Host machine & OS version: Windows
- Issue Environment : On Device
- ARDK version: 2.0.0
- Unity version: 2021.1.3f1
Description of the issue:
Is tracking, with or without VPS, ever intended to take compass heading into account?
I initially assumed it would, but world Z+ seems to stay in roughly the direction the camera was facing when the app opened, rather than any real-world consistent direction.
My next idea, after reading some tangential references on a thread about deriving XYZ offsets from lat/lon (another part of my demo, but moot if directions are inconsistent), was to explore the Compass API, which I have to assume is wrapped into LocationService. However, a handler attached to LocationService.CompassUpdated seems to never get called, so I don’t seem to be able to get TrueHeading from that path.
If there’s a way to get to the underlying Compass API from whatever LocationService uses under the hood, or raw from the Unity side, neither the ARDK docs nor the Unity docs are particularly clear how to correctly get a Compass instance.
Once I can figure out how to establish a true-enough north relative to camera facing, it looks like the LatLng class has all the right kinds of helper functions for getting distances between geolocations, from which to place objects in the scene, but until I know the device’s real-world heading, I’m kinda stuck.
This is largely copypasta from various samples, and I can confirm OnLocationUpdate gets called. No evidence that OnCompassUpdate is hit, however.
//callback for the session starting. private void OnSessionInitialized(AnyARSessionInitializedArgs args) { //only run once guard ARSessionFactory.SessionInitialized -= OnSessionInitialized; //save the session. _session = args.Session; _locationService = LocationServiceFactory.Create(_session.RuntimeEnvironment); // For LocationService, we recommend using a desiredAccuracyInMeters of 1 and an updateDistanceInMeters of 0.001 for best results _locationService.Start(1, 0.001f); _locationService.LocationUpdated += OnLocationUpdate; _locationService.CompassUpdated += OnCompassUpdate; } private void OnCompassUpdate(CompassUpdatedArgs args) { _trueHeadingDeg = args.TrueHeading; _antiHeadingQuat = Quaternion.AngleAxis(-_trueHeadingDeg, Vector3.up); _compassNorth = _antiHeadingQuat * Vector3.forward; _compassEast = _antiHeadingQuat * Vector3.right; Debug.Log("Compass Updated"); }