Brendan McKenzie

Calculating Velocity on iPhone

Thursday, 12 April 2012

So after a hard drive crash and a memory upgrade my MacBook is back up and running with OS X Lion and Xcode installed.

While I'm working on other projects here and there, websites and other iPhone applications, I've given myself a task.

On the surface it sounds simple, but it's not.

I want to use only the gyroscope and accelerometer in my iPhone to determine its velocity.

I've already accepted that it's going to be difficult and include a fair bit of algebra and calculus; however, the main issue I will face is taking into consideration the rotation of the device.

I understand that the only velocity I can get from the phone is the velocity of the phone based on the initial velocity. Meaning that if I am sitting in a car travelling at 60km/h when I start calculating, the velocity will be 0km/h and when the car comes to a stop the calculated velocity will be -60km/h.

I'm sure there's more treasures to find and I'll add them here as I come across them.

Not that anyone reads this anyway...