无法使用 watchOS 5: "[Gyro] Manually set gyro-interrupt-calibration to 800"获取核心运动更新



我正在尝试从Apple Watch 3(WatchOS 5.1)获取核心运动数据,但是尽管可用DeviceMotion(isDeviceMotionAvailable属性为true),但从未触发处理程序。解析super.willActivate()后,我立即在控制台中收到以下消息:

[Gyro]手动将陀螺式互性校准设置为800

我正在使用以下功能获取设备运动更新:

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参数与设备的功能匹配。如果没有磁力计,它与磁性北部无法关联,即使它具有磁力计,除非知道您在哪里(即具有纬度&经度),否则它也无法与True North相关。如果它没有能力符合您选择的参数,则将调用更新,但数据将为nil

如果您使用最小.xArbitraryZVertical启动它,则您 Will 从加速度计获得更新,但是您不会通过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)
        }
    }
}

最新更新