【问题标题】:Cannot get Core Motion Updates using watchOS 5: "[Gyro] Manually set gyro-interrupt-calibration to 800"无法使用 watchOS 5 获取核心运动更新:“[Gyro] Manually set gyro-interrupt-calibration to 800”
【发布时间】:2019-02-18 13:53:33
【问题描述】:

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

[Gyro]手动设置gyro-interrupt-calibration为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

【问题讨论】:

    标签: gyroscope core-motion watchos-5


    【解决方案1】:

    这里的技巧是将startDeviceMotionUpdates(using: CMAttitudeReferenceFrame 参数与您设备的功能相匹配。如果它没有磁力计,它就不能与磁北相关,即使它有磁力计,它也不能与真北相关,除非它知道你在哪里(即有纬度和经度)。如果它没有符合您选择的参数的能力,则会调用更新,但数据将是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)
            }
        }
    }
    

    【讨论】:

    • 抱歉回复晚了。它现在完美运行。我还将尝试使用带有磁力计的新 Apple Watch Series 5,看看它是否有所不同。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-04
    • 2018-10-06
    • 2022-08-08
    • 1970-01-01
    • 2013-07-02
    相关资源
    最近更新 更多