0

I am trying to use the .gravityAndHeading on my ARWorldTrackingConfiguration.worldAlignment configuration. However, I keep getting this error:

Device orientation error: Error Domain=CMErrorDomain Code=102 "(null)" 2018-03-01 20:08:25.218445+0000 App[759:84092] [Session] Session (0x10ba12ce0): did fail with error: Error Domain=com.apple.arkit.error Code=102 "Required sensor failed." UserInfo={NSLocalizedFailureReason=A sensor failed to deliver the required input., NSUnderlyingError=0x1c0850740 {Error Domain=CMErrorDomain Code=102 "(null)"}, NSLocalizedRecoverySuggestion=Make sure that the application has the required privacy settings., NSLocalizedDescription=Required sensor failed.} Session failed. Changing worldAlignment property.

The docs said to ensure that Info.plist contains the relevant privacy requirements - I've added camera, location, motion etc. but to no avail.

Anyone experienced the same/worked out a solution?

I am using this specific setting because I need to map nodes to the physical world, not just to the relative position of the user.

Josh
  • 529
  • 6
  • 21

2 Answers2

5

Have you added these keys to your info.plist?

enter image description here

Based on other resesarch e.g. What Does Error Code 102 Mean it seems that the following may be applicable to your situation:

CMErrorTrueNorthNotAvailable

From the post above one StackOverFlow user seems to have solved the issue by changing the following settings on their device:

Settings > Privacy > Location Services > System Services > Compass Calibration:

enter image description here

BlackMirrorz
  • 7,217
  • 2
  • 20
  • 31
  • Ahh! Thank you so much, this is invaluable! Not sure how I missed that SO question as I was searching avidly for a solution. The Compass Calibration did the trick. – Josh Mar 02 '18 at 12:22
1

Also in addition to the answer from @JoshRobbins above, I had a new iPhone and noticed that it was turned off by default, so the app crashed. The enduser doesn't know he has to go into settings and turn compass calibration on. The following bypasses that:

let configuration = ARWorldTrackingConfiguration()

func session(_ session: ARSession, didFailWithError error: Error) {

    switch error.code {
    case 102:
        configuration.worldAlignment = .gravity
        restartSession()
    default:
        configuration.worldAlignment = .gravityAndHeading
        restartSession()
    }
}

@objc func restartSession() {

    self.sceneView.session.pause()

    self.sceneView.session.run(configuration, options: [
        .resetTracking,
        .removeExistingAnchors])
}
Peter de Vries
  • 780
  • 1
  • 6
  • 14