Reputation: 35953
I am trying to grab the device acceleration using CoreMotion. I have this code:
for setting
if (motionManager == nil)
motionManager = [[CMMotionManager alloc] init];
motionManager.deviceMotionUpdateInterval = framesPorKeyframes / 60.0; //60 Hz
motionManager.accelerometerUpdateInterval = framesPorKeyframes / 60.0; //60 Hz
[motionManager startDeviceMotionUpdates];
referenceAttitude = nil;
for reading
vec3f_t translation = {0.0f, 0.0f, 0.0f};
CMRotationMatrix rotation;
CMAcceleration userAcceleration;
CMDeviceMotion *deviceMotion = motionManager.deviceMotion;
attitude = deviceMotion.attitude;
rotation = attitude.rotationMatrix;
userAcceleration = deviceMotion.userAcceleration;
[userAccelerationLpf addAcceleration:userAcceleration withTimestamp:deviceMotion.timestamp];
// The user acceleration we want to use is the one computed by userAccelerationLpf
userAcceleration.x = userAccelerationLpf.x;
userAcceleration.y = userAccelerationLpf.y;
userAcceleration.z = userAccelerationLpf.z;
NSLog(@"acc = %f, %f, %f", userAcceleration.x, userAcceleration.y, userAcceleration.z);
All I have here are zeros!!!!!!!!
The reading method repeats at 30 Hz.
this is taken from Apple sample and should not be giving me zeros! any clues?
thanks.
Upvotes: 2
Views: 1067
Reputation: 4985
What do you see if you drop the low-pass filter and just log the raw acceleration? (I bet I know the answer :)
Upvotes: 3