1. Introduction
The aim of the Internet of Things is to trace a map of the real world, giving an electronic identity to physical objects and places [
1]. This enables the inter-connectivity of devices: The objects gain new and powerful capabilities by sharing data with each other. In this scenario, the position of the connected objects is often an essential piece of information for effective representation of the real world. Without a central co-ordinator, every device should autonomously trace its own movements. A low-cost and accessible method relies on the use of an embedded accelerometer.
An accelerometer measures the proper acceleration of an object [
2]. The proper acceleration is relative to an inertial stationary observer; for example, the gravity acting upon the inertial observer is not considered in the proper acceleration. For this reason, an accelerometer in free-fall will measure zero, whereas an accelerometer at rest will measure an acceleration of 1 g due to the Earth’s gravity. Internally, the accelerometer can be considered as a damped mass on a spring. The deformation of the spring gives a measurement of the acceleration: In a resistive or capacitive accelerometer, the deformation is converted into a change of the impedance, whereas, in a piezo-electric accelerometer, it is expressed as an electrical signal.
The motion and displacement (i.e., change of position) of an object can be analyzed by measuring its acceleration. In fact, the acceleration can reveal the intensity and the frequency of the movement, as it is proportional to the external force applied to the object [
3]. Basically, integration (with respect to time) of the values provided by the accelerometer gives information about the speed and displacement of the object. In addition, information about inclination can be retrieved, such as the orientation and tilt of an object rotating on a reference plane [
4]. Furthermore, wearable devices commonly exploit accelerometers to evaluate human actions in vehicle control [
5], clinical and lab environments [
6], and in a free-living context [
7]. The first example of using an accelerometer to analyze human motion was presented in the 1950s [
8]. This trend was accelerated by technological improvements in the 1970s [
9]; thanks to micro-electro-mechanical systems (MEMS), sensor performance was notably increased while both cost overhead and power requirements were significantly reduced. In 1979, the first MEMS accelerometers were batch-fabricated [
10] and commonly integrated into wearable objects for the analysis of human activity and movements, both for research and commercial purposes [
7,
11]. The size and cost of accelerometers have continued to decrease, due to further advances in integrated MEMS, without compromising quality and reliability standards [
12].
This paper investigates movement tracking by means of a single accelerometer. In particular, the goal is computation of the displacement based on the data collected by a three-axis linear accelerometer. Typically, the displacement is estimated by a double integration of the acceleration data. First, the speed is computed by integrating the acceleration, following which the displacement is retrieved by integrating the speed. However, measurements are affected by errors and noise, which dramatically reduces the precision of the results. This paper analyzes a countermeasure for this issue, based on the Kalman filter [
13,
14]. The Kalman filter is commonly exploited in dynamic systems, in order to make estimations based on uncertain information. This paper extends a preliminary analysis [
15] by comparing the performance of two different accelerometers and by evaluating the overhead introduced by the Kalman filter. The main goal of this paper is to evaluate the benefits of the application of the Kalman filter. Different experiments were made, studying movements with one, two, and three degrees of freedom. The collected statistics reveal that the technique based on the Kalman filter produces more accurate results, with a reduction of the estimation error ranging between 18–72%. Moreover, although the Kalman filter requires additional computation time with respect to the integration of the acceleration values, the overhead can be assumed to be negligible.
The remainder of the paper is organized as follows. The related works for estimating a displacement according to the values produced by an accelerometer are reviewed in
Section 2. The Kalman filter and the approach to exploit it for estimating the displacement are described in
Section 3.
Section 4 describes the methodology followed to evaluate the accuracy of the developed approach. The experimental analysis is provided in
Section 5.
Section 6 investigates the overhead due to the proposed approach. Finally, some conclusions are drawn in
Section 7.
2. Related Work
A common approach for retrieving position information is by integration of the signal acquired from an accelerometer [
16]. However, this method is reliable only without strict requirements about the result precision, as the input data usually contain noise and measurement errors that need to be properly managed. The correction techniques proposed in the literature are targeted to the specific application scenario.
Human movement can be tracked by means of inertial and magnetic sensors on body parts, such as limbs and feet [
17]. Cyclic phases can be frequently detected in various kinds of human actions, such as walking, running, and side-steping. For instance, walking is composed of an alternation of stance and swing phases. In some periodic moments, the instantaneous value of the speed may be zero (e.g., between the stance and the swing phases, when both feet touch the ground). Recognizing these events may increase the accuracy of the results. In these cases, if the result of integration of the acceleration is not null, as expected, the error of the drift in the measurements can help to correct the accelerometer results, by providing consistent speed data. Consequently, better data on human movement can be provided; for example, the average error measured by tests on indoor walking has been recorded to be 5.5% [
17].
In automotive engineering, displacement is commonly estimated by means of inertial-based measurement techniques [
18]. In fact, due to their small dimensions, accelerometers can be used in a vehicle. Furthermore, information about the structural integrity of the vehicle can be obtained by studying the accelerometer data: For an elastic structure, the stress responsible for structural damage is proportional to the displacement. Finally, vibrations can be properly detected by the wide frequency and dynamic range of acceleration. Three digital filtering approaches have been designed to reduce the integration errors in low-frequency random acceleration data related to on-road vibration patterns and vehicle movements. Filtering approaches exploit the response of the finite and the infinite impulses with the inverse of the fast Fourier transform [
18]. With their adoption, the standard error in the displacement estimation has been shown to range from 5.7% at 20 Hz to 21.5% at 150 Hz [
18].
An off-line analysis of the displacement which uses the acceleration measurements has been provided for damage detection in structural health monitoring [
19]. A variation of the Kalman filter has been applied to limit the increase in noise due to the integration of the acceleration values. In particular, the condition at a specific point is estimated off-line by knowing the entire sequence of measurements. Kalman filter smoothing is introduced by analyzing a Kalman filter applied to all the samples, backward and forward. A multi-rate Kalman filter should be applied, due to the different sampling frequencies used in civil engineering applications. The displacement error is affected by the acceleration values (e.g., considering a swept-sine signal, the root mean square error is equal to 2.5% [
19]).
An alternative approach to computing the displacement is realized through conversion of the acceleration values to the frequency domain [
20,
21]. Given a discrete series of acceleration samples
, the discrete Fourier transform is applied for the conversion. The discrete Fourier transform
of an acceleration sample
is:
with
i corresponding to the imaginary unit. The discrete Fourier transform
of the
kth displacement is immediate, due to the property of the Fourier transform of the integrals:
It is possible to take the inverse Fourier transform of the coefficients of (
2) in order to obtain the discrete series of the displacement:
The scale factor of the error involved in (
3) is
. Consequently, when the frequency is doubled, the displacement is reduced by 6 dB. Thus, the components of the dominant signal may be lower than those at low-frequency noise during conversion. Low-frequency components should be zero padded, in order to be attenuated, with the exception of the significant sinusoidal components within the Fourier transform of the acceleration signal [
20]. A better technique has been proposed, based on the significant frequency components of the Fourier transform of acceleration values before applying inverse-Fourier transform [
21]. A curve-fitting correction on the local maximum points of the discrete Fourier transform can be applied to execute this operation. Curve-fitting corresponds to the finding which coefficients of a function better match a series of points.
Not only the error in the integration of the acceleration values, but also the drift and other noise effects, as well as double integration of thermal noise, affect the estimation of the displacement [
22,
23]. This effect can be checked with a fixed accelerometer: A long integration time increases the root mean square value, which is even affected by the sampling frequency. Initial calibration of an accelerometer can exploit the theoretical model of the described error, taking into account both analytical [
22] and numerical [
23] integration.
3. Theoretical Approach
The speed of an object at time
T can be obtained by integrating the acceleration over time, if its initial speed is zero. The speed can be computed as a summation of samples at discrete instants
:
The end of (
4) reveals that the speed corresponds to the sum of the area below the acceleration curve in the Cartesian plane. Algorithm 1 follows this approach to estimate the speed of an object. The input is the acceleration along an axis, obtained by querying the accelerometer with the acceleration.getx() pseudo-command, and the output is the value of the speed along the same axis. Algorithm 1 is repeated as many times as the degrees of freedom of the movement; for example, the speed of an object moving in three-dimensional space is obtained by three iterations of the algorithm. The variables
,
, and
all start at zero. Spurious data produced by the accelerometer are discarded after comparison with admissible values. The threshold for determining an acceptable value is different for all the axes and is related to the values of acceleration; for example, the threshold applied to z-axis is greater than that applied to the other axes, as it also includes the gravitational force.
Algorithm 1 Computation of speed along the x-axis. |
- 1:
- 2:
- 3:
acceleration.getx() - 4:
if then - 5:
- 6:
end if - 7:
if then - 8:
- 9:
end if - 10:
|
By definition, speed is the distance covered per unit of time. Algorithm 2 approximates the integral of the speed by a summation:
A significant difference between the value computed in (
5) and the real displacement can occur, due to noise and measurement errors. This gap can be limited by means of a Kalman filter [
13], which statistically minimizes the estimation error. The acquisition of a new measurement does not require that any previous data are processed again. During the data-processing flow of the algorithm, input data (i.e., discrete-time measurement samples) are first acquired, then they are processed, and finally new output data are produced.
Algorithm 2 Computation of displacement along the x-axis. |
- 1:
- 2:
call Algorithm 1 - 3:
- 4:
|
The Kalman filter evaluates the system model, row data, and data uncertainty [
14]. The system model can be described by a linear stochastic difference equation
where
represents the state of the system at time
k,
A is an
n ×
n matrix that indicates how the system evolves to the next step without any process noise,
is the optional control input,
B is an
n ×
l matrix that represents the control-input model applied to
, and
is the process noise. At the instant
k, a measurement
of the true state
is made, according to
where
H is an
m ×
n matrix that links the true state
to the observed state
;
is the measurement noise, which is considered to be white and Gaussian (i.e., not correlated in time and with probability density equal to the normal distribution); and
Q and
R are the matrices of covariance of the process and measurement noise. In a covariance matrix, the element (
i,
j) corresponds to the covariance between the
ith and
jth elements of the source vector. In other words, a covariance matrix reports the covariance between any two elements of the vectors.
The a priori state estimate at time
k is defined as the estimation obtained by relying only the process before time
k. It is indicated as
. On the contrary, the a posteriori state estimate at time
k exploits also the knowledge of the measurement
to estimate the state. It is indicated as
. The a priori and a posteriori estimate errors are
and the a priori and a posteriori estimate error covariance matrices are:
The Kalman filter estimates the process with a feedback control. In the predict phase, the process at time
k is estimated without knowledge of
. Then, in the update phase the estimation is refined by including knowledge of
. The a priori estimations of the state and the error covariance matrix are computed in the predict phase, as follows
The feedback control is implemented in the update phase by the sum of the new measurement with the a priori estimate, in order to obtain a better a posteriori estimate:
where
K, which is the Kalman gain, is a
n ×
m matrix that minimizes the a posteriori error covariance:
Algorithm 3 shows an implementation of the Kalman filter for computation of the speed on the x-axis. Every iteration of the algorithm computes the a priori and a posteriori estimates of the speed at the current time. In particular, the a priori estimate of the speed is based on the a posteriori estimate from the previous iteration. In more detail, the a priori estimate is computed in the predict phase by multiplying the previous a posteriori estimate by a constant A, because there are no control inputs. In a similar way, the a priori estimate of the error covariance uses the a posteriori estimate of the error covariance from the previous iteration of the algorithm. The a priori estimate of the error covariance is applied in the update phase for the computation of the Kalman gain. The speed value used in this phase is the last value computed by Algorithm 1. Finally, the a posteriori estimate of the speed and error covariance are updated, as they are needed for the subsequent iteration.
Algorithm 3 Use of the Kalman filter to compute speed along the x-axis. |
- 1:
- 2:
- 3:
- 4:
- 5:
- 6:
|
Algorithm 4, which computes the displacement on the x-axis, is similar to Algorithm 3. Both algorithms are executed three times, in order to compute speed and displacement along each of the three axes.
Algorithm 4 Use of the Kalman filter to compute displacement along the x-axis. |
- 1:
- 2:
- 3:
- 4:
- 5:
- 6:
|
4. Evaluation Scenario
The method developed in
Section 3 for the computation of the displacement was evaluated with two accelerometers produced by ST Microelectronics: LIS344ALH [
24] and LIS331DLH [
25]. The IC interface of the accelerometers acquires information from the sensing element and provides an output signal. Suspended silicon structures inside the sensing element are able to move along the direction of the sensed acceleration. Therefore, when an acceleration is applied, the proof mass changes, which generates an imbalance in the capacitive circuit. A charge integration can measure the imbalance by applying a voltage pulse to the sense capacitor.
The LIS344ALH is the accelerometer available in the Waspmote, an Arduino-based wireless sensor platform commercialized by Libelium [
26] and shown in
Figure 1. It is a ultra compact, low-power, analog output three-axis linear accelerometer. The user can dynamically select the acceleration full scale, choosing between ±2 g and ±6 g. The maximum bandwidth of the measured acceleration is 1.8 kHz. The IC interface processes the signal acquired from the sensing element by means of a low-noise capacitive amplifier and three different sample and hold circuits. The analog signal provided by the IC interface is an offset voltage, which is ratiometric to the voltage supply V
; the offset increases or decreases linearly, according to the change of the voltage supply. Furthermore, the sensitivity, which indicates the gain of the sensor, is ratiometric to the voltage supply. The sensitivity is obtained by performing one measure and by repeating the same measurement when 1 g is applied to the sensor. This can be easily obtained by pointing the sensor towards the center of the Earth, and then repeating the measurement with the sensor rotated by 180 degrees, in order to add the gravitational force. The mean of the two output values provided by the sensor gives its sensitivity. With V
= 3.3 V, the sensitivity of the LIS344ALH ranges between V
/5 and V
/15 V/g and its change, according to the temperature, is
C.
The LIS331DLH is the accelerometer embedded in the iPhone 4S smartphone. The LIS331DLH is a nano, low-power, digital output three-axis linear accelerometer, in which the three full scales of ±2 g, ±4 g, and ±8 g are available. The output data rate is between 0.5 Hz to 1 kHz. The technology of the sensing element is the same as the LIS344ALH accelerometer. The IC interface exploits a low-noise capacitive amplifier to generate an analog voltage, following which an analog-to-digital converter provides a discrete-time signal. The output data can be easily accessed by means of a IC/SPI serial interface. The typical voltage supply is V = 2.5 V. The analog-to-digital converter uses a 12 bit representation; the sensitivity ranges between 0.9–4.3 m g/digit and its change, according to the temperature, is C.
For the experiment with the LIS344ALH accelerometer, a program developed in C for Arduino was compiled and uploaded to the Waspmote. The program acquires data from the accelerometer and computes the displacement, according to two algorithms: The basic double integration of the input data and the application of the Kalman filter to the input data. A similar application was developed with the Swift programming language for iOS and uploaded onto the iPhone 4S, in order to repeat the experiment with the LIS331DLH accelerometer. Motion data were received from the device hardware and processed by means of the Core Motion framework.
In every experiment, the distance between an initial and a final point was first evaluated with a measuring tape. Then, both devices were moved along a straight path between the two points. The initial speed of each of the accelerometers was zero, and their speed was randomly changed during the movement. Three kinds of paths were considered, with one, two, and three degrees of freedom. In the first case, the x-axis of the accelerometer was aligned with the straight line followed by the device. In the second case, the device moved over a desk, which coincided with the xy-plane of the accelerometer. In the third case, the device freely moved in the space and the accelerometer recorded data along all three axes.
Three reference distances were considered in the experiments: 50, 70, and 100 cm. The devices covered every distance N = 3 times. Each estimation of the displacement d was recorded and the following statistics were computed:
The mean
e gives a measure of central tendency:
The range R indicates how widely spread the estimations are:
The uncertainty in a measurement
suggests the precision of the estimations. If a lot of data are available, the uncertainty coincides with the standard deviation:
According to (
15), the majority of the data lies in the range
. With a small number of data, the uncertainty can be computed as:
According to (
16), the displacement ranges in the interval between
and
. As each experiment was repeated only three times, the uncertainty in a measurement was computed as in (
16).
The uncertainty in the mean
indicates how far the displacement is from the average value of the estimations:
Substituting (
16) into (
17), if few data are available, the uncertainty in the mean can be computed as:
The mean absolute percentage error
expresses the discrepancy between the displacement and the estimations:
All statistics were computed both for the estimation based on integration of the acceleration data and for the estimation based on the Kalman filter. Finally, in order to quantify the benefits introduced by the Kalman filter, the percentage decrease of the MAPE was computed, as follows:
5. Experimental Results
Table 1 and
Table 2 present the statistics of the experiment with one degree of freedom, when the acceleration data were recorded with the Waspmote and the smartphone, respectively. The estimation was usually higher than the real displacement: This can be noted by observing that the mean value of the estimation was always higher than the distance covered by the device. However, some instances of the experiment provided an output value lower than the real displacement. This can be easily detected by checking the range of the estimations. For example, the range of the values computed with a double integration of the data obtained from the Waspmote was always higher than the displacement; this means that the maximum estimation was higher than the displacement, but the minimum one was lower. On the contrary, a narrow range indicates that the single estimations were closer to the mean value. For example, this happened in the trials with 50 and 70 cm, both with the Waspmote and the smartphone. In these cases, all estimations were higher than the path covered, as their average value was higher, but not by too much, since their range was tight. A correction can be easily applied to reach a better estimation; for example, by applying a reductive factor to the mean value or by giving more weight to the minimum estimation. By comparing the mean absolute percentage errors, it can be noted that the use of the Kalman filter decreased the percentage error in the estimation at least by 50%. However, only the accelerometer of the Waspmote allowed for precise results, with an acceptable error.
Data concerning the movement with two degrees of freedom is listed in
Table 3 and
Table 4 for the Waspmote and the smartphone, respectively. Similarly to the previous set of trials, the average estimation was always higher than the real distance covered by the device. It can be noted that the average value obtained with a double integration of the acceleration data could not predict the displacement. In fact, even if the average value was decreased by the uncertainty in the mean, the result was still higher than the real displacement. By applying the Kalman filter, the uncertainty in the mean was lower; which means that the estimations were closer to each other. At the same time, the estimations based on the data collected with the accelerometer embedded in the Waspmote were closer to the real distance, so a satisfactory match can be obtained by correcting the average value with the uncertainty in the mean. The only exception, according to
Table 3, occurs when the path covered was 70 cm. In contrast, relying on the mean and on its uncertainty was not enough if the Kalman filter was used with the data obtained from the smartphone. However, the use of the Kalman filter is always suggested, as it reduced the percentage error of the estimation in every case.
The data shown in
Table 5 and
Table 6, about the movement with three degrees of freedom with the Waspmote and smartphone, respectively, confirm the general trend of the previous experiments. Notably, the estimations were always higher than the measured displacement. However, the Kalman filter reduced the gap between the average value of the estimation and the displacement, both with the Waspmote and the smartphone. Similarly, the percentage error of the single estimation always decreased by applying the Kalman filter to the acceleration data. The accelerometer embedded in the smartphone provided results almost precise as those obtained from the accelerometer of the Waspmote, independently of the use of the Kalman filter.