3

I'm concepting an iPhone app that will require precise calibration to the iPhones accelerometer and gyro data. I will have to simulate specific movements that I would eventually like to execute code. (Think shake-to-shuffle, or undo).

Is there a good way of doing this already? or something you can come up with? Perhaps some way to generate a time/value graph of the movement data as it is being captured?

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
Hippocrates
  • 2,510
  • 1
  • 19
  • 35

2 Answers2

1

Movement data being captured - see the accelerometer graph sample app, which shows the data in real time: http://developer.apple.com/library/ios/#samplecode/AccelerometerGraph/Introduction/Intro.html

The data is pretty noisy - the gyro and accelerometer aren't good enough right now to be able to track where the phone is in local 3d space, for example. The rotation, however, is very solid, and the orientation of the device can be pretty accurately tracked. You may have the best results making gestures out of rotation data instead of movement along an axis. Or, basic direction like shakes along an axis will work as Jacob Jennings said.

ericn
  • 173
  • 5
0

A good starting point for accelerometer gesture recognition is this tutorial by Kevin Bomberry at AblePear: http://blog.ablepear.com/2010/02/iphone-sdk-shake-rattle-roll.html

He sets a blanket threshold for the absolute value of acceleration on any axis. I would generate an 'event' for the axis that had the highest acceleration during the break of the threshold (Z POSITIVE, X NEGATIVE, etc), and push these on an 'event history' queue. At the end of each didAccelerate call, evaluate the queue for patterns that match a gesture, for example: X POSITIVE, X NEGATIVE, X POSITIVE, X NEGATIVE might be considered a 'shake' along that axis. This should provide a couple different gesture commands.

See the following for a simple queue category addition to NSMutableArray: How do I make and use a Queue in Objective-C?

Community
  • 1
  • 1
Jacob Jennings
  • 2,796
  • 1
  • 24
  • 26