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
-
does this happen to users alot: spinning around quickly in short circles? – Mitch Wheat Oct 28 '11 at 10:34
-
2not my business, my concern is to tackle this programming problem – Shyam Bhat Oct 28 '11 at 10:50
-
You need to use the gyro for this. – Moshe Oct 28 '11 at 13:30
-
Why would you want that out of curiosity? – Paul C Oct 28 '11 at 15:06
-
shyam: I've never been a fan of the "just following orders" approach... – Mitch Wheat Oct 29 '11 at 00:15
2 Answers
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.

- 56,466
- 29
- 168
- 265