9

[Note: this question was written against the beta version of ARKit during the iOS11/High Sierra prerelease period. Preserved for historical interest only]

I'm seeing erratic placement and orientation for the world origin when I set the ARWorldTrackingSessionConfiguration.worldAlignment to .gravityAndHeading.

The position of the origin is steady after the scene opens. But the axes are often rotated 180 degrees or 90 degrees around the Y axis.

Is there an additional setting I'm missing? I'm running a 2017 iPad (vanilla, not Pro) and Xcode 9 beta 2. I've tested a few compass apps on this iPad and they give me correct results, so I believe the hardware is working correctly.

override func viewDidLoad() {
    super.viewDidLoad()
    
    // Set the view's delegate
    sceneView.delegate = self
    
    // Show statistics such as fps and timing information
    sceneView.showsStatistics = true
    
    // Create a new scene
    let scene = SCNScene()

    // debug options
    let debugOptions: SCNDebugOptions = [ARSCNDebugOptions.showFeaturePoints,ARSCNDebugOptions.showWorldOrigin]
    sceneView.debugOptions = debugOptions

    // Set the scene to the view
    sceneView.scene = scene
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    
    // Create a session configuration
    let configuration = ARWorldTrackingSessionConfiguration()
    configuration.worldAlignment = .gravityAndHeading
    configuration.planeDetection = .horizontal

    // Run the view's session
    sceneView.session.run(configuration)
}

Here are some samples (in all of them I'm facing south).

Positive X and Z point west and north (incorrect, 180 degrees out of phase):

enter image description here

Positive X and Z point east southeast and south southwest (close to correct):

enter image description here

Positive X and Z point east and south (correct), but origin is displaced a couple of meters:

enter image description here

Positive X and Z point south and west (90 degrees out of phase):

enter image description here

From the .gravityAndHeading documentation:

The y-axis matches the direction of gravity as detected by the device's motion sensing hardware; that is, the vector (0,-1,0) points downward.

The x- and z-axes match the longitude and latitude directions as measured by Location Services. The vector (0,0,-1) points to true north and the vector (-1,0,0) points west. (That is, the positive x-, y-, and z-axes point east, up, and south, respectively.)

Community
  • 1
  • 1
Hal Mueller
  • 7,019
  • 2
  • 24
  • 42
  • 3
    This looks like a very well written (and otherwise documented) bug report. [Have you filed one?](http://bugreport.apple.com) Also, neat clock. – rickster Jul 05 '17 at 00:34
  • Stuck on this as well. Anyone able to make any headway on this? – dmr07 Aug 03 '17 at 22:31

4 Answers4

2

I realize this is an old thread, however even with ARKit 2 release and I am using iOS 12, Xcode 10.1 with iPhone 8, I am still getting inconsistent world origin. In some cases where the blue line should be pointing to South, it is actually pointing to East or West.

I did try Sander's suggestion by using the location manager heading, but it is still not 100% guarantee I am getting the right direction to begin with.

Anyone has any other suggestion?

Andi Setiyadi
  • 197
  • 1
  • 1
  • 11
  • I think you're better off posing a brand new question (and maybe reference this one). We're long past Xcode 9 beta and you might be hitting a completely different issue. – Hal Mueller Dec 13 '18 at 22:23
0

I am getting occasional random world origin, where Y axis is NOT aligned with gravity, but is at maybe a 45 degree tilt. This is on Xcode 9.1 (beta) and iOS 11.0.3. If I reset the session, it redetects the Y axis correctly. (I am using gravityAndHeading).

As for heading, I am in a new downtown multi-story metal/brick/stucco building. Indoor Magnetic North detection is almost impossible. I have tested this extensively with many different devices. (I was doing drone navigation). The symptom was a floating north due to extremely low magnetic field. So sometimes it worked, but could change even +-90degrees in a few seconds.

It looks like you are testing indoors, with some brick walls...

0

I faced up with the same issue. My suggestion as a workaround to use CLLocationManager's delegate method to get true north

func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading)

In my experiments is shows more stable and correct results, although sometimes they are as wrong as .gravityAndHeading 's north.

Sander
  • 1,325
  • 1
  • 11
  • 30
0

No additional settings for this app are required. Your code is OK.

As you quoted from .gravityAndHeading documentation – longitude and latitude directions measured by Location Services. There is definitely a bug touching Location Services in Xcode 9 beta. I stumbled upon the same issue one year ago.

But now, when I'm using official release of Xcode 10, everything works fine. I tested it more than hundred times in different places (indoor and outdoor). A deviation from the true compass values is +2/-2 degrees.

Tested on iPhone X (MQA82LL) in iOS 12 (16A366).

macOS Mojave 10.14 (18A391), Xcode 10.0 (10A255).

Also, read this useful and informative article: Requesting Always Authorization. There are many tips.

enter image description here

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220