无法使用 watchOS 5 获取 Core Motion 更新:“[陀螺仪] 手动将陀螺仪中断校准设置为 800”

Cannot get Core Motion Updates using watchOS 5: "[Gyro] Manually set gyro-interrupt-calibration to 800"

我正在尝试从 Apple Watch 3 (WatchOS 5.1) 获取 Core Motion 数据,但是尽管 DeviceMotion 可用(isDeviceMotionAvailable 属性 是 true),处理程序是从未触发。解析 super.willActivate():

后,我立即在控制台中收到以下消息

[Gyro] Manually set gyro-interrupt-calibration to 800

我正在使用以下函数获取 Device Motion 更新:

func startQueuedUpdates() {
    if motion.isDeviceMotionAvailable {
        self.motion.deviceMotionUpdateInterval = 1.0 / 100.0
        self.motion.showsDeviceMovementDisplay = true
        self.motion.startDeviceMotionUpdates(using: .xMagneticNorthZVertical, to: self.queue, withHandler:{
            (data, error) in
            // Make sure the data is valid before accessing it.
            if let validData = data {

                print(String(validData.userAcceleration.x))

            }
        })
    }
}

在我声明的InterfaceController中

let motion = CMMotionManager()
let queue : OperationQueue = OperationQueue.main

有没有人以前遇到过这条消息并设法解决了它?

注:isGyroAvailable属性我查过了,是false

此处的技巧是将 startDeviceMotionUpdates(using: CMAttitudeReferenceFrame 参数与您设备的功能相匹配。如果它没有磁力计,它就不能与磁北相关,即使它有磁力计,它也不能与真北相关,除非它知道你在哪里(即有纬度和经度)。如果它没有能力符合您的参数 select,将调用更新,但数据将是 nil.

如果您以最小 .xArbitraryZVertical 启动它,您 从加速度计获得更新,但您不会获得有意义的航向,只是一个相对的航向, 通过 CMDeviceMotion.attitude 属性 ...

if motion.isDeviceMotionAvailable {
    print("Motion available")
    print(motion.isGyroAvailable ? "Gyro available" : "Gyro NOT available")
    print(motion.isAccelerometerAvailable ? "Accel available" : "Accel NOT available")
    print(motion.isMagnetometerAvailable ? "Mag available" : "Mag NOT available")

    motion.deviceMotionUpdateInterval = 1.0 / 60.0
    motion.showsDeviceMovementDisplay = true
    motion.startDeviceMotionUpdates(using: .xArbitraryZVertical) // *******

    // Configure a timer to fetch the motion data.
    self.timer = Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { _ in
        if let data = self.motion.deviceMotion {
            print(data.attitude.yaw)
        }
    }
}