Arkit Setting Worldtrackingconfiguration to Gravityandheading Produces Error

ARKit setting WorldTrackingConfiguration to gravityAndHeading produces error

Have you added these keys to your info.plist?

Sample Image

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:

Sample Image

ARKit Stereo – Is it possible to run two ARSCNView at the same time?

The answer is: Yes, it's possible.

Use the following code to accomplish it:

import UIKit
import SceneKit
import ARKit

class ViewController: UIViewController, ARSCNViewDelegate {

@IBOutlet weak var sceneView: ARSCNView!
@IBOutlet weak var sceneView2: ARSCNView!

override func viewDidLoad() {
super.viewDidLoad()

sceneView.delegate = self
sceneView.showsStatistics = true
let scene = SCNScene(named: "art.scnassets/ship.scn")!
sceneView.scene = scene
sceneView.isPlaying = true

// Setup for sceneView2
sceneView2.scene = scene
sceneView2.showsStatistics = sceneView.showsStatistics

// Now sceneView2 starts receiving updates
sceneView2.isPlaying = true
}

override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
let configuration = ARWorldTrackingConfiguration()
sceneView.session.run(configuration)
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
sceneView.session.pause()
}
func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
DispatchQueue.main.async {
self.updateFrame()
}
}
func updateFrame() {
// Clone pointOfView for Second View
let pointOfView: SCNNode = (sceneView.pointOfView?.clone())!

// Determine Adjusted Position for Right Eye
let orientation: SCNQuaternion = pointOfView.orientation
let orientationQuaternion: GLKQuaternion = GLKQuaternionMake(orientation.x,
orientation.y,
orientation.z,
orientation.w)
let eyePos: GLKVector3 = GLKVector3Make(1.0, 0.0, 0.0)
let rotatedEyePos: GLKVector3 = GLKQuaternionRotateVector3(orientationQuaternion,
eyePos)
let rotatedEyePosSCNV: SCNVector3 = SCNVector3Make(rotatedEyePos.x,
rotatedEyePos.y,
rotatedEyePos.z)
let mag: Float = 0.064 // Interocular distance (in metres)
pointOfView.position.x += rotatedEyePosSCNV.x * mag
pointOfView.position.y += rotatedEyePosSCNV.y * mag
pointOfView.position.z += rotatedEyePosSCNV.z * mag

// Set PointOfView for SecondView
sceneView2.pointOfView = pointOfView
}
}

For more details look at this project on a GitHub.

Sample Image

What does Core Motion error 102 mean?

As Krishnabhadra correctly pointed out, this error code means CMErrorTrueNorthNotAvailable. The description ("True north is not available on this device. This usually indicates that the device’s location is not yet available.") unfortunately doesn't give any hint how to solve the issue so I'd like to describe my findings when this error occurs.

It occurs on a tiny (a handful out of many thousands) fraction of iOS 6.0+ devices when using CMAttitudeReferenceFrameXTrueNorthZVertical (CMAttitudeReferenceFrameXMagneticNorthZVertical is OK). Despite the error description, Core Location works correctly. On affected devices the bug is triggered in 100% of the cases and blocks Core Motion updates completely. -[CMMotionManager deviceMotion] always returns nil.

Resetting the iOS system settings fixes the problem.

I’ve logged rdar://12952327 with some more details.

Update:
This error occurs if compass calibration is disabled in the privacy / location services / system services section.

handle didFailToLocateUserWithError when user do not allow to use location services

You should check whether the authorisation status is authorised and only execute any functions requiring location usage if the status is authorised. Otherwise either request authorisation or show an alert to user to turn them on. This way you don't need to handle errors, since you are only calling the functions if you actually have authorisation to do so.

let locationManager = CLLocationManager()
if CLLocationManager.authorizationStatus() == .notDetermined {
locationManager.requestWhenInUseAuthorization()
} else if CLLocationManager.authorizationStatus() == .authorizedWhenInUse {
mapView.showsUserLocation = true
} else {
//show alert
}

Keep in mind that the system only displays the built-in authorisation dialog if the authorisation status is not determined. If the user declined authorisation, the built-in dialog will never be shown again, hence in this case, you need to present a custom UIAlertController telling the user to turn on authorisation in Settings if they want to use the location-related features of your app.



Related Topics



Leave a reply



Submit