[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):
Positive X and Z point east southeast and south southwest (close to correct):
Positive X and Z point east and south (correct), but origin is displaced a couple of meters:
Positive X and Z point south and west (90 degrees out of phase):
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.)
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?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With