# A Study about Kalman Filters Applied to Embedded Sensors

^{1}

^{2}

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Technical Background

#### 2.1. Modeling the System

- an input vector $\mathbf{U}$, containing all the system known inputs;
- a state vector $\mathbf{X}$, containing the system internal state, which will evolve depending on the inputs;
- an output vector $\mathbf{Y}$, containing the system outputs/measurement;
- an evolution Equation (1), describing the evolution of the internal state of the system, depending on the previous state and the command input vector; and
- a measurement Equation (2), describing the measurements at the output of the system depending on its state and its command input.$${\mathbf{X}}_{k+1}=f({\mathbf{X}}_{k},{\mathbf{U}}_{k})$$$${\mathbf{Y}}_{k}=h({\mathbf{X}}_{k},{\mathbf{U}}_{k})$$

#### 2.2. Kalman Filters

#### 2.2.1. The Extended Kalman Filter

#### 2.2.2. The Unscented Kalman Filter

#### The Unscented Transform

#### System Evolution

- Generate a weighted point set for the following state estimation.$${\mathcal{X}}_{k}=\left(\right)open="["\; close="]">{\widehat{\mathbf{X}}}_{k},{\widehat{\mathbf{X}}}_{k}+\sqrt{(n+\lambda )[{\widehat{\mathbf{P}}}_{k}]},{\widehat{\mathbf{X}}}_{k}-\sqrt{(n+\lambda )[{\widehat{\mathbf{P}}}_{k}]}$$
- Propagate the state through the evolution function$${\tilde{\mathcal{X}}}_{k+1}^{\left(i\right)}=f({\mathcal{X}}_{k}^{\left(i\right)},{\mathbf{U}}_{k},0),i\in [0,2n]$$
- Compute the projection statistics using the Unscented method$$\begin{array}{cc}\hfill {\tilde{\mathbf{X}}}_{k+1}& =\sum _{i=0}^{2n}{\omega}_{i}^{\mu}{\tilde{\mathcal{X}}}_{k+1}^{\left(i\right)}\hfill \end{array}$$$$\begin{array}{cc}\hfill [{\tilde{\mathbf{P}}}_{k+1}]& =\sum _{i=0}^{2n}{\omega}_{i}^{c}({\tilde{\mathcal{X}}}_{k+1}^{\left(i\right)}-{\tilde{\mathbf{X}}}_{k+1}){({\tilde{\mathcal{X}}}_{k+1}^{\left(i\right)}-{\tilde{\mathbf{X}}}_{k+1})}^{T}+\left[\mathbf{Q}\right]\hfill \end{array}$$

#### Measurements Projection

- Generate a weighted point set from the estimated state$${\tilde{\mathcal{X}}}_{k+1}=\left(\right)open="["\; close="]">{\tilde{\mathbf{X}}}_{k+1},{\tilde{\mathbf{X}}}_{k+1}+\sqrt{(n+\lambda )[{\tilde{\mathbf{P}}}_{k+1}]},{\tilde{\mathbf{X}}}_{k+1}-\sqrt{(n+\lambda )[{\tilde{\mathbf{P}}}_{k+1}]}$$
- Propagate the points through the measurement function$${\tilde{\mathcal{Y}}}_{k+1}^{\left(i\right)}=h({\tilde{\mathcal{X}}}_{k+1}^{\left(i\right)},{\mathbf{U}}_{k+1},0),i\in [0,2n]$$
- Estimate the mean and covariance of the measurement$$\begin{array}{cc}\hfill {\tilde{\mathbf{Y}}}_{k+1}& =\sum _{i=0}^{2n}{\omega}_{i}^{\mu}{\tilde{\mathcal{Y}}}_{k+1}^{\left(i\right)}\hfill \end{array}$$$$\begin{array}{cc}\hfill [{\tilde{\mathbf{P}}}_{yy,k+1}]& =\sum _{i=0}^{2n}{\omega}_{i}^{c}({\tilde{\mathcal{Y}}}_{k+1}^{\left(i\right)}-{\tilde{\mathbf{Y}}}_{k+1}){({\tilde{\mathcal{Y}}}_{k+1}^{\left(i\right)}-{\tilde{\mathbf{Y}}}_{k+1})}^{T}+\left[\mathbf{R}\right]\hfill \end{array}$$
- Estimate the crossed covariance between the state and measurement$$[{\tilde{\mathbf{P}}}_{xy,k+1}]=\sum _{i=0}^{2n}{\omega}_{i}^{c}({\tilde{\mathcal{X}}}_{k+1}^{\left(i\right)}-{\tilde{\mathbf{X}}}_{k+1}){({\tilde{\mathcal{Y}}}_{k+1}^{\left(i\right)}-{\tilde{\mathbf{Y}}}_{k+1})}^{T}$$

#### Correction

- Compute the Kalman Gain$$\left[{\mathbf{K}}_{k+1}\right]=[{\tilde{\mathbf{P}}}_{xy,k+1}]{[{\tilde{\mathbf{P}}}_{yy,k+1}]}^{-1}$$
- Correct the state$$\begin{array}{cc}\hfill {\widehat{\mathbf{X}}}_{k+1}& ={\tilde{\mathbf{X}}}_{k+1}+\left[{\mathbf{K}}_{k+1}\right]({\mathbf{Y}}_{k+1}-{\tilde{\mathbf{Y}}}_{k+1})\hfill \end{array}$$$$\begin{array}{cc}\hfill [{\widehat{\mathbf{P}}}_{k+1}]& =[{\tilde{\mathbf{P}}}_{k+1}]-\left[{\mathbf{K}}_{k+1}\right][{\tilde{\mathbf{P}}}_{yy,k+1}]{\left[{\mathbf{K}}_{k+1}\right]}^{T}\hfill \end{array}$$

#### 2.3. Algorithm Complexity and Computing Power

- the processed lines counts to do an operation;
- the number of Multiplication and Accumulation (MAC) operations; and
- the number of Floating point Operations (FLOP) ( i.e., the number of operation on “Real numbers” in the algorithm).

#### 2.3.1. Algorithms Complexity

- one affectation for the initialization of the sum variable;
- one addition and affectation per element (n addictions and affectations);
- one division; and
- one affectation for the result.

- $T\left(f\right(n\left)\right)$, the number of operations to be executed to solve the problem; and
- $\mathcal{O}\left({f}_{O}\left(n\right)\right)={\mathrm{lim}}_{n\to +\infty}T\left(f\left(n\right)\right)$.

#### 2.3.2. A Computing Power Overview

- the ATMega328, a 8 bits microcontroller, the most commonly used in hobbyists designs as core controller of the Arduino Uno board;
- the STM32L053, a ultra low-consumption 32 bits microcontroller, used in the 2D orientation estimation demonstration; and
- the STM32F4xx, a high-end 32 bits microcontrollers family, embedding a FPU to accelerate computation of floating points numbers.

## 3. The Proposed Methodology

#### 3.1. Specify the Use-Cases

- the operation context of the system—to what end it is being used (e.g., Calibration mode, Normal estimation mode); and
- for each context, what are the parameters: known and controlled parameters, parameters to be estimated...

#### 3.2. Identify the System Equations

- defining all the physical parameters affecting the system outputs;
- defining all the calibration parameters (i.e., the dispersion parameters due to the sensors manufacturing process), and checking if it is possible to measure them independently of the desired measurement; and
- defining all the equations linking these physical parameters (those are mainly differential equations).

#### 3.3. Create the System Models for Each Use-Case

- the known parameters are put into the command vector ${\mathbf{U}}_{k}$ of the system;
- the parameters to be estimated and all the intermediate parameters in the differential equations are put into the state vector ${\mathbf{X}}_{k}$;
- the measured output values of the system are put into the measurement vector ${\mathbf{Y}}_{k}$;
- the evolution and measurement equations are written according to the previously established equations; and
- the system equations time discretization for continuous time equations (as the Kalman filters only works with discrete time models).

#### 3.4. Apply an Adapted Filter

- If the subsystem is mixed (i.e., its evolution equation is linear and its measurement equation is non-linear), the evolution part should be handled by Kalman filter implementation and the measurement part should be implemented using EKF or UKF method, in order to optimize the processing load.

- two matrix multiplications by a vector, of complexity $T(2\times 2\times 2\times 1)=T\left(8\right)$ each; and
- an addition of two vectors of two elements, of a complexity of $T\left(2\right)$

## 4. Application to a 2D Orientation Estimation Problem

#### 4.1. The Sensing Elements

- raw measurements for the Accelerations and Rotational speed on X, Y and Z axis;
- internal processing for free-fall detection, movement detection, 6D/4D orientation, click and double-click detection, pedometer, step detector and counter;
- an independent automatic sampling with data storage in FIFO;
- I${}^{2}$C or SPI serial interface; and
- two configurable interrupt output lines.

#### 4.2. The Processing Unit

- a low-power 32 MHz, 32 bits ARM Cortex-M0 processor, without FPU;
- 64 KB of Flash and 8 KB of RAM;
- a processing power of about 180 kFLOPs/s at 32 MHz; and
- ultra low power consumption, with 88 $\mathsf{\mu}$A/MHz running power consumption, and down to 270 nA Stand-by mode.

#### 4.3. Applying the Methodology

- Calibration mode: The sensor is still, on a table. Using this measurement, the gyroscope measurements should be zero, and the sensor bias is estimated by the filter.
- Orientation estimation mode: The sensor bias is known and used as a control input, and the sensor orientation is estimated by the filter.

#### 4.3.1. System Equations

- the gravity vector projection norm $|gra{v}_{XZ}|$;
- the gravity vector projection angle ${\theta}_{Y}$, which is the desired measurement translating the system orientation in the 2D plane; and
- the gyroscope measurement bias ${b}_{gyro}$.

- the acceleration noise on X and Z axes: ${R}_{ax}$ and ${R}_{az}$.

#### Calibration Mode Equations

#### Estimation Mode Equations

#### 4.3.2. Applying an Adapted Filter

#### Calibration Mode Filter

#### Estimation Mode Filter

## 5. Results and Discussion

## 6. Materials and Methods

- NUCLEO-L053R8 for the microcontroller development kit; and
- X-NUCLEO-IKS01A2 for sensing elements.

## 7. Conclusions

## Acknowledgments

## Author Contributions

## Conflicts of Interest

## Appendix A. Unscented Transform Computation

- Select the $2n+1$ states to propagate, those points are represented by the ${\mathcal{X}}^{\left(i\right)}$ matrix, composed of $2n+1$ state vectors of lenth n:$${\mathcal{X}}^{\left(i\right)}=\left(\right)open="\{"\; close>\begin{array}{cc}\tilde{\mathbf{X}}\hfill & \hfill ,i=0\\ \tilde{\mathbf{X}}+\sqrt{(\mu +\lambda )\left[{\mathbf{C}}_{X}\right]}\hfill & \hfill ,i\in [1,n]\\ \tilde{\mathbf{X}}-\sqrt{(\mu +\lambda )\left[{\mathbf{C}}_{X}\right]}\hfill & \hfill ,i\in [n+1,2n]\end{array}$$
- Transforming the points:$${\mathcal{Y}}^{\left(i\right)}=f({\mathcal{X}}^{\left(i\right)}),i\in [0,2n]$$
- Define the weights:$$\begin{array}{cc}\hfill {\omega}_{i}^{\mu}& =\left(\right)open="\{"\; close>\begin{array}{cc}\frac{\lambda}{\lambda +n}\hfill & \hfill ,i=0\\ \frac{1}{2(\lambda +n)}\hfill & \hfill ,i\in [1,2n]\end{array}\hfill \end{array}$$$$\begin{array}{cc}\hfill {\omega}_{i}^{c}& =\left(\right)open="\{"\; close>\begin{array}{cc}{\omega}_{0}^{\mu}+1-{\alpha}^{2}+\beta \hfill & \hfill ,i=0\\ \frac{1}{2(\lambda +n)}\hfill & \hfill ,i\in [1,2n]\end{array}\hfill \end{array}$$
- Compute the mean and covariance of the result:$$\begin{array}{cc}\hfill \tilde{\overline{Y}}& =\sum _{i=0}^{2n}{\omega}_{i}^{\mu}{\mathcal{Y}}^{\left(i\right)}\hfill \end{array}$$$$\begin{array}{cc}\hfill [{\tilde{\mathbf{C}}}_{Y}]& =\sum _{i=0}^{2n}{\omega}_{i}^{c}({\mathbf{Y}}_{i}-\tilde{\overline{Y}}){({\mathbf{Y}}_{i}-\tilde{\overline{Y}})}^{T}\hfill \end{array}$$

- the scattering factor $\alpha $ around the mean value,
- the distribution relative factor $\beta $ (for a Gaussian distribution $\beta =2$),
- $\lambda ={\alpha}^{2}(n+\kappa )-n$,
- $\kappa $ the scale factor, in general the value is fixed to $\kappa =3-n$.

## References

- Kahn, J.M.; Katz, R.H.; Pister, K.S.J. Next Century Challenges: Mobile Networking for “Smart Dust”. In Proceedings of the 5th Annual ACM/IEEE International Conference on Mobile Computing and Networking, Seattle, WA, USA, 15–19 August 1999; pp. 271–278. [Google Scholar]
- Gil, D.; Ferrández, A.; Mora-Mora, H.; Peral, J. Internet of Things: A review of Surveys Based on Context Aware Intelligent Services. Sensors
**2016**, 16, 1069. [Google Scholar] [CrossRef] [PubMed] - Khattak, A.M.; Truc, P.T.H.; Hung, L.X.; Vinh, L.T.; Dang, V.-H.; Guan, D.; Pervez, Z.; Han, M.; Lee, S.; Lee, Y.-K. Towards Smart Homes Using Low Level Sensory Data. Sensors
**2011**, 11, 11581–11604. [Google Scholar] [CrossRef] [PubMed] - Zhu, H.; Gao, L.; Li, H. Secure and Privacy-Preserving Body Sensor Data Collection and Query Scheme. Sensors
**2015**, 16, 179. [Google Scholar] [CrossRef] [PubMed] - Facchinetti, A. Continuous Glucose Monitoring Sensors: Past, Present and Future Algorithmic Challenges. Sensors
**2016**, 16, 2093. [Google Scholar] [CrossRef] [PubMed] - Kalman, R.E. A New Approach to linear Filtering and Prediction Problems. Trans. ASME J. Basic Eng.
**1960**, 82, 35–45. [Google Scholar] [CrossRef] - Sierra, M.; Maria, J. Kalman Filter, Particle Filter and Other Bayesian Filters. In Digital Signal Processing with Matlab Examples; Springer: Singapore, 2016; pp. 3–148. ISBN 978-981-10-2533-4. [Google Scholar]
- Brown, R.G.; Hwang, P.Y.C. Introduction to Random Signal and Applied Kalman Filtering, 4th ed.; Wiley: Hoboken, NJ, USA, 2012; ISBN 978-0-470-60969-9. [Google Scholar]
- Stoica, P.; Jansson, M. MIMO system identification: State-space and subspace approximations versus transfer function and instrumental variables. IEEE Trans. Signal Process.
**2000**, 48, 3087–3099. [Google Scholar] [CrossRef] - Al-Matouq, A.; Vincent, T.; Tenorio, L. Reduced complexity dynamic programming solution for Kalman filtering of linear discrete time descriptor systems. Am. Control Conf.
**2013**. [Google Scholar] [CrossRef] - Konatowski, S.; Kaniewski, P.; Matuszewski, J. Comparison of Estimation Accuracy of EKF, UKF and PF Filters. Annu. Navig.
**2016**, 23. [Google Scholar] [CrossRef] - Julier, S.J.; Uhlmann, J.K. A new extension of the kalman filter to nonlinear systems. Signal Process. Sens. Fusion Target Recognit.
**1997**, 3068. [Google Scholar] [CrossRef] - Del Moral, P.; Doucet, A. Particle methods: An introduction with applications. ESAIM Proc. Surv.
**2014**, 44, 1–46. [Google Scholar] [CrossRef] - Orderud, F. Comparison of Kalman Filter Estimation Approaches for State Space Models with Nonlinear Measurements. 2005. Available online: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.135.9250 (accessed on 25 October 2017).
- Wan, E.A.; van der Merwe, R. The Unscented Kalman Filter for nonlinear estimation. In Proceedings of the Adaptive Systems for Signal Processing, Communications, and Control Symposium, Lake Louise, AB, Canada, 2000; pp. 153–158. [Google Scholar]
- Higham, N. Functions of Matrices: Theory and Computation. SIAM
**2008**. [Google Scholar] [CrossRef] - Golub, G.H.; van Loan, C.F. Matrix Computations, 3rd ed.; Johns Hopkins University Press: Baltimore, MD, USA, 1996; ISBN 978-0801854149. [Google Scholar]
- Galal, S.; Horowitz, M. Energy-efficient floating-point unit design. IEEE Trans. Comput.
**2010**, 60, 913–922. [Google Scholar] [CrossRef] - Dang, A.T.; Nguyen, V.H. DCM-based orientation estimation using cascade of two adaptive extended Kalman filters. ICCAIS
**2013**. [Google Scholar] [CrossRef] - ST Microelectronics. Available online: http://www.st.com (accessed on 20 October 2017).
- Valade, A. Capteurs intelligents: Quelles méthodologies pour la fusion de données embarquée?
**2017**. [Google Scholar] [CrossRef]

**Figure 2.**Linear projection methods for: (

**a**) linear system (Kalman projection); and (

**b**) non-linear system local linearization (EKF projection).

**Figure 3.**Non-Linear projection methods for: (

**a**) local linearization system (EKF projection); and (

**b**) non-linear weighted projections (Unscented Transform projection).

Step | Kalman Filter | Real System |
---|---|---|

Evolution | ${\tilde{\mathbf{X}}}_{k+1}=\left[\mathbf{A}\right]{\widehat{\mathbf{X}}}_{k}+\left[\mathbf{B}\right]{\mathbf{U}}_{k}$ | ${\mathbf{X}}_{k+1}=\left[\mathbf{A}\right]{\mathbf{X}}_{k}+\left[\mathbf{B}\right]{\mathbf{U}}_{k}+{\mathbf{V}}_{k}$ |

$[{\tilde{\mathbf{P}}}_{\mathbf{k}+\mathbf{1}}]=\left[\mathbf{A}\right][{\widehat{\mathbf{P}}}_{k}]{\left[\mathbf{A}\right]}^{T}+\left[\mathbf{Q}\right]$ | ||

Prediction/measurement | ${\tilde{\mathbf{Y}}}_{k}=\left[\mathbf{C}\right]{\tilde{\mathbf{X}}}_{k}+\left[\mathbf{D}\right]{\mathbf{U}}_{k}$ | ${\mathbf{Y}}_{k}=\left[\mathbf{C}\right]{\mathbf{X}}_{k}+\left[\mathbf{D}\right]{\mathbf{U}}_{k}+{\mathbf{W}}_{k}$ |

Correction | ${\mathbf{E}}_{k}={\mathbf{Y}}_{k}-{\tilde{\mathbf{Y}}}_{k}$ | |

$\left[{\mathbf{K}}_{k}\right]=[{\tilde{\mathbf{P}}}_{\mathbf{k}}]{\left[\mathbf{C}\right]}^{T}{(\left[\mathbf{C}\right][{\tilde{\mathbf{P}}}_{k}]{\left[\mathbf{C}\right]}^{T}+\left[\mathbf{R}\right])}^{-1}$ | ||

${\widehat{\mathbf{X}}}_{k}={\tilde{\mathbf{X}}}_{k}+\left[{\mathbf{K}}_{k}\right]{\mathbf{E}}_{k}$ | ||

$[{\widehat{\mathbf{P}}}_{k}]=(\mathbf{I}-\left[{\mathbf{K}}_{k}\right]\left[\mathbf{C}\right])[{\tilde{\mathbf{P}}}_{k}]$ |

Step | EKF | Real System |
---|---|---|

Evolution | ${\tilde{\mathbf{X}}}_{k+1}=f({\widehat{\mathbf{X}}}_{k},{\mathbf{U}}_{k},0)$ | ${\mathbf{X}}_{k+1}=f({\mathbf{X}}_{k},{\mathbf{U}}_{k},{\mathbf{V}}_{k})$ |

$[{\tilde{\mathbf{P}}}_{\mathbf{k}+\mathbf{1}}]=\left[{\mathbf{F}}_{X,k+1}\right][{\widehat{\mathbf{P}}}_{k}]{\left[{\mathbf{F}}_{X,k+1}\right]}^{T}$ | ||

$+\left[{\mathbf{F}}_{V,k+1}\right]\left[\mathbf{Q}\right]{\left[{\mathbf{F}}_{V,k+1}\right]}^{T}$ | ||

Prediction/measurement | ${\tilde{\mathbf{Y}}}_{k}=h({\tilde{\mathbf{X}}}_{k},{\mathbf{U}}_{k},0)$ | ${\mathbf{Y}}_{k}=h({\mathbf{X}}_{k},{\mathbf{U}}_{k},{\mathbf{W}}_{k})$ |

Correction | ${\mathbf{E}}_{k}={\mathbf{Y}}_{k}-{\tilde{\mathbf{Y}}}_{k}$ | |

$\left[{\mathbf{K}}_{k}\right]=[{\tilde{\mathbf{P}}}_{\mathbf{k}}]{\left[{\mathbf{H}}_{X,k}\right]}^{T}{(\left[{\mathbf{H}}_{X,k}\right][{\tilde{\mathbf{P}}}_{k}]{\left[{\mathbf{H}}_{X,k}\right]}^{T}+\left[\mathbf{R}\right])}^{-1}$ | ||

${\widehat{\mathbf{X}}}_{k}={\tilde{\mathbf{X}}}_{k}+\left[{\mathbf{K}}_{k}\right]{\mathbf{E}}_{k}$ | ||

$[{\widehat{\mathbf{P}}}_{k}]=(\mathbf{I}-\left[{\mathbf{K}}_{k}\right]\left[{\mathbf{H}}_{X,k}\right])[{\tilde{\mathbf{P}}}_{k}]$ |

Operation | $\mathit{T}\mathbf{(}\mathbf{.}\mathbf{)}$ | $\mathcal{O}\mathbf{(}\mathbf{.}\mathbf{)}$ |
---|---|---|

Matrix multiplication | $2\times n\times m\times p$ | $2\times n\times m\times p$ |

Adding two vectors of size n | n | n |

Adding two matrices of size $(n,m)$ | $n\times m$ | $n\times m$ |

Transpose a matrix | 0 | 0 |

Invert a matrix | $4\times {n}^{3}+2\times {n}^{2}$ | $4\times {n}^{3}$ |

Mean vector of a matrix | $n\times (m+1)$ | $n\times m$ |

Mean value of a vector | $n+1$ | n |

Covariance de deux matrices | $2\times n\times m\times p$ | $2\times n\times m\times p$ |

Algo | Opération | $\mathcal{O}\mathbf{(}\mathbf{.}\mathbf{)}$ |
---|---|---|

(E)KF | ${\tilde{\mathbf{X}}}_{k+1}=\left[\mathbf{A}\right]{\widehat{\mathbf{X}}}_{k}+\left[\mathbf{B}\right]{\mathbf{U}}_{k}$ | $2{n}^{2}$ |

$[{\tilde{\mathbf{P}}}_{\mathbf{k}+\mathbf{1}}]=\left[\mathbf{A}\right][{\widehat{\mathbf{P}}}_{k}]{\left[\mathbf{A}\right]}^{T}+\left[\mathbf{Q}\right]$ | $4{n}^{3}$ | |

${\tilde{\mathbf{Y}}}_{k}=\left[\mathbf{C}\right]{\tilde{\mathbf{X}}}_{k}+\left[\mathbf{D}\right]{\mathbf{U}}_{k}$ | $2m(n+p)$ | |

${\mathbf{E}}_{k}={\mathbf{Y}}_{k}-{\tilde{\mathbf{Y}}}_{k}$ | m | |

$\left[{\mathbf{K}}_{k+1}\right]=[{\tilde{\mathbf{P}}}_{\mathbf{k}}]{\left[\mathbf{C}\right]}^{T}{(\left[\mathbf{C}\right][{\tilde{\mathbf{P}}}_{k}]{\left[\mathbf{C}\right]}^{T}+\left[\mathbf{R}\right])}^{-1}$ | $4{n}^{2}m$/$4{m}^{2}n$ | |

${\widehat{\mathbf{X}}}_{k}={\tilde{\mathbf{X}}}_{k}+\left[{\mathbf{K}}_{k}\right]{\mathbf{E}}_{k}$ | $2mn$ | |

$[{\widehat{\mathbf{P}}}_{k}]=(\mathbf{I}-\left[{\mathbf{K}}_{k}\right]\left[\mathbf{C}\right])[{\tilde{\mathbf{P}}}_{k}]$ | ∼$2{n}^{3}$/$2{m}^{2}n$ | |

UKF | ${\mathcal{X}}_{k}=\left(\right)open="["\; close="]">{\widehat{\mathbf{X}}}_{k},{\widehat{\mathbf{X}}}_{k}\pm \sqrt{(n+\lambda )[{\widehat{\mathbf{P}}}_{k}]}$ | ${n}^{3}$ |

${\tilde{\mathcal{X}}}_{k+1}^{\left(i\right)}=f({\mathcal{X}}_{k}^{\left(i\right)})$ | $2n\mathcal{O}\left(f\right(.\left)\right)$ | |

${\tilde{\mathbf{X}}}_{k+1}={\sum}_{i=0}^{2n}{\omega}_{i}^{\mu}{\tilde{\mathcal{X}}}_{k+1}^{\left(i\right)}$ | $4{n}^{2}$ | |

$[{\tilde{\mathbf{P}}}_{k+1}]={\sum}_{i=0}^{2n}{\omega}_{i}^{c}({\tilde{\mathcal{X}}}_{k+1}^{\left(i\right)}-{\tilde{\mathbf{X}}}_{k+1}){({\tilde{\mathcal{X}}}_{k+1}^{\left(i\right)}-{\tilde{\mathbf{X}}}_{k+1})}^{T}+\left[\mathbf{Q}\right]$ | $6{n}^{3}$ | |

${\tilde{\mathcal{Y}}}_{k+1}^{\left(i\right)}=g({\tilde{\mathcal{X}}}_{k+1}^{\left(i\right)},{\mathbf{U}}_{k+1},0)$ | $(2n+1)\mathcal{O}\left(g\right(.\left)\right)$ | |

${\tilde{\mathbf{Y}}}_{k+1}={\sum}_{i=0}^{2n}{\omega}_{i}^{\mu}{\tilde{\mathcal{Y}}}_{k+1}^{\left(i\right)}$ | $4{m}^{2}n$ | |

$[{\tilde{\mathbf{P}}}_{yy,k+1}]={\sum}_{i=0}^{2n}{\omega}_{i}^{c}({\tilde{\mathcal{Y}}}_{k+1}^{\left(i\right)}-{\tilde{\mathbf{Y}}}_{k+1}){({\tilde{\mathcal{Y}}}_{k+1}^{\left(i\right)}-{\tilde{\mathbf{Y}}}_{k+1})}^{T}+\left[\mathbf{R}\right]$ | $6{m}^{2}n$ | |

$[{\tilde{\mathbf{P}}}_{xy,k+1}]={\sum}_{i=0}^{2n}{\omega}_{i}^{c}({\tilde{\mathcal{X}}}_{k+1}^{\left(i\right)}-{\tilde{\mathbf{X}}}_{k+1}){({\tilde{\mathcal{Y}}}_{k+1}^{\left(i\right)}-{\tilde{\mathbf{Y}}}_{k+1})}^{T}$ | $4{n}^{2}m$ | |

${\widehat{\mathbf{X}}}_{k}={\tilde{\mathbf{X}}}_{k}+\left[{\mathbf{K}}_{k}\right]{\mathbf{E}}_{k}$ | $2mn$ | |

$[{\widehat{\mathbf{P}}}_{k}]=(\mathbf{I}-\left[{\mathbf{K}}_{k}\right]\left[\mathbf{C}\right])[{\tilde{\mathbf{P}}}_{k}]$ | ∼$2{n}^{3}$/$2{m}^{2}n$ |

Algorithm | $\mathit{T}\mathbf{(}\mathbf{.}\mathbf{)}$ | $\mathcal{O}\mathbf{(}\mathbf{.}\mathbf{)}$ |
---|---|---|

(E)KF | $4{n}^{3}+4{m}^{3}+6{m}^{2}n+4{n}^{2}m+3{n}^{2}+\cdots $ | $4{n}^{3}$ |

UKF | $10{n}^{3}+4{n}^{2}m+14{m}^{2}n+23{n}^{2}+6{m}^{2}+\cdots $ | $10{n}^{3}$ |

Controller | Single Precision Float Operations | Fixed Point 32 Bits Operations |
---|---|---|

ATMega328 8 bits/16 MHz | ≈100,000 | ≈1.5 M |

STM32L053 32 bits/32 MHz | ≈180,000 | ≈3.6 M |

STM32F4x 32 bits/216 MHz/FPU | ≈1 M without FPU, ≈12 M | ≈100 M |

Mode | Controlled/Known Parameters | Parameters to Estimate |
---|---|---|

Calibration | Main measurement parameters | System calibration parameters |

Normal estimation | System calibration parameters | Main measurement parameters |

Step | Used Equation |
---|---|

Evolution | ${\tilde{\mathbf{X}}}_{k+1}=\left(\right)open="["\; close="]">\begin{array}{cc}1& 0\\ 0& 1\end{array}\xb7{\mathbf{U}}_{k}$ |

$[{\tilde{\mathbf{P}}}_{\mathbf{k}+\mathbf{1}}]=\left(\right)open="["\; close="]">\begin{array}{cc}1& 0\\ 0& 1\end{array}+\left[\mathbf{Q}\right]=[{\widehat{\mathbf{P}}}_{k}]+\left[\mathbf{Q}\right]$ | |

Prediction/measurement | ${\tilde{\mathbf{Y}}}_{k}=\left(\right)open="("\; close=")">\begin{array}{c}{\tilde{a}}_{X,k}\\ {\tilde{a}}_{Z,k}\end{array}$ |

Correction | ${\mathbf{E}}_{k}={\mathbf{Y}}_{k}-{\tilde{\mathbf{Y}}}_{k}$ |

$\left[{\mathbf{K}}_{k}\right]=[{\tilde{\mathbf{P}}}_{\mathbf{k}}]{\left[{\mathbf{H}}_{X,k}\right]}^{T}{(\left[{\mathbf{H}}_{X,k}\right][{\tilde{\mathbf{P}}}_{k}]{\left[{\mathbf{H}}_{X,k}\right]}^{T}+\left[\mathbf{R}\right])}^{-1}$ | |

${\widehat{\mathbf{X}}}_{k}={\tilde{\mathbf{X}}}_{k}+\left[{\mathbf{K}}_{k}\right]{\mathbf{E}}_{k}$ | |

$[{\widehat{\mathbf{P}}}_{k}]=(\mathbf{I}-\left[{\mathbf{K}}_{k}\right]\left[{\mathbf{H}}_{X,k}\right])[{\tilde{\mathbf{P}}}_{k}]$ |

Parameter | Result |
---|---|

Start-up convergence time | ∼30 s @ $\pm {1}^{\circ}$ |

Still measurement noise | <0.1${}^{\circ}$ |

Measurement repeatability | <1${}^{\circ}$ in two consecutive tests |

© 2017 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Valade, A.; Acco, P.; Grabolosa, P.; Fourniols, J.-Y.
A Study about Kalman Filters Applied to Embedded Sensors. *Sensors* **2017**, *17*, 2810.
https://doi.org/10.3390/s17122810

**AMA Style**

Valade A, Acco P, Grabolosa P, Fourniols J-Y.
A Study about Kalman Filters Applied to Embedded Sensors. *Sensors*. 2017; 17(12):2810.
https://doi.org/10.3390/s17122810

**Chicago/Turabian Style**

Valade, Aurélien, Pascal Acco, Pierre Grabolosa, and Jean-Yves Fourniols.
2017. "A Study about Kalman Filters Applied to Embedded Sensors" *Sensors* 17, no. 12: 2810.
https://doi.org/10.3390/s17122810