1

I am trying to make a very simple Android pedometer, but so far it's failing pretty badly. I got some advice here and there on the internet, but nothing seems to be working.

I basically set an acceleration sensor and get the values of the x, y and z axis. After that I calculate their distance from the origin, which is basically: d = sqrt(x²+y²+z²) followed by the calculation of their moving average. My idea was whenever I find a local peak I should count as a step. The issue is, I have no idea how to find the local peak right away in order to count the step. I am sorry if this seems like a simple problem, but I really have no idea how to go on from here.

Thank you very much.

theJuls
  • 6,788
  • 14
  • 73
  • 160

1 Answers1

1

I tried to implement this and the approach you take is subject to substantial measurement errors. You should just accept it. The reasons are:

  • a phone can be in any location, not only the trousers' pocket
  • phone accelerators are not medically precise, and they can deviate and "flow" given exactly the same position in space
  • moving average is not the best known technique to do this, a better one would use some sort of waves and wavelet analysis
  • One step has two local maximums and two local minimums (if I remember correctly)
  • There is no strict definition of a "step" globally accepted, this is due to physiology, measurements and various techniques used in the research field

Now to your question:

  • Plot the signal from the three axis you have, this will dramatically help you (signal vs time)
  • Define a window of a fixed (or slightly moving) size, moving window is required to detect people who walk slower, run or have disability
  • Every time you have a new measurement (usual frequency is about 20-30 Hz), put one to the tail of the window (your signal measurement's queue) and pop one from the head. In this way you will always have a queue with the last N measurements
  • Again for every mesurements recalculate your stuff and decide if the window contains one (or two!) minimums and count it as a step

good luck!

oleksii
  • 35,458
  • 16
  • 93
  • 163
  • First of all thank you very much for your help, I am sorry, it may be stupid of me, but I don't quite understand... So basically I first plot the signal from all three axis and then do the calculations I described above? – theJuls Oct 21 '13 at 19:42
  • Well, plotting the signal will help you to see the data, merely for convenience. I dug out my answer [here](http://stackoverflow.com/a/11241452/706456), have a look around that question as well. To make it clear: calculations are independent from plotting. You plot it only once to understand the signal. Calculations are usually performed on a small segment of the signal, say on a 3 second interval. The segment is moving, i.e. when you get a newest accelerometers measurements, you first remove the oldest measurements from the segment, and add the recent one. Hence you always keep last 3 sec. – oleksii Oct 22 '13 at 09:55