How it works

picture showing phone axes

Phone axes

  • The +Z axis comes out from the screen of the phone with the -Z axis coming out from the back

  • The +Y axis comes out from the top of the taller side of the phone with the -Y axis coming out from the bottom

  • The +X axis comes out from the right of the taller side of the phone with the -X axis coming out from the left

We assume that the phone is in the user's pocket facing downwards. Therefore we collected data from the Z-axis to get the most variation in accelerometer readings.

Recording DATA

The app collects accelerometer data from the user's phone as they move. This data is collected in 2048-point samples, with each point being taken 10 milliseconds apart. This allows the app to capture a detailed picture of the user's movement over time.

At the location of the star, the magnitude (y-axis) is the highest showing identifying it as the walking frequency (x-axis) of steps.

Applying the FFT

Once the accelerometer data has been collected, the app applies a fast Fourier transform (FFT) algorithm to convert the data into the frequency domain. This allows the app to determine the frequencies at which the user's movement is occurring.

Next, the app filters out frequencies below 0.2Hz, as these are likely to be caused by noise or other sources of vibration that are not related to the user's steps. The remaining frequencies are then analyzed to determine the one with the highest amplitude, which is assumed to be the user's step frequency.

Photo Credit: Jose A. Bernat Bacete, Getty Images

Converting to Stride Length

Once the step frequency has been determined, the app uses an equation that accounts for the user's gender and height to calculate their stride length. This equation uses average step lengths for males and females, which are determined based on height. For example, a male who is 6 feet tall (72 inches) would have an average stride length of approximately 2.5 feet, or 30 inches.

Finally, the app combines the stride length with the step frequency to calculate the user's pace in miles per hour. This is done by dividing the stride length by the time it takes to complete a single step, which is determined by the step frequency. For example, if the user has a stride length of 30 inches and a step frequency of 2 Hz (two steps per second), their pace would be 15 inches per second, or 0.13 mph.

Motion model

  • A motion model for a phone accelerometer in a person's pocket can be represented by a simple harmonic oscillator.

  • The degrees of freedom for the phone's motion are its three translational coordinates (x, y, and z) and three rotational coordinates (roll, pitch, and yaw). The time derivatives of these coordinates are the phone's linear and angular velocities, respectively. We only use data from the Z-axis, meaning that our motion model effectively has two degrees of freedom, the Z-axis and yaw, or rotation on the Z-axis.

  • An important frequency in this system is the frequency of the person's steps, which can be measured using the accelerometer. This frequency can be used to identify periods of walking versus periods of stationary or sedentary behavior.

  • The acceleration data is directly output by the phone's sensor therefore we do not require equations of motions to convert between position and acceleration.

CODE SAMPLE

This JavaScript code sample that was used in our real app uses the fft.js library for the FFT showcases the main steps in transforming acceleration data from the phone into a person's walking speed.