Messy world origin / alignment for ARSessionConfiguration.WorldAlignment = .gravityAndHeading

[Note: this question was written against the beta version of ARKit during the pre-release version of iOS11 / High Sierra. Retained for historical interest only]

I see erroneous placement and orientation for world origin when I set ARWorldTrackingSessionConfiguration.worldAlignment to .gravityAndHeading .

The position of the origin is stable after the scene is opened. But the axes often rotate 180 or 90 degrees around the Y axis.

Are there any additional settings that I skip? I use iPad 2017 (vanilla, not Pro) and Xcode 9 beta 2. I have tested several compass apps on this iPad and they give me the correct results, so I believe that the equipment works correctly.

 override func viewDidLoad() { super.viewDidLoad() // Set the view 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 session sceneView.session.run(configuration) } 

Here are a few samples (in all I look south).

Positive X and Z indicate west and north (wrong, 180 degrees against the phase):

enter image description here

Positive X and Z indicate east southeast and south southeast (close to right):

enter image description here

Positive X and Z indicate east and south (correctly), but the origin is offset by a couple of meters:

enter image description here

Positive X and Z indicate south and west (90 degrees against phase):

enter image description here

From the .gravityAndHeading documentation:

The y-axis corresponds to the direction of gravity detected by hardware that is sensitive to the movement of the device; that is, the vector (0, -1, 0) points down.

The x- and z-axes correspond to the longitude and latitude directions measured by the Location Services. Vector (0,0, -1) indicates true north, and vector (-1, 0,0) indicates west. (That is, the positive x-, y-, and Z axes indicate east, up, and south, respectively.)

+7
source share
4 answers

I get a random random world origin where the Y axis is NOT aligned with gravity, but there may be a 45 degree tilt. This is on Xcode 9.1 (beta) and iOS 11.0.3. If I reset the session, it will regenerate the Y-axis correctly. (I am using gravityAndHeading).

As for the headline, I am in a new multi-story metal / brick / stucco building in the city center. Internal magnetic detection of the North is almost impossible. I have tested this many times with many different devices. (I did unmanned navigation). The symptom was floating north due to the extremely low magnetic field. So sometimes it worked, but even -90 degrees can change within a few seconds.

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

0
source

I ran into the same problem. My suggestion is to use the delegate method CLLocationManager as a workaround to get true north

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

My experiments show more stable and correct results, although sometimes they are just as wrong as .gravityAndHeading north.

0
source

No additional settings are required for this application. Your code is ok.

As you pointed out in the documentation. GravityAndHeading is the longitude and latitude directions measured by Location Services definitions of Location Services . There is definitely a bug regarding Location Services in the beta version of Xcode 9. I ran into the same problem a year ago.

But now, when I use the official release of Xcode 10, everything works fine. I checked it more than a hundred times in different places (indoors and outdoors). Deviation from the true compass value is +2 / -2 degrees.

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

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

Also, read this helpful and informative article: Always request authorization . There are many tips.

enter image description here

0
source

I understand that this is an old topic, however, even with the release of ARKit 2, and I use iOS 12, Xcode 10.1 with iPhone 8, I still get a conflicting world background. In some cases, when the blue line should point south, it actually points east or west.

I tried Sander's suggestion using the header of the location manager, but it is not yet a 100% guarantee that I get the right direction to start.

Anyone have any other suggestions?

0
source

Source: https://habr.com/ru/post/1269464/


All Articles