问题
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.
回答1:
Have you added these keys to your info.plist
?
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:
回答2:
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])
}
来源:https://stackoverflow.com/questions/49058263/arkit-setting-worldtrackingconfiguration-to-gravityandheading-produces-error