Obtaining accurate displacement/position change from iPhone accelerometer - iphone

I'm currently trying to implement an augmented reality iphone application (ios 4.2) that uses accelerometer data to translate and rotate an OpenGl object on the screen. I have already succeeded in getting the object to respond to the phones rotation, but this was always going to be the easy part.
For the translational part, I have I've tried implementing some of the techniques from this paper (http://www.freescale.com/files/sensors/doc/app_note/AN3397.pdf)
but it's still not very accurate. I'm in the process of implementing a kalman filter to filter the accelerometer data.
Has anyone had any luck in determining phone translational movement? If so, how accurate did you get it, and what techniques did you use to obtain this accuracy?

Related

Detecting the user's spinning motion

I have been experimenting with the Core Motion framework to detect a user spinning around, say on a merry-go-round, holding an iphone in his hand.
There are ways to detect the device motion around its own axes, but what is a good way to detect the iPhone spinning in circles?
Thanks
You can use the gyroscope. Take a look here: Gyroscope example
You have to remind that it is only availble on iPhone4 and iPhone4S.
There is one degenerate case where you can run into trouble, only magnetometer (compass) can help in that particular case.
If you put the device (a) on the desk in stationary position then (b) on a perfectly horizontal turntable rotating slowly you will get the same qualitative sensor readings. Both the gyro and the accelerometer readings are constant in the two cases, although the readings quantitatively differ. The sad part is: gyro bias error can render case (a) to look like (b) and vice-versa. In this particular case you need a compass to cancel the gyro drift. Case (a) is typical for a phone.
Apart from this degenerate case, gyroscopes and accelerometers with sensor fusion are sufficient to track arbitrary rotations of the device.

accelerometers uses- smartphone

It is known that the raw accelerometer data is combination of both linear acceleration and gravity. In order to isolate them w need to apply appropriate filters. I would like to know the real time applications where we would need only "gravity" or only "linear acceleration".
Gravity is used when you are trying to figure out the orientation of the phone. In other words, when you are trying to figure out how the user holds the phone. It is good for tilt games, for example you use the phone to drive a car, etc.
Linear acceleration is used when you are trying to figure out how the phone is shaken. It good for shaking games.
I highly recommend this video. In particular, between 4:15-6:10 and staring from 33:30 you see demos.

Augmented Reality sample code using Gyroscope

Morning,
I have hunted around StackOverFlow for about an hour and found lots of sample code (mainly github) for creating Augmented Reality apps that display where a 2nd location is relative to your current location (e.g. New York).
However, I noticed that none of these are using the Gyroscope functionality provided in the iPhone 4 that gives a far smoother experience to the end users.
Does anyone know if such an example of sample code exists?
Cheers,
Charlie
You can definitely use CoreMotion to get data from the gyro. The basic approach would be to get CMAttitude.rotationMatrix and multiply its inverse (transpose) by a reference matrix which you initially set. The Teapot sample project on developer.apple.com shows the basic approach of working with CoreMotion.
For a true augmented reality app you will need to create a model using OpenGL ES. I personally found v1.1 to be more reliable on iOS, after having tried GL ES 2.0. The Teapot sample also uses GLES 1.1.
Using the gyro is much more accurate and "smooth" than using the Magneotmeter for getting the device's rotation around its reference axis. The trick is how to initially calibrate the reference matrix in order to get the true "heading" of the device and to place your GL ES model objects in the correct position around the camera. After you have achieved that you can rotate your model in 3D by multiplying of GL's viewMatrix with the inverse of the CMAttitude.rotationMatrix.
Lastly, if you intend to support iPhone 3Gs as well then don't forget to check gyroAvailable property of CMMotionManager and provide an alternative implementation using the magnetometer.
You can try using CMMotionManager instance methods
startDeviceMotionUpdatesToQueue:withHandler: or startGyroUpdatesToQueue:withHandler:
[CMMotionManagerObject startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue] withHandler:^ (CMDeviceMotion *devMotion, NSError *error)
{
CMAttitude *currentAttitude = devMotion.attitude;
xRotation = currentAttitude.roll*180/M_PI;
yRotation = currentAttitude.pitch*180/M_PI;
zRotation = currentAttitude.yaw*180/M_PI;
}];
If you use startGyroUpdatesToQueue:withHandler: you can get the result through the property gyroData
I don't know of any code sample, unfortunately.
A problem common to all AR apps is that you need to find out the orientation of your device. You can do that with atan2 and the accelerometer, but it has an unholy amount of noise (as seen in Apple's AccelerometerGraph sample project). If you try to fix it with an adaptive low pass filter you reduce the noise but you also make it less responsive.
The gyro doesn't have noise but error accumulates fast enough that you have to constantly reset the position using the accelerometer. It seems good to rotate an object, but not to replace the compass.

iPhone - detecting motion with gyroscope/accelerometer

I'm trying to detect a swinging motion with an iPhone 4 using the gyro/accelerometer. I searched for some posts on SO about this, but couldn't find anything specific to my issues.
Do I need to do any sort of calibration for data from the gyroscope/accelerometer?
Anyone think of how I would measure a swinging motion?
Thanks!
1: Most iPhone games using the accelerometer don't do any calibration, but not all iphones are the same; there is some variation in accelerometer calibration. You could add a manual or automatic calibration to your program. If however, detecting a swinging motion is all you want, calibration is not necessary.
2: Apple has a nice little app that generates graphs of accelerometer motions in the iPhone SDK. You can download and build that and see the measurements for the motion you want. Then you can write code to detect similar accelerometer measurements.

6DOF using accelerometer and gyroscope

Has any one developed 6DOF pose estimation using only the iPhone sensors, not video? Drift from the accelerometer and gyroscope are understood.
The gyroscope provides fairly reliable relative orientation rates. I've been able to develop with the gyroscope data.
However, I'm having more problems deriving translation from the accelerometer. Double integration of the acceleration leads to useless position data very quickly (less than half a second).
I have attempted to remove the bias with a calibration step, but the position is still poor. What's worse, is the bias isn't constant. It changes over time, and the noise drowse the signal.
I'm interested if anyone has been able to develop a 6DOF with only the accelerometer and gyroscope that works reliably for 5-10 seconds with little drift in both translation and orientation.
The gyro yaw using DeviceMotion has a drift when you first start updating, try not to take those samples and everyone will be happy.
I made a post about this: Get orientation device in the iPhone for Opengl Es, I having the same issue, I´m just trying to make a filter but it´s not working good, there is a book about these http://www.amazon.com/iOS-Sensor-Programming-Augmented-Location/dp/1449382657, but I didn´t read this book.