I'm using the accelerometer in iPhone to get some motion data, but the frequency seems not corresponding to what I set in the code.
motionManager.accelerometerUpdateInterval = accelInterval
motionManager.startAccelerometerUpdatesToQueue(NSOperationQueue.currentQueue(), withHandler: {(accelerometerData: CMAccelerometerData!, error:NSError!)in
self.outputAccelerationData(accelerometerData.acceleration)
and here is how I check the real frequency
func outputAccelerationData(accel:CMAcceleration){
var timePoint: String {
get {
return "\(NSDate().timeIntervalSince1970)"
}
}
timePoints.addObject(timePoint)
println(timePoint) }
When I set ´accelInterval´ to be 1/5 or 1/10, the timePoint matches -- 5 or 10 data per second. But when I set it to be 1/20 or 1/40, the timePoint turned out to be 12 or 24 data per second.
But it was not the end. I tried accelInterval as 1/30, it became 33 time point data per second; I tried 1/25, it matched to be 25 time point per second!
Can anyone help me to illustrate a bit more on this issue? I couldn't find the norm for the real update interval! Thanks!
0 comments:
Post a Comment