Sébastien Ménigot

Doctor of Engineering in Signal Processing Applied to Ultrasound Imaging

Pedometer in HTML5

Pedometer in HTML5 for Firefox OS and Firefox for Android

Introduction

Nowadays,the connected devices are increasingly present. They are especially the "stars" of the latest Consumer Electronics Show 2014 (Las Vegas, NV, USA) . Among these devices, there is one who knows a revival: pedometer. For a long time, pedometer has established in hiking field. But it has suffered in comparison with geolocation which can offers greater simplicity (no setting) and greater accuracy in distance measurements. However, geolocation can be a complement to the pedometer since only the pedometer can measure the number of steps. With the accession of smartphones, all these measures can easily be performed with the same device. For example, there is a version for Android pedometer under GNU GPLv3 license [1].

However, it seems that the future of mobile technologies tends to turn to web technologies based on HTML5. Two projects of operating system arouse: Firefox OS developed by the Mozilla Foundation and Tizen developed by Linux Foundation. Note that web scripts can be added to programs in C++ through Qt Library. These factors led me to develop a pedometer in HTML5 under the GNU GPLv3 License.

The recent development of new functionality enables to get information from gyroscopes easily. The web browser will calculate the acceleration in three smartphone axes x, y and z. From these three signals, when a person has a smartphone in the pocket, the steps can be detected. This web application is based on measures of digital accelerometer [2].

axes of smartphone

Orientation and motion data explained
Author: Sheppy (Mozilla Contributor).
Creative Commons Attribution-ShareAlike license (CC-BY-SA)

The web application has been tested on a Geeksphone Peak (Madrid, Spain) with Firefox OS 1.3 Prerelase. Note that Firefox for Android, the web application works but no benchmark has been achieved in this platform.

Acceleration and Walking

The measurement principle is described in the block diagram given in the following figure.

Flowchart

When a person walks, the smartphone in his pocket undergoes accelerations and decelerations. A step corresponds to a pseudo-period of the signal with acceleration variations. Counting the number of steps is therefore to increment a counter for pseudo-period performed.

acceleration on 3 axes

The first step is to merge information of the three accelerations d²x/dt², d²y/dt² and d²z/dt². The other advantage of this operation is to eliminate the absence of information on the position in the pocket, because the acceleration during walking can not be predicted. The simplest fusion is to compute the norm of the vector acceleration:

eq norm

where t is the discrete time.

To improve the robustness of detection, the steps are not directly counted on the standard acceleration a(t). A denoising step is applied from a Kalman filter [3] by using the following equations.

eq kalman gain (Optimal Kalman gain)
eq Kalman (Updated acceleration estimated)
eq Kalman (Updated covariance estimated)

where P_t is the error covariance matrix, a_t the signal estimated at time t, H_t the matrix of the estimation model and R_t the covariance of the noise mesured. Note that all parameters are initialized at 1 at the beginning of the computation.

This filter could be applied before the norm calculation on each three accelerations d²x/dt², d²y/dt² and d²z/dt². However by applying the Kalman filter on the acceleration a(t), the computation cost can be reduced. In this case, the dimension of the matrix are therefore one. Finally, we hypothesized that the signal without noise is sinusoidal with a variance of 0.5. By measuring the variance of acceleration a(t), we can deduce the noise variation.

The detection is made ​​on this denoised signal. A step is then detected if the acceleration cut an adaptive threshold. This threshold corresponds to the average of the extreme ​​acceleration values on a window of 2 seconds. Several conditions are also added to reduce false positives. First, it is necessary that the difference between the extrema exceeds to the sensitivity. This sensitivity is the double of the noise variance normalized. Moreover, to count a single step per pseudo-period, a condition on the derivative is added: the detection is performed only when the acceleration exceeding the threshold falls below this threshold. Finally, to reduce the risk of detecting false quick step, the minimum time between two step detection has to be 200 ms (13.6 km/h).

Step detection

From these measurements, we deduce the instantaneous speed as an average speed on a window of 2 seconds. The calories burned are therefore computed [2]:

Web Interface

Main pageSetting pageMenu

The main page shows the step number, the distance walked, mean and instantaneous speed and calories burned. In the current version, the lock screen does not launch in Firefox OS. When this application is running, the lock screen is automatically locked.

From the menu, you can adjust the step size to determine the total distance traveled. We recommend counting your steps on a large known distance. The relationship between distance and the number of steps will give you the size of your steps. It is also possible to adjust the weight to calculate calories burned.

Finally you can also have a description of the application.

Conclusion

This first version of the pedometer works on my Geeksphone Peak. It demonstrates the capabilities of real-time processing signal for an HTML5 application.

Version Note

  • Version 1.0.3 : first public version. It can count step, speed and burned calories from accelerometers.
  • Version 2.0.1 : the distance walked and the instantaneous speed can be checked from the GPS data to increase the precision. However, it is just an option so that the pedometer can continue to run even when GPS reception is poor. This option is activated by default. To activate it, go to the parameter menu, check the option and return to the main page.
  • Version 2.1 : Add of a "pause" button" on the main page.

Links and Download

Confidentiality

The application does not require an internet connection. Your statistics is recorded on your smartphone. No data is transferred.

The application is free under the GNU GPL v3 License. Some javascript library are on MIT Licence and WTFPL Licence.

References

[1] Pedometer for Android : https://code.google.com/p/pedometer/

[2] Zhao, N. Full-featured pedometer design realized with 3-Axis digital accelerometer. Analog Dialogue, 2010, vol. 44, no 6, p. 1-5.

[3] Kalman, R. E. A New Approach to Linear Filtering and Prediction Problems. Journal of basic Engineering, 1960, vol 82 (Series D), no 1, p. 35-45.