I was working on an dead reckoning script, despite hearing from just about everybody that the phone had too much noise/too low a frequency for sampling (Which turned out to be true, on my ipod touch 5th generation it drifts around 40cm per 5 seconds).
Code here
With the preset time constants, it should run on an iphone 4s/ ipod touch 5 directly. Each while loop takes approximately 0.08 seconds (you need 0.01 seconds to even start thinking about seeing the results real time). And to that end, I avoided using arrays/map/for loops/numpy.cos because my timing showed that it was slower than just setting var1=something, and using math.cos. Despite my best efforts, it cannot present accurate results. If people could check it for errors, that would be fabulous, and maybe a solution using pickle, and later analysis would work. Coded mostly in pycharm on the desktop.
The numbers it returns is relative to your initial position according to this page(not the phones, assuming you are facing towards the short side of the phone)
Interesting observations:
Angle drift depended on how long the update has started, the longer, the less drift, that's why update is started and we wait 10 seconds.
Acceleration drift is dependent on phone position, that's why you need to "calibrate it".
Array creation is not worth it, if you're just using three numbers, also don't bother with numpy.
