Post

Replies

Boosts

Views

Activity

Reply to Gyroscope and Magnometer Data on Apple Watch
Actually, I fixed it!    let motionManagerDelegate = CMMotionManager()   var sensorDataDelegate=[Double]()      print("sensor function starts==============================",currentTime)           if self.motionManagerDelegate.isDeviceMotionAvailable {       if !self.motionManagerDelegate.isDeviceMotionActive{         self.motionManagerDelegate.deviceMotionUpdateInterval = 30 / 60.0         self.motionManagerDelegate.showsDeviceMovementDisplay = true       }         self.motionManagerDelegate.startDeviceMotionUpdates(using: .xMagneticNorthZVertical, to: OperationQueue.current!, withHandler: { (data, error) in           if let validData = data {             let rX = validData.rotationRate.x             let rY = validData.rotationRate.y             let rZ = validData.rotationRate.z             let timeStamp=validData.timestamp             if self.offsetTimeFlag{ //              let currentTime=Date().timeIntervalSince1970 //              self.offsetTime=currentTime-timeStamp               self.offsetTime = 0.0-timeStamp               self.offsetTimeFlag=false             }             self.sensorDataDelegate.append(contentsOf: [timeStamp+self.offsetTime])           }         })     }     else {       fatalError("The motion data is not avaialable")     }
Aug ’21