CoreLocation:CPAS数据响应是invaild

时间:2016-10-18 20:56:46

标签: ios swift core-motion

在使用iOS 10.0.2的iPhone 6上,我收到以下代码时出错:

class ViewController: UIViewController {

    @IBOutlet weak var startStop: UIButton!

    var isRunning = false

    let manager: CMMotionManager = {
        let manager = CMMotionManager()
        manager.deviceMotionUpdateInterval = 1/100
        return manager
    }()

    @IBAction func handleStartStop(_ sender: AnyObject) {
        if isRunning {
            stopMotionUpdates()
            startStop.setTitle("Start", for: .normal)
        } else {
            startMotionUpdates()
            startStop.setTitle("Stop", for: .normal)
        }
        isRunning = !isRunning
    }

    func startMotionUpdates() {
        manager.startDeviceMotionUpdates(using: .xTrueNorthZVertical, to: .main) { (data, error) in
            print("Roll: \(data!.attitude.roll), Pitch: \(data!.attitude.pitch), Yaw: \(data!.attitude.yaw)")
        }
    }

    func stopMotionUpdates() {
        manager.stopDeviceMotionUpdates()
    }

}

输出:

2016-10-19 07:45:13.865847 CoreMotionTest[562:350766] CoreLocation: CPAS data response was invaild.
Roll: -0.0135864792263794, Pitch: 0.00864587532420694, Yaw: 6.47493275587377e-05
Roll: -0.0135915108585011, Pitch: 0.00865699352311076, Yaw: 7.09129926643357e-05
Roll: -0.0135963930210582, Pitch: 0.00867386848019366, Yaw: 8.84424471509634e-05
Roll: -0.0136066048134502, Pitch: 0.00868011794373523, Yaw: 0.000105925819254466
Roll: -0.0136114190872102, Pitch: 0.00867577431915433, Yaw: 0.000117932969705823
Roll: -0.0135948730328641, Pitch: 0.00867657982050841, Yaw: 0.00012968687069689
Roll: -0.0135732480451522, Pitch: 0.00867729811777266, Yaw: 0.000152007924023406
Roll: -0.0135619969691634, Pitch: 0.00868342424259059, Yaw: 0.000163872505991956
Roll: -0.013304139897602, Pitch: 0.00874500976978164, Yaw: 0.000179014630004322
Roll: -0.0133409772363028, Pitch: 0.00887204866716325, Yaw: 0.00018600114405152
Roll: -0.0130968013066843, Pitch: 0.00890815168076916, Yaw: 0.000201127439543817
Roll: -0.0129980717242318, Pitch: 0.00898203106432451, Yaw: 0.00022290167061286
Roll: -0.013058759809209, Pitch: 0.008972000868579, Yaw: 0.000240753238817741
Roll: -0.0130954579972119, Pitch: 0.0089717830946822, Yaw: 0.000258417382421598

知道这意味着什么吗?

1 个答案:

答案 0 :(得分:1)

它与使用指南针的请求有关。 xMagneticNorthZVertical导致它,而xArbitraryZVertical则没有。