Question

I am trying to replicate the acceleration calculation like the application "Dynolicious" but I'm not sure where to head to calculate this. Do I use Core Motion or do I do calculations using other numbers?

I have tried using Core Motion's userAcceleraion value, but it is not coming out at all like what I'm looking for.

coreMotion = [[CMMotionManager alloc]init];
[coreMotion startDeviceMotionUpdates];

//then every second it updates my label...

NSString *accel = [NSString stringWithFormat:@"%f", [[coreMotion accelerometerData]acceleration].x];
accelerationLabel.text = accel;

i.e. I want my values to come out like 0.4, -0.4, etc.

Était-ce utile?

La solution

You might want to consider low pass filtering (shown in this SO post), which is actually an Apple guideline (see the Isolating the Gravity Component from Acceleration Data of the Event Handling Programming Guide)

If you are using the accelerometer data to detect the current orientation of a device, you need to be able to filter out the portion of the acceleration data caused by gravity from the portion of the data that is caused by motion of the device. To do this, you can use a low-pass filter to reduce the influence of sudden changes on the accelerometer data. The resulting filtered values then reflect the more constant effects of gravity.

You can also look at the "Isolating Instantaneous Motion from Acceleration Data" section

If you are using accelerometer data to detect just the instant motion of a device, you need to be able to isolate sudden changes in movement from the constant effect of gravity. You can do that with a high-pass filter.

It goes on to give a simple implementation to accomplish this.

Autres conseils

Apple's got some good documentation up about gathering accelleration information at http://developer.apple.com/library/ios/#documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/MotionEvents/MotionEvents.html

Looks like you need to setup the accelerometer and then use delegate methods to read the data.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top