0
我需要樣品3軸磁場,3軸加速度和3軸的旋轉速度,所以我使用DeviceMotion,這裏是我的代碼:爲什麼magneticField.field的值固定爲零?
if manager.deviceMotionAvailable {
if manager.magnetometerAvailable {
manager.magnetometerUpdateInterval=0.01
manager.deviceMotionUpdateInterval = 0.01
manager.startDeviceMotionUpdatesToQueue(NSOperationQueue.mainQueue(), withHandler: {(data: CMDeviceMotion?, error: NSError?) -> Void in
if(standard_time) {
let data = [
"ax":data!.userAcceleration.x,"ay":data!.userAcceleration.y,"az":data!.userAcceleration.z,
"gax":data!.gravity.x,"gay":data!.gravity.y,"gaz":data!.gravity.z,
"gx":data!.rotationRate.x,"gy":data!.rotationRate.y,"gz":data!.rotationRate.z,
"mmx":data!.magneticField.field.x,"mmy":data!.magneticField.field.y,"mmz":data!.magneticField.field.z,
"roll":data!.attitude.roll, "pitch":data!.attitude.pitch, "yaw":data!.attitude.yaw]
}
)}
}
}
然而,3-值無論我多麼努力地嘗試移動我的iphone,我得到的軸向磁場都固定爲零。你可以幫我嗎 ???
我需要3軸加速度和3軸的旋轉速度的同時,所以我不能使用startDeviceMotionUpdatesToQueue和startMagnetometerUpdatesToQueue因爲其採樣時間其different.In事實上,雖然我設置與deviceMotionUpdateInterval相同magnetometerUpdateInterval如果我使用startDeviceMotionUpdatesToQueue和startMagnetometerUpdatesToQueue,不僅是樣本時間不同,而且樣本編號爲 –