C Kalman Filter
C Kalman Filter
Article
Implementation of a C Library of Kalman Filters for
Application on Embedded Systems
Christina Schreppel *, Andreas Pfeiffer, Julian Ruggaber and Jonathan Brembeck
Institute of System Dynamics and Control, Robotics and Mechatronics Center, German Aerospace Center (DLR),
82234 Weßling, Germany
* Correspondence: [email protected]; Tel.: +49-8153-28-4507
Abstract: Having knowledge about the states of a system is an important component in most control
systems. However, an exact measurement of the states cannot always be provided because it is either
not technically possible or only possible with a significant effort. Therefore, state estimation plays
an important role in control applications. The well-known and widely used Kalman filter is often
employed for this purpose. This paper describes the implementation of nonlinear Kalman filter
algorithms, the extended and the unscented Kalman filter with square-rooting, in the programming
language C, that are suitable for the use on embedded systems. The implementations deal with single
or double precision data types depending on the application. The newly implemented filters are
demonstrated in the context of semi-active vehicle damper control and the estimation of the tire–road
friction coefficient as application examples, providing real-time capability. Their per-formances were
evaluated in tests on an electronic control unit and a rapid-prototyping platform.
Keywords: Kalman filter; vehicle state estimation; road friction estimation; C implementation;
embedded systems
in [5]. The latter variant is also employed in a similar field in [6], together with the Kalman
filter, within a localization and mapping algorithm to measure the position of a robot. A
five-state extended Kalman filter is designed in [7], estimating the speed over the ground
of an unmanned surface vehicle, in addition to other quantities needed for course control,
and experimental results are shown. In [8], a lithium-ion battery cell is modeled and a
state of charge estimation is carried out. An algorithm for pose estimation based on one or
several event-based sensors is presented in [9], incorporating an extended Kalman filter
that is real-time capable in the case of one sensor.
The Kalman filter theory is explained in Section 2. Section 3 covers the implementation
of the new library, including the general structure, the integration of user-defined prediction
models, basic numerical routines, and the consideration of coding guidelines. In Section 4,
the applications of the library on an electronic control unit (ECU) and a rapid prototyping
platform are described and validations are carried out. Section 5 presents a conclusion.
with the vector of states x(t) ∈ Rnx , the time t ∈ R, the vector of inputs u(t) ∈ Rnu , the
vector of outputs y(t) ∈ Rny , and their respective dimensions n x , nu and ny . Since the
aim is to implement Kalman filter algorithms for state estimation on embedded systems,
which represent sampled data systems, model (1) cannot be used directly. Instead, it is
transformed to a discrete-time formulation. This resulting dynamic system with additive
Gaussian noise is utilized in the following discrete-time state estimation:
xk = fk | k −1 (xk −1 , uk −1 ) + wk −1 ,
yk = h (xk ) + vk ,
(2)
wk ∼ N(0, Q),
vk ∼ N(0, R),
with xk = x(tk ), uk = u(tk ) and yk = y(tk ), where tk denotes the k-th sample time point in
a data system sampled periodically. Both the system and output formulas are perturbed by
white Gaussian noises wk and vk . They are assumed to be uncorrelated with zero mean.
The corresponding covariance matrices for the noises are described by Q and R, which are
regarded to be constant. The discrete-time integration between the last sample point tk−1
and the new one tk is described by the following equation:
Ztk
fk | k −1 = xk −1 + f(x, uk−1 )dt, (3)
t k −1
whereby the integration can be performed by using, e.g., Runge-Kutta or Euler methods.
The required evaluations of the prediction model in the Kalman filter algorithms are
described by (1) and (3).
Figure 1 shows the basic idea of state estimation using Kalman filtering, see also [20].
A recursive algorithm is presupposed, which consists of the two steps predict and
correct, building a cyclic flow. At the beginning, the filter is initialized with x̂0+ and P0+ ,
which is an initial estimate for the state vector and the state covariance matrix, that indicates
the confidence in this first guess. The first step of the cycle in Figure 1 refers to the predict
step. It represents an a priori estimation of the mean and covariance, which means a gauge
for the trust in the system states. The outcomes of this step have a “−” in their superscripts
in the following. This is succeeded by the correct step, the results of which have a “+” in the
superscript. In this step, the covariance matrix and the estimated states are updated, using
the calculated Kalman gain and the current measurements of the outputs ym k in the actual
sample k. Afterwards the predict step follows and the procedure repeats with k := k + 1.
The cycle is carried out with a specified sample time Ts . At every sample period, new
Computers 2022, 11, 165 4 of 23
𝒙+
0,
+
0
𝒙−
𝑘,
−
𝑘
Measurement
Time Update
Update
(Predict)
(Correct)
𝒖𝑘 𝒙+
𝑘,
+
𝑘
𝒚𝑚
𝑘
Figure1.1.Scheme
Figure Schemeof
ofstate
stateestimation
estimationusing
usingKalman
Kalmanfiltering.
filtering.
2.1. Nonlinear
A recursive Kalman Filter Variants
algorithm is presupposed, which consists of the two steps predict and
+
correct,
Basedbuilding
on thisageneral
cyclic flow. At the
principle beginning,
of state estimation,the filter
there isareinitialized with 𝑥̂of
several variants and 𝑃0+ ,
0 Kalman
which The
filters. is anpure
initial estimate
Kalman foristhe
filter statefor
suited vector
linearand the state
systems. covariance
However, matrix, that
real-world systemsindi-
often
cates include nonlinearities.
the confidence In order
in this first guess.to The
be able
firsttostep
alsoofapply the state
the cycle estimation
in Figure 1 refersto these
to the
systems, nonlinear
predict step. Kalmananfilters
It represents were
a priori developed,
estimation of for
theexample,
mean andthe extended Kalman
covariance, which means filter
(EKF) and the unscented Kalman filter (UKF). Since these two
a gauge for the trust in the system states. The outcomes of this step have a “−” in theirvariants are well known and
widely used, only a short overview is given at this point for the
superscripts in the following. This is succeeded by the correct step, the results of which sake of brevity. A detailed
description
have a “+” of in the algorithms
superscript.ofInboth thisvariants
step, thecan be foundmatrix
covariance in Appendix
and theA.estimated states
The EKF using
are updated, linearizes the modelKalman
the calculated using Taylor
gain and series
the expansions, while the UKF
current measurements of thedoes out-
not
puts use𝒚𝑚𝑘
approximations
in the actual for
sample performing
𝑘. state
Afterwards estimation
the predict on nonlinear
step follows systems.
and the Instead,
procedure it
selects specified points, the sigma points, around the current states
repeats with 𝑘: = 𝑘 + 1. The cycle is carried out with a specified sample time 𝑇𝑠 . At every and propagates them
through
sample the nonlinear
period, function of the system
new measurements to estimate
of the outputs are the next state.
provided andAs a result,
used the UKF
to update the
has a higher accuracy compared
current estimation of the states. to the EKF. However, its implementation requires higher
computational effort.
As an extension
2.1. Nonlinear Kalmanto the EKF
Filter and the UKF in terms of numerical robustness, there are
Variants
also the extended Kalman filter with square-rooting (EKF-SR) and the unscented Kalman
Based on this general principle of state estimation, there are several variants of Kal-
filter with square-rooting (UKF-SR). These two variants use a decomposition of the state
man filters. The pure Kalman filter is suited for linear systems. However, real-world sys-
covariance matrix and employ its positive definiteness, entailing higher numerical stability
tems often include nonlinearities. In order to be able to also apply the state estimation to
of the square-rooting (SR) variants compared to the original filters.
these systems, nonlinear Kalman filters were developed, for example, the extended Kal-
The filter equations of the EKF and the EKF-SR are summarized in Section A.1 and
man filter (EKF) and the unscented Kalman filter (UKF). Since these two variants are well
Section A.2, respectively. The UKF and its modifications to the UKF-SR are described in
known and widely used, only a short overview is given at this point for the sake of brevity.
Sections A.3 and A.4.
A detailed description of the algorithms of both variants can be found in Appendix A.
The EKF linearizes
2.2. Incorporation of State the model using Taylor series expansions, while the UKF does not
Constraints
use approximations for performing state estimation on nonlinear systems. Instead, it se-
As an augmentation to the methods of state estimation with Kalman filtering described
lects specified
above, it is alsopoints,
possible thetosigma
considerpoints, around constraints
additional the current on states
theand propagates
states. This may thembe
through the nonlinear function of the system to estimate the next
essential in some practical applications where physical limitations on the states are imposed. state. As a result, the
UKF has
These a higher
include, for accuracy
example,compared
the need for to the EKF. However,
positive concentrations its implementation
in a chemical requires
system.
higher computational effort.
Taking this additional information about the constraints into account, the estimation of the
statesAs an extension
becomes to the EKF
more reliable. and the UKF
An approach in terms
to realize thisof numerical
with the UKFrobustness,
is suggested there are
in [21].
also the extended Kalman filter with square-rooting (EKF-SR)
Therein, the inequality constraints define a feasible range for the states. If sigma points and the unscented Kalman
filter
for thewith
UKFsquare-rooting
are outside this(UKF-SR).
range, they These two variants
are projected to theuseedge
a decomposition
of the admissible of the state
region.
covariance matrix and employ its positive definiteness, entailing
This is applied directly after the computation of the sigma points in Equation (A10) and higher numerical stabil-
ity of after
again the square-rooting
their propagation (SR)through
variantsthe compared
nonlinear to function
the original filters. (A11). The same
in Equation
method The is filter equations
employed for theofestimated
the EKF and theif EKF-SR
states they do not are respect
summarized in Sections
the constraints. A.1 and
Using the
A.2, respectively. The UKF and its modifications to the UKF-SR
described approach of projecting the sigma points, the constraints also affect the covariance. are described in Sections
A.3
In and A.4.
contrast to simply clipping the estimated states, this makes the estimation more precise.
in [21]. Therein, the inequality constraints define a feasible range for the states. If sigma
points for the UKF are outside this range, they are projected to the edge of the admissible
region. This is applied directly after the computation of the sigma points in Equation (A10)
and again after their propagation through the nonlinear function in Equation (A11). The
Computers 2022, 11, 165 same method is employed for the estimated states if they do not respect the constraints. 5 of 23
Using the described approach of projecting the sigma points, the constraints also affect
the covariance. In contrast to simply clipping the estimated states, this makes the estima-
tion state
This moreconstraint
precise. This state thus
method constraint
providesmethod thus provides
additional support additional support so
for the estimation forthat
the
estimation so that physically infeasible state values do not occur at all. In [20] an overview
physically infeasible state values do not occur at all. In [20] an overview of methods for
of methods
handling for handling
constraints constraints
in state in state
estimation estimation is provided.
is provided.
3. Implementation
3. Implementation of of the
the Embedded
Embedded Kalman Kalman Filter
Filter Library
Library
The embedded
The embedded Kalman Kalman filter
filter library
library comprises
comprises implementations
implementations for for the
the EKF-SR
EKF-SRand and
the UKF-SR. It is based on an internally developed library; see [22,23]. In contrast,
the UKF-SR. It is based on an internally developed library; see [22,23]. In contrast, all parts all parts
ofthe
of theembedded
embeddedKalman Kalmanfilter
filterlibrary
librarywere
were newly
newly implemented
implemented inwithout
in C C without dependen-
dependencies
ciesexternal
on on external libraries.
libraries.
Thissection
This sectionpresents
presentsdetails
detailsabout
aboutthetheimplementation
implementationofof thethe embedded
embedded Kalman
Kalman fil-
filter
ter library.
library. Its general
Its general structure
structure is shown,
is shown, in addition
in addition to its usage
to its usage with user-defined
with user-defined pre-
prediction
diction models.
models. Additionally,
Additionally, a summary a summary of the employed
of the employed numerical numerical
routines routines is given
is given and and
features
of the implementation regarding coding guidelines are described.
features of the implementation regarding coding guidelines are described.
3.1.
3.1. Structure
Structure of of the
the Embedded
Embedded Kalman
Kalman Filter
Filter Library
Library
The library is generally composed
The library is generally composed of generic of generic filter
filter parts
parts andand model-specific
model-specific parts.
parts. The
The filter parts contain the routines of the respective filter variant including
filter parts contain the routines of the respective filter variant including all necessary nu- all necessary
numerical routines,but
merical routines, butdodonotnothold
holdany
anyprediction
prediction model-specific
model-specific information.
information. These
These areare
grouped
grouped in a separate part of the library. Therefore, the generic filter parts can be applied
in a separate part of the library. Therefore, the generic filter parts can be applied
without
without anyany problem-specific adaptations. Figure
problem-specific adaptations. Figure22shows
showsthe thegeneral
generalstructure
structure ofof
thethe
li-
library, withthe
brary, with thegeneric
generic filter
filter parts
parts on
on the
the left
left side
side and
and thethe model-specific
model-specific parts
parts on
on the
the right.
right.
Figure2.2. Diagram
Figure Diagramof
of the
the general
generalstructure
structureof
ofthe
theembedded
embeddedKalman
Kalmanfilter
filterlibrary.
library.
The filter algorithms (see the middle part of Figure 2) are divided into an initializa-
tion part and a main part. The corresponding functions are named xkf_sr_initialize and
xkf_sr_predict_correct, where the prefix depends on the respective filter variant, i.e., ekf_sr
or ukf_sr. In the function xkf_sr_predict_correct the actual evaluation of the Kalman filter
routines takes place. Here, the computations for the time and measurement update, the
predict and correct steps, are carried out, see Figure 1. The specific operations depend on
the filter variant used and are listed in the appendix in Tables A1 and A5, respectively
in the modifications (A22)–(A25). Thus, the function xkf_sr_predict_correct constitutes the
cyclic flow of the filter algorithms and is executed in each time step of the estimation. It
utilizes the inputs uk of the prediction model as well as the measured model outputs ym k .
The output of the function represents the estimated states x̂+ k to be computed by the filter
algorithm at sample time tk , cf. Figure 3 for illustration.
predict and correct steps, are carried out, see Figure 1. The specific operations depend on
the filter variant used and are listed in the appendix in Tables A1 and A5, respectively in
the modifications (A22)–(A25). Thus, the function xkf_sr_predict_correct constitutes the cy-
clic flow of the filter algorithms and is executed in each time step of the estimation. It
utilizes the inputs 𝒖𝑘 of the prediction model as well as the measured model outputs 𝒚𝑚 𝑘 .
Computers 2022, 11, 165 6 of 23
The output of the function represents the estimated states 𝒙+ 𝑘 to be computed by the filter
algorithm at sample time 𝑡𝑘 , cf. Figure 3 for illustration.
𝒖𝑘
xkf_sr_predict_correct 𝒙+
𝑘
𝒚𝑚
𝑘
Figure
Figure 3. Interfaces
3. Interfaces of of
thethe function
function xkf_sr_predict_correct
xkf_sr_predict_correct to to
thethe surrounding
surrounding software
software environment.
environment.
To include the embedded Kalman filter library in a given software environment for a
To include the embedded Kalman filter library in a given software environment for
known prediction model, the user needs
a known prediction model, the user needs
• to provide prediction model-specific functions using the given interfaces of the library
• to provide prediction model-specific functions using the given interfaces of the li-
(right part of Figure 2), see Section 3.2 for more details on these functions,
brary (right part of Figure 2), see Section 3.2 for more details on these functions,
• to call the function xkf_sr_initialize once in the initialization phase,
• to call the function xkf_sr_initialize once in the initialization phase,
• to call the function xkf_sr_predict_correct in each sample time step of the environment,
• to call the function xkf_sr_predict_correct in each sample time step of the environment,
and
• and to provide variables for the inputs uk , ym and the outputs x̂+ of the function xkf_
• provide variables for the inputs 𝒖𝑘 , 𝒚k𝑚
to sr_predict_correct. k +
𝑘 and the outputs 𝒙𝑘 of the function
xkf_sr_predict_correct.
The filter algorithm functions have the following C prototypes:
The filter algorithm functions have the following C prototypes:
• void xkf_sr_initialize (void)
• • void voidxkf_sr_initialize (void) (real_t * ptr_u, real_t * ptr_y_meas, real_t * ptr_out)
xkf_sr_predict_correct
• void xkf_sr_predict_correct (real_t * ptr_u, real_t * ptr_y_meas, real_t * ptr_out)
In the routine xkf_sr_initialize, all global variables are initialized and the model-specific
In the routine
initialization xkf_sr_initialize,
functions are called,allforglobal
examplevariables are initialized
for setting and the model-spe-
the filter parameters, providing
cific initialization
an initial guess for functions
the statesare andcalled, for example
for initializing for setting
the model the filter parameters,
variables.
providing Thean initial guess
function for theofstates
parameters and for initializing
xkf_sr_predict_correct mustthebemodel
set invariables.
the software environ-
ment before the first call. They represent pointers to variablesinfor
The function parameters of xkf_sr_predict_correct must be set thethesoftware
inputsenviron-
uk (ptr_u)
ment before the first call. They
m represent pointers to variables
and measured outputs yk (ptr_y_meas) of the prediction model and the estimated for the inputs 𝒖𝑘 (ptr_u)
states
andx̂+ measured
(ptr_out). outputs
In the 𝒚𝑚 𝑘 (ptr_y_meas)
function, several of the prediction
model-specific model are
functions andcalled
the estimated
in a states
generic way,
k
𝒙+ (ptr_out).
𝑘for exampleIntothe function,
perform theseveral model-specific
model evaluations from functions are called
(1) and (3). Further, infilter
a generic way,
subroutines
forand
example to performroutines
basic numerical the model areevaluations
employed,from see left(1) part
and of(3).Figure
Further, filter subroutines
2. More details on the
and basic
latter numerical
functions are routines are employed,
given in Section 3.3. Thesee leftsubroutines
filter part of Figure carry2.outMore thedetails on the
respective filter
latter functions are given in Section 3.3. The filter
computations, see Appendix A, e.g., ukf_sr_sigma_points performs (A10). subroutines carry out the respective
filter computations,
The data typesee Appendix
named real_tA,
is e.g., ukf_sr_sigma_points
defined in the library and performs
used for (A10).
single or double
The data
precision type named
floating-point real_t isBy
variables. defined
doing in thethe
this, library
wholeand used
library for singleinorboth
is available double
a float
precision
32-bit and floating-point
a float 64-bit variables. By doing
configuration, wherethis, the whole
the switch is donelibrary is available
by simply activatingin both a
a macro
float 32-bit
in the code.andThus,
a float 64-bit configuration,
depending where the
on the application, the data
switchtype is and
donethe bydesired
simply accuracy
activating can
be selected.
a macro in theFor example,
code. Thus, offline simulations
depending with the purpose
on the application, the dataof validating
type and the theestimation
desired
may need
accuracy cana behigher accuracy,
selected. whereas the
For example, use on
offline embeddedwith
simulations systems requires single
the purpose precision
of validating
computing. The model code needs to support the use
the estimation may need a higher accuracy, whereas the use on embedded systems of this data type real_t or to provide
re-
another
quires dataprecision
single type thatcomputing.
is suitable forThethemodel
chosencodeprecision,
needs i.e., 32-bit orthe
to support 64-bit.
use of this data
type real_t or to provide another data type that is suitable for the chosen precision, i.e., 32-
bit3.2. Incorporation of User-Defined Prediction Models
or 64-bit.
It is presupposed that the prediction model whose states are to be estimated is available
asIncorporation
3.2. C code, including the model
of User-Defined evaluations
Prediction Models from (1) and (3). For example, this can be
accomplished by exporting code from a simulation environment in which the model is
designed. The obtained model code then needs to be interfaced to the model-specific part
of the embedded Kalman filter library, see the right side of Figure 2 for the list of functions.
For each prediction model, all the problem-specific information (functions, global data and
macros) can be included in a single separate C file. Some functions are only needed by a
certain filter variant, others by all of them.
The memory concept of the library consists of a set of global variables to be used in
the generic filter functions xkf_sr_initialize or xkf_sr_predict_correct and global variables in
the model-specific part. The size of the generic global arrays depends on the dimensions of
the problem considered, namely the number of states n x and the number of outputs ny of
the underlying model. These sizes must be defined in the model-specific part via macros
NX and NY. A working memory for temporary data is also provided as a global variable
and used for internal calculations in the filter subroutines and basic numerical routines. A
Computers 2022, 11, 165 7 of 23
further important part of the memory concept is global variables for the model inputs uk ,
.
the states xk , the state derivatives xk and the ouputs yk to be declared in the model-specific
code and to be used in the model functions. In the following description of the model
functions it is assumed that these global variables exist.
In the initialization phase of the state estimation, i.e., in the function xkf_sr_initialize,
the following functions being part of the model algorithms are called first:
• void set_model_states(real_t * states[NX])
• void set_model_der_states(real_t * der_states[NX]) (only needed for the EKF-SR)
• void set_model_outputs(real_t * outputs[NY])
These three functions are used to establish a link between the generic filter functions
and the global model variables for states, state derivatives and outputs used in the model
code. The idea is not to use the global model variables by their names but access them in
the generic filter functions via vectors of pointers (states, der_states, outputs). The length of
these vectors is defined by using the macros NX and NY. The vectors are provided by the
function xkf_sr_initialize and their components have to be assigned in the listed functions to
the memory location of the respective global model variables.
Next, the following functions are called in the initialization phase:
• void set_x_pre(real_t xpre[NX])
• void set_filter_params(real_t *alpha, real_t *beta, real_t *kappa) (only needed for the UKF-
SR)
• void set_covariances(real_t CfPpre[NX*NX], real_t CfQ[NX*NX], real_t CfR[NY*NY])
• void do_model_initialization(void)
In the first function, values for the initial guess of the states x̂0 have to be provided. The
second function is only needed for the filter variant UKF-SR and specifies the parameters
α, β and κ from Table A2. In the third function, an initial estimate for the state covariance
matrix P0 and the process and measurement noise covariance matrices Q and R is set.
Throughout the C program, matrices are stored column-wise via arrays and are manipu-
lated accordingly. These three functions apply global variables as function parameters that
are supplied by generic filter functions. The last function of the model-specific part that is
called in xkf_sr_initialize is do_model_initialization. Here, the initialization of the underlying
prediction model is performed, for example by executing a corresponding function from
the user provided model code.
In the cyclically processed function xkf_sr_predict_correct, several functions from the
model algorithms are also called. Concerning the model inputs uk , that arrive in each
sample time step tk , that is:
• void get_model_inputs(real_t *ptr_u)
This function is used to pass the inputs ptr_u provided by the software environment
to the respective inputs of the model code.
In the further processing of xkf_sr_predict_correct, the following functions of the model
algorithms are called:
• void get_der_states(void) (only needed for the EKF-SR)
• void get_outputs(void)
• void get_states(void)
• void get_state_constraints (int state_constr_ind[NX_CONSTR], real_t constrVecLow[NX_
CONSTR], real_t constrVecUp[NX_CONSTR]) (optional)
By executing the first three functions the model evaluations from (1) and (3) are carried
out. These are the evaluation of the state derivatives, outputs, or the updating of the states
by performing the integration between two sample points.
The last function get_state_constraints denotes an optional function. If state constraints
are present, they can be specified here. The function will only be activated if the user has
enabled a macro and the state constraints are then incorporated in the filter algorithms as
described in Section 2.2. It is possible to provide constraints for only some of the total n x
Computers 2022, 11, 165 8 of 23
states. If a state has constraints, both lower and upper constraints must be indicated. The
user needs to define a macro (NX_CONSTR) for the number of states that have constraints
and to give the indices of these states via the array state_constr_ind. The respective con-
straints are then specified in constrVecLow and constrVecUp which are provided with the
appropriate length of constrained states defined by the macro.
In addition to all these mentioned model algorithms, the function xkf_sr_predict_correct
executes the predict and correct steps of the respective filter variants, which do not contain
any model-specific components. The functions utilized in this regard usually receive arrays
as parameter arguments.
At the end of the function xkf_sr_predict_correct, the variables for the states and the
system covariance matrix are set to the respective current estimates and, thus, provide
the starting point for the next iteration step. The estimated states x̂+ k , representing the
outputs of the main function xkf_sr_predict_correct, are passed to the surrounding software
environment where the estimator is employed and where they can be further processed.
Due to the particular design of the algorithm, where the calculations are carried out
by using multiples of two, no roundoff errors are generated. More information about
the matrix exponential can also be found in [24].
• LQ factorization (lq_fact):
• A = LQ, where A ∈ Rm×n is a real matrix, L ∈ Rm×n is a lower triangular matrix and
Q ∈ Rn×n is an orthogonal matrix. The implementation is based on the corresponding
LAPACK routine sgelqf [26]. The algorithm returns the matrix L on the lower triangle
of A, while the matrix Q is only implicitly available. Several other methods for basic
matrix operations are included in this routine. It is used in Equations (A22) and (A23).
• Equilibration (equilibrate): This algorithm can be employed directly preceding the LQ
factorization to equilibrate the corresponding matrix that is to be decomposed. The
use of this routine is optional. It applies a different methodology than the balancing
mentioned above. Its goal is to reduce the condition number of a matrix by computing
row and column scaling. Thereby, roundoff errors can be minimized. The algorithm is
based on the LAPACK routine sgeequ [26].
• Low-rank Cholesky updating and downdating (cholesky_update, cholesky_downdate): This
algorithm performs the updating of the Cholesky factor used e.g., in (A22). Starting
from the Cholesky decomposition A = GGT , the Cholesky factor G∗ is calculated where
A∗ = G∗ G∗ T . Here, the relation A∗ = A ± vvT is considered with a corresponding vector
v. For details about Cholesky updating and downdating, see [24,27].
Table 1. Code segment to define the data type and macros depending on the chosen precision.
#define single_precision
#ifdef double_precision
typedef double real_t;
#define ukf_sr_fabs fabs
#define ONE 1.0
#elif defined single_precision
typedef float real_t;
#define ukf_sr_fabs fabsf
#define ONE 1.0f
#endif
Another MISRA C rule states that input variables received from an external source
need to be checked. This is because there could be a possibility that such inputs show
invalid values due to errors. If these are later used without prior checking, unintended
effects may be encountered, for example an infinite loop may be created by an invalid
loop controller or an array index bounds error may occur due to invalid memory accesses.
Furthermore, the use of dynamic memory allocation should be avoided according to the
MISRA C guidelines. However, several subfunctions of the filter algorithms performing
internal calculations demand additional memory space for temporary data. This is handled
by introducing a pre-allocated floating-point type working memory, which is passed to the
internal functions as a pointer and is also propagated to further subroutines. The length
of the working array is appropriate and depends merely on the dimensions of the state
and output variables of the underlying model. Thus, the allocation of dynamic memory is
not necessary.
ning with physical models of systems or controllers, and ending with efficient production
code for embedded systems through different specialized software tools.
The used prediction model is implemented in the modeling language Modelica [30]
and represents a nonlinear quarter vehicle model incorporating a two-mass system [28].
Utilizing code export by means of the eFMI standard, C code is generated from the Modelica
prediction model, which is interfaced to the Kalman filter model functions. The filter type
EKF-SR is chosen because of its lower execution time compared to the UKF-SR. Together
with the controller, the state estimator is included in the software framework of the ECU
by means of TargetLink [31] and compiled for the ECU. Simulations are carried out, in
addition to real-world demonstrations with a test vehicle equipped with sensors and the
ECU. The Kalman filter runs in real time on the embedded system in the vehicle with a
sample time of 1 ms. It is deduced that the filter is generally able to track the dynamics of
the states. The results of the test drive are shown and evaluated in [28], and details of the
entire setup and the tool chain can also be found therein.
This vector includes the side-slip angle β of the vehicle, its over ground velocity
.
v, the maximum tire-road friction coefficient µmax and the vehicle’s yaw rate ψ. The
friction coefficient is a particularly interesting variable for the estimation because its direct
measurement is hardly possible and its estimation is rather challenging. In particular, with
regard to automated driving, the friction coefficient is an essential quantity, as it describes
the road condition and, therefore, strongly influences the steering and braking dynamics of
the vehicle.
The vehicle prediction model expects 11 input components:
h . i
u = δfl δfr δrl δrr ωfl ωfr ωrl ωrr a x,in ay,in ψin . (5)
This includes the respective steering angles δi and speeds ωi of the four wheels,
where the subscript i indicates the front or rear and the right or left wheels. Finally, the
.
longitudinal and lateral acceleration a x,in and ay,in , respectively, as well as the yaw rate ψin
represent the input quantities for the Kalman filter.
The values of a x,in and ay,in are unknown inputs in the tire force equations, whose
outputs are in turn the same acceleration values. Thus, this structural dependency re-
sults in an algebraic loop, see [33] (Appendix B). It is possible to obtain its solution by
considering a nonlinear system of equations which is computationally expensive to solve.
In addition to the limited computational capacity on embedded systems, this aspect is
also problematic from a real-time capability view due to its iterative solution procedure.
Computers 2022, 11, 165 12 of 23
However, the aforementioned algebraic loop can be eliminated by including a x,in and
ay,in as input variables for the prediction model, since these vehicle accelerations can be
.
measured accurately and cost-effectively. Moreover, the yaw rate ψin , whose accurate
measurement is also possible, is taken as an additional input variable enabling open-loop
evaluation of the prediction model. This is particularly advantageous in scenarios where
the feedback through the measurement update (closed-loop) cannot be performed, e.g.,
due to measurement interruptions.
Regarding the outputs y of the prediction model, the following 10 quantities are
selected and are available as measurands:
h . i
y = β out vout Fy f Fyr Fx f Fxr Mz f a x,out ay,out ψout (6)
This vector includes the virtual side-slip angle β out and the virtual speed vout , in
addition to the virtual longitudinal (Fx f , Fxr ) and lateral (Fy f , Fyr ) forces of the front and
rear axles, respectively. Details about these virtual measurands, which are computed by
means of other measured variables, and their derivations are described in [33]. Another
output of the model is the tire self-aligning torque on the front axle Mz f , and, furthermore,
.
the longitudinal and lateral accelerations a x,out and ay,out , in addition to ψout . All of these
variables are used as measured outputs in the measurement update step of the Kalman
filter, see also the vector ym
k in Figure 1 and Equations (A5) and (A20).
4.2.2. Integration of the Model Code in the Embedded Kalman Filter Library
In several steps the outlined Modelica prediction model of ROMO‘s vehicle dynamics
is processed to suitable C code, which is finally interfaced to the model-specific functions
of the embedded Kalman filter library. The process is based on the eFMI workflow [29] as
described in [28] for the application example in Section 4.1. It includes the following steps:
• the export of the Modelica model to eFMI GALEC code [29] by a Dymola prototype
implementation,
• manual modifications of the generated GALEC code to provide all necessary features
and function interfaces for state estimation, and
• the generation of eFMI production C code based on the modified GALEC code by an
CATIA ESP prototype implementation. CATIA ESP is a newly developed production
code generator not yet released by Dassault Systèmes.
In the first of the listed steps the prediction model equations are automatically dis-
cretized with the Explicit Euler method to ensure real-time capable code. The manual
modifications in the second step are related to the eFMI function DoStep and its interface.
The GALEC code is modified to enable several calls of DoStep within one sample period for
different additional purposes such as repeating the integration step with different values of
the states and evaluating the state derivatives and outputs for given states. These features
have not yet been included in the eFMI standard proposal [29]. The generated C code of
DoStep is interfaced to the library functions get_states, get_der_states and get_outputs, see
Figure 2. More details on the applied process can be found in [28]. For the state estimation,
the filter type UKF-SR is chosen in this application because of its higher numerical accuracy
compared to the EKF-SR and a significant nonlinearity caused by the tire model.
The filter’s process and measurement noise covariance matrices Q and R, and the
filter parameters α, β and κ from Table A2 are determined via an optimization approach
described in [33]. They are specified using a reference trajectory obtained by means of a
high-precision validated multiphysics Modelica model of the ROMO, see [33]. In contrast
to the prediction model, this model represents a very detailed full vehicle model combined
with an environmental model. It is utilized to generate reference data for the state estimator.
The covariance matrices Q and R are determined to minimize the quadratic tracking error,
i.e., the quadratic error between the estimated states and the states of the reference trajectory.
The relevant system and measurement noise covariances are used as tuning parameters in
Computers 2022, 11, 165 13 of 23
this minimization problem. The optimization is carried out by applying the optimization
software MOPS [34]. In the same way, the filter parameters α, β and κ are determined.
For the initial guess of the state vector, which is to be set in the initialization phase of the
estimation, the initial states of the reference trajectory are used.
For the estimation of the state µmax , the maximum tire friction coefficient, state con-
straints are introduced according to [33]. They arise from the physical limitations. The
upper limit for the friction coefficient is given by the constant 1. The lower limit, which is
represented here by the currently utilized friction value, can be approximated by consider-
ing Kamm’s friction circle [33]. This limit is calculated using the longitudinal and lateral
accelerations a x,in and ay,in and the gravitational acceleration g:
1q
a x,in 2 + ay,in 2 . (7)
g
These constraints are implemented in the function get_state_constraints, see Section 3.2.
1 q
a x,in 2 + ay,in 2 . (8)
g · µmax
It utilizes the lateral and longitudinal accelerations of the vehicle ay,in and a x,in , respec-
tively, and the gravitational acceleration g. Figure 5 shows the time dependent plot of this
excitation and of the friction coefficient from Figure 4 for convenient comparison.
Computers 2022, 11, x FOR PEER REVIEW 14 of 23
Figure 4 shows the results of the simulation of the Simulink model, which contains
Computers 2022, 11, 165 the UKF-SR algorithm and the prediction model code with single precision data type as
14 of 23
an S-function and the derived inputs.
The estimated states of the model (see (4)) are depicted, as well as the reference tra-
jectory for each state. The comparison over the entire simulation period of 60 s shows
good agreement, especially for the side-slip angle 𝛽, the over ground velocity 𝑣 and the
yaw rate 𝜓̇. The maximum friction coefficient 𝜇max can also follow its reference trajectory
well. Corresponding to the introduced state constraints, the friction coefficient does not
exceed the upper limit of 1. However, slight deviations of the estimation occur, e.g., at 15
s, 44 s and 55 s. An explanation for this relates to the excitation of the system as follows.
The prescribed driving path of the reference vehicle to generate the input data 𝒖
represents a crossing eight; see [33]. Different lateral and longitudinal excitations occur in
the process, due to braking, accelerating and steering. The overall excitation results from
the consideration of Kamm’s friction circle and is given by the following formula [33]∶
1
√𝑎𝑥,𝑖𝑛 2 + 𝑎𝑦,𝑖𝑛 2 . (8)
𝑔 ⋅ 𝜇max
It utilizes the lateral and longitudinal accelerations of the vehicle 𝑎𝑦,in and 𝑎𝑥,in ,
respectively, and the gravitational acceleration 𝑔. Figure 5 shows the time dependent plot
of this excitation and of the friction coefficient from Figure 4 for convenient comparison.
5. Estimated
Figure 5. Estimatedand andreference
referencefriction
frictioncoefficient
coefficient from
from Figure
Figure 4, compared
4, compared to the
to the excitation
excitation of
of the
the system
system (8). (8).
fromfrom
The parts of the simulation range, where the friction coefficient shows the outliers,
correspond to phases with a low input excitation. In [33] it is demonstrated that, in these
passages the observability of the dynamical system decreases since the excitation is below
a necessary threshold. For the friction coefficient, this leads to episodes where the estima-
tion drifts away from the reference.
Computers 2022, 11, 165 15 of 23
The parts of the simulation range, where the friction coefficient shows the outliers,
correspond to phases with a low input excitation. In [33] it is demonstrated that, in these
passages the observability of the dynamical system decreases since the excitation is below a
necessary threshold. For the friction coefficient, this leads to episodes where the estimation
drifts away from the reference.
5. Conclusions
In this paper, a new embedded Kalman filter library is introduced. It was implemented
in C with the goal of performing state estimation on embedded systems, for example, in
the context of designing controllers for vehicle system dynamics. The library contains
different variants of nonlinear Kalman filters: the EKF-SR and the UKF-SR. The UKF-SR
provides the advantage of higher accuracy compared to the EKF-SR, whereas the EKF-
SR allows for a shorter execution time. The square-rooting (SR) variants increase the
numerical stability and provide a greater robustness compared to the base filters. During
implementation, an emphasis was placed on ensuring that the code complies widely with
the requirements for safety-critical applications in the automotive sector. The commonly
used programming language C is suitable for this purpose and was, therefore, chosen
for the new library. It also enables an easy integration into tool chains for embedded
systems. The MISRA C coding guidelines were also considered during the implementation.
Numerical computations required for the state estimation algorithms are partially based on
existing and well-established functions such as LAPACK routines, as they have already
proven their efficiency. All of these are newly implemented in C, yielding self-contained
software without the need for external libraries.
For execution on embedded systems, the real-time capability of the software is an-
other important factor, in addition to running in a 32-bit single precision configuration.
The library proved its real-time capability in two application examples for vehicle state
estimation. The two Kalman filter variants, the EKF-SR and the UKF-SR, were tested in two
Computers 2022, 11, 165 16 of 23
different scenarios. The vehicle models used in the respective cases comprise a nonlinear
quarter vehicle model and a nonlinear double-track model. In both cases, the code for the
model representations was generated through a modified eFMI export and then interfaced
to the model-specific functions of the library. The filter algorithms were integrated in two
different embedded systems. Code generation for the respective platforms was carried out
by means of TargetLink and Real-Time Interface. The underlying C code of the Kalman
filter library was incorporated into the executed production code as custom code.
The two scenarios were aimed at different purposes. First, it was shown that the
state estimator was able to provide reasonably good results under challenging real-time
conditions in a small-scale production series ECU within a vehicle in real-world driving
tests. In the second application, special emphasis was placed on the accuracy of the filter,
which was able to follow well the synthetically generated reference data on a rapid proto-
typing platform. In both examples, the embedded Kalman filter library was successfully
implemented on an embedded system using appropriate tool chains and it achieved good
results under real-time constraints.
The embedded Kalman filter library will be used in future internal research projects.
For common research projects with interested readers, the authors may be contacted.
Author Contributions: Conceptualization, C.S., A.P. and J.B.; methodology, C.S., A.P. and J.R.; library
software, C.S.; application software and data, C.S., A.P. and J.R.; validation, C.S., A.P. and J.R.; formal
analysis, C.S. and A.P.; investigation, C.S., A.P. and J.R.; visualization, C.S.; writing—original draft
preparation, C.S.; writing—review and editing, C.S., A.P., J.R. and J.B.; supervision, J.B. and A.P. All
authors have read and agreed to the published version of the manuscript.
Funding: This work was mainly funded by DLR internal projects. Parts of the work were funded
by the German Federal Ministry of Education and Research (grant number 01|S17023B) within the
European ITEA3 project EMPHYSIS (Embedded systems with physical models in the production
code software) under the project number 15016.
Data Availability Statement: Not applicable.
Acknowledgments: The authors’ thanks go to Dassault Systèmes for providing prototypical tools for
eFMI export and to Daniel Baumgartner for his support with the real-time tests.
Conflicts of Interest: The authors declare no conflict of interest.
Initialization:
x̂0+ = E(x0 )
T (A1)
P0+ = E x0 − x̂0+ x0 − x̂0+
For k = 1, 2, . . .
Predict:
x̂− +
k = fk |k −1 x̂k −1 , uk −1
(A2)
∂f
( ∂x |x̂+ · Ts )
P− + T (Jk−1 · Ts ) = e (A3)
k = Fk−1 Pk −1 Fk −1 + Q with Fk −1 = e
k −1
Correct:
−1
Kk = P− T − T
k Hk · Hk Pk Hk + R with Hk = ∂h ∂x x̂−
(A4)
k
− m − h x̂−
x̂+
k = x̂ k + K k · y k k
(A5)
−
P+k = (I − Kk · Hk ) · Pk
(A6)
The operator E(·) in the initialization phase determines the expectation value of the
specified variables [20]. Ts represents the sample time and Kk the Kalman gain. The
covariance matrices Q and R are defined by the user and they can be employed to adjust
the filter to the respective application. The matrix Q denotes the process noise covariance. It
evaluates the trust in the a priori estimation. The measurement noise covariance R reflects
the confidence in the measurements ym k . The matrix Fk −1 is the state transition matrix of
the function f with respect to x at the point x̂+ k −1 . It is computed by means of a matrix
exponential function evaluating the system state Jacobian Jk−1 . The latter can be calculated
numerically, if it is not available in analytical form. This can be carried out using a forward
difference quotient as follows:
For i = 1, 2, . . . , n x :
f(x̂k−1 +∆·ei ,uk−1 )−f(x̂k−1 ,uk−1 )
(Jk −1 ) i = ∆
(A7)
√
with ∆ ∼
= e
In this formula, n x denotes the number of states of the system and ei is the i-th
unit vector. The radicand e represents the respective machine precision of the employed
computer system. The output Jacobian matrix Hk of the function h with respect to x at the
point x̂−
k is computed analogous to the Jacobian Jk −1 with a forward difference quotient as
in (A7). Performing the steps in Table A1, the new estimated states vector x̂+
k is computed
using the results from the last sample time step and the current output measurement vector
ym
k . In Table A1, the model evaluation of the underlying system equations is necessary
for computing the Jacobians Jk−1 and Hk , h, and fk|k−1 , whereas the latter denotes the
integration from the last sample point to the new one; see Equation (3).
P+ T
k = Lk Lk (A8)
and the positive definiteness of the covariance matrix is easier to maintain. Furthermore, as
shown in [20], the square-root of a matrix has a condition number that is the square-root
of the condition number of the original matrix, which helps to improve the numerical
accuracy of the algorithm.
Parameter Description
α Spread of the sigma points around the current mean x̂
β Characteristic of the stochastic distribution
κ Scaling kurtosis of the sigma points
For the utilized approach of the unscented transformation a matrix X ∈ Rnx ×(2nx +1) is
created. It is composed of the 2n x + 1 sigma vectors representing the columns of the matrix.
These sigma vectors are calculated using the current mean x̂ and the covariance matrix P+ .
The formulas for the calculation of the vectors is shown in Table A3. It is related to [40].
Computers 2022, 11, 165 19 of 23
√
The expression P+ in these equations determines the matrix square-root of the
covariance matrix. Table A3 also specifies the scaling parameter γ, which depends
only on
√
the parameters of Table A2 and the dimension of the system states. The term γ · P +
i
denotes the ith column of the corresponding matrix.
The resulting sigma points are assigned with weights in the UKF algorithm. These
scalar weightings are summarized in Table A4, see also [20]. They depend on the parameters
in Table A2.
Weight Description
α2
λ = · (n x + κ ) − n x Scaling parameter
a = α2 · ( n x + κ ) Scaling parameter
w0m = λa Weight of unmodified mean prediction
c
w0 = a + 1 − α 2 + β
λ Weight of unmodified output mean prediction
1
wi = wic = 2a
m , i = 1, . . . , 2n x Weight of sigma points of states and outputs
With these prerequisites, the steps of the UKF algorithm can now be outlined. The
general structure of the UKF resembles the corresponding EKF algorithm setup in Table A1.
Its scheme is again composed of a predict and a correct step after an initialization, like in
Figure 1. The algorithm of the UKF is given as pseudo code in Table A5 and is based on [20].
Initialization:
x̂0+ = E(x0 )
T (A9)
P0+ = E x0 − x̂0+ x0 − x̂0+
For k = 1, 2, . . .
Predict: h q q i
+ +
Xk−1 = x̂+ k −1 , X̂ k − 1 + γ · P +
k −1 , X̂ k − 1 − γ · P +
k −1
(A10)
Xk | k −1 = fk | k −1 (Xk −1 , uk −1 ) (A11)
2· n x m
x̂−
k = ∑ i =0 wi · Xk | k −1 i +1
(A12)
T
P− = 2· n x c
∑ i =0 i w · X − x̂ −
X − x̂ −
+Q (A13)
k k | k −1 k k | k −1 k
q i +1 q ii+1
− −
h
X0k = x̂− k , X̂k + γ · P−k , X̂k − γ · P− k
(A14)
Yk = h X0k (A15)
2· n x m
ŷ−
k = ∑ i =0 wi · (Yk ) i +1
(A16)
Correct:
T
Pyk = ∑2i=·n0x wic · (Yk )i+1 − ŷ− (Yk )i+1 − ŷ−
+R (A17)
k k
2· n x c T
Px k y k = ∑ i = 0 w i · X k | k − 1 − x̂k (Yk )i+1 − ŷ−
−
k
(A18)
i +1
Kk = Pxk yk Py−k1 (A19)
− −
x̂+ m
k = x̂k + Kk · yk − ŷk
(A20)
−
P+ T
k = P k − K k · Py k · K k
(A21)
In the above notations, there are some expressions of a function with a matrix instead of
a vector as an argument, for example h X0k in (A15). This term corresponds to evaluating
Computers 2022, 11, 165 20 of 23
each column of the matrix separatelyh and returning thisi as a result, again in a matrix
representation. It is defined X̂k−1 := x̂+
+ + + n x ×n x in (A10) and X̂− :=
k −1 , x̂k −1 , . . . , x̂k −1 ∈ R k
− − −
n × n
x̂k , x̂k , . . . , x̂k ∈ R x x in (A14). The matrix square-roots of the covariance matrices
are calculated by means of Cholesky factorizations. The time and measurement update
equations comprise more calculations in the UKF, compared to the EKF, including the
evaluation of the sigma points. The concatenated matrix Xk−1 provides the sigma vectors
from Table A3. The following step in the pseudo code in (A11) represents the integration
performed 2n x + 1 times between the last sample point tk−1 and the new one tk . For this
purpose, for example, an Euler method can be applied and the sigma points serve as
disturbed state inputs for the integration. The set of scalars as determined in Table A4, is
employed in the calculations of x̂− − −
k , ŷk and Pk in the predict step, where weighted sums
are used. The matrices Q and R define again, as in the EKF, the respective covariances
for process and measurement noises. By tuning them, the trust in the measurements can
be stated.
√
− p c
−
CPk = LQ w1 · Xk|k−1 − x̂k , Q
i i =2:2·n x +1
(A22)
CP−k : = cholupdate CP −
k , X k | k −1 − x̂ −
k , w c
0
1
the lower triangular part of a matrix is incorporated [20]. In the next step of (A22), a rank
one update of the Cholesky factor is performed. It is assumed P = CPCPT . The notation
cholupdate(CP, v, ±1) calculates a lower triangular matrix CP∗ = CP ± vvT where the
positive definiteness of the matrix P∗ = CP∗ CP∗ T is guaranteed [20]. More details about
rank updates for Cholesky decompositions can be found in [24,27]. The second step in
(A22) is required because the weight w0c could be negative. These two operations in (A22)
perform the time update of the Cholesky factor; see also [19].
The same approach is utilized in the calculation of the Cholesky factor of the observa-
tion error covariance. The calculation of the matrix Pyk in (A17) in the correct step of the
UKF in Table A5 is thus replaced by the following two steps:
hp √ i
w1c · (Yk )i − ŷ−
CPyk = LQ k i =2:2·n x +1 , R (A23)
CPyk := cholupdate CPyk , (Yk )1 − ŷ− c
k , w0
These operations are similar to the corresponding steps in (A22). The evaluation of
the Kalman gain matrix Kk in (A19) is performed by the equation:
−1
Kk = Pxk yk · CPyk T CPyk (A24)
This can be solved efficiently using backward substitutions. The last adaptation of the
UKF algorithm concerns the last item of Table A5 where the measurement update of the
state covariance P+k is calculated in (A21). It is replaced by these operations:
U = Kk · CPyk
(A25)
CP+ CP−
k = cholupdate k , U, −1
To the former computed Cholesky factor CP− k , several consecutive Cholesky rank one
downdates are applied, see [19]. They are executed using the ny columns of the matrix U,
where ny denotes the dimension of the outputs of the system equations.
With these modifications of the UKF algorithm, the UKF-SR algorithm is adequately
described. The refactorization of the covariance matrices in each step can be omitted because
the decomposed Cholesky factors are propagated directly. Hence, the state covariance
matrices acquire the ensured property of positive semi-definiteness [19]. This advantage
promotes the improvement in numerical properties of the UKF-SR algorithm and provides
greater robustness to numerical instabilities in comparison to the UKF [20].
References
1. Haykin, S. Kalman Filtering and Neural Networks; John Wiley & Sons, Inc.: New York, NY, USA, 2001.
2. Karamta, M.R.; Jamnani, J.G. Implementation of extended kalman filter based dynamic state estimation on SMIB system
incorporating UPFC dynamics. Energy Procedia 2016, 100, 315–324. [CrossRef]
3. Li, J.-M.; Chen, C.W.; Cheng, T.-H. Estimation and Tracking of a Moving Target by Unmanned Aerial Vehicles. In Proceedings of
the American Control Conference (ACC), Philadelphia, PA, USA, 10–12 July 2019.
4. Wutke, M.; Heinrich, F.; Das, P.P.; Lange, A.; Gentz, M.; Traulsen, I.; Warns, F.K.; Schmitt, A.O.; Gültas, M. Detecting animal
contacts—A deep learning-based pig detection and tracking approach for the quantification of social contacts. Sensors 2021, 21, 7512.
[CrossRef] [PubMed]
5. Al Khatib, E.I.; Jaradat, M.A.; Abdel-Hafez, M.; Roigari, M. Multiple Sensor Fusion for Mobile Robot Localization and Navigation
Using the Extended Kalman Filter. In Proceedings of the 10th International Symposium on Mechatronics and Its Applications
(ISMA), Sharjah, United Arab Emirates, 8–10 December 2015.
6. Ullah, I.; Su, X.; Zhang, X.; Choi, D. Simultaneous localization and mapping based on Kalman filter and extended Kalman filter.
Wirel. Commun. Mob. Comput. 2020, 2020, 2138643. [CrossRef]
7. Fossen, S.; Fossen, T.I. Five-state extended Kalman filter for estimation of Speed over Ground (SOG), Course over Ground (COG)
and Course Rate of Unmanned Surface Vehicles (USVs): Experimental results. Sensors 2021, 21, 7910. [CrossRef] [PubMed]
8. Vergori, E.; Mocera, F.; Somà, A. Battery modelling and simulation using a programmable testing equipment. Computers 2018, 7, 20.
[CrossRef]
9. Colonnier, F.; della Vedova, L.; Orchard, G. ESPEE: Event-based sensor pose estimation using an extended Kalman filter. Sensors
2021, 21, 7840. [CrossRef] [PubMed]
Computers 2022, 11, 165 22 of 23
10. Ponte, S.; Ariante, G.; Papa, U.; del Core, G. An embedded platform for positioning and obstacle detection for small unmanned
aerial vehicles. Electronics 2020, 9, 1175. [CrossRef]
11. Fico, V.M.; Arribas, C.P.; Soaje, Á.R.; Prats, M.Á.M.; Utrera, S.R.; Vázquez, A.L.R.; Casquet, L.M.P. Implementing the Unscented
Kalman Filter on an Embedded System: A Lesson Learnt. In Proceedings of the IEEE International Conference on Industrial
Technology (ICIT), Seville, Spain, 17–19 March 2015.
12. EEKF—Embedded Extended Kalman Filter. 2015. Available online: https://github.com/dr-duplo/eekf (accessed on 4 October 2022).
13. Valade, A.; Acco, P.; Grabolosa, P.; Fourniols, J.-Y. A study about Kalman filters applied to embedded sensors. Sensors 2017, 17, 2810.
[CrossRef] [PubMed]
14. Rasmussen, T.B.; Yang, G.; Nielsen, A.H.; Dong, Z.Y. Implementation of a Simplified State Estimator for Wind Turbine Monitoring
on an Embedded System. In Proceedings of the 2017 Federated Conference on Computer Science and Information Systems,
Prague, Czech Republic, 3–6 September 2017; pp. 1167–1175.
15. Motor Industry Software Reliability Association. MISRA-C:2012. 2012. Available online: https://www.misra.org.uk/ (accessed
on 4 October 2022).
16. Bagnara, R.; Bagnara, A.; Hill, P.M. The MISRA C Coding Standard and Its Role in the Development and Analysis of Safety-
and Security-Critical Embedded Software. In Proceedings of the Static Analysis: The 25th International Symposium (SAS 2018),
Freiburg, Germany, 29–31 August 2018.
17. Anderson, E.; Bai, Z.; Bischof, C.; Blackford, L.S.; Demmel, J.; Dongarra, J.; Croz, J.D.; Greenbaum, A.; Hammarling, S.;
McKenney, A.; et al. LAPACK Users’ Guide, 3rd ed.; Society for Industrial and Applied Mathematics: Philadelphia, PA, USA, 1999.
18. Simon, D. Optimal State Estimation: Kalman, H Infinity, and Nonlinear Approaches; John Wiley & Sons, Inc.: Cleveland, OH, USA, 2006.
19. van der Merwe, R.; Wan, E.A. The Square-Root Unscented Kalman Filter for State and Parameter-Estimation. In Proceedings of
the IEEE International Conference on Acoustics, Speech, and Signal Processing, Salt Lake City, UT, USA, 7–11 May 2001.
20. Brembeck, J. Model Based Energy Management and State Estimation for the Robotic Electric Vehicle ROboMObil. Ph.D. Thesis,
Technische Universität München, Munich, Germany, 2018.
21. Kandepu, R.; Imsland, L.; Foss, B.A. Constrained State Estimation Using the Unscented Kalman Filter. In Proceedings of the 16th
Mediterranean Conference on Control and Automation, Ajaccio, France, 25–27 June 2008; pp. 1453–1458.
22. Brembeck, J. A physical model-based observer framework for nonlinear constrained state estimation applied to battery state
estimation. Sensors 2019, 19, 4402. [CrossRef] [PubMed]
23. Brembeck, J. Nonlinear constrained moving horizon estimation applied to vehicle position estimation. Sensors 2019, 19, 2276.
[CrossRef] [PubMed]
24. Golub, G.H.; Van Loan, C.F. Matrix Computations, 4th ed.; The Johns Hopkins University Press: Baltimore, MA, USA, 2013.
25. Modelica Association. Modelica Standard Library v4.0.0. 2020. Available online: https://github.com/modelica/ModelicaStanda
rdLibrary/releases/tag/v4.0.0 (accessed on 21 September 2022).
26. Netlib. LAPACK Documentation. 2022. Available online: http://www.netlib.org/lapack/explore-html/ (accessed on 4 October 2022).
27. Seeger, M. Low Rank Updates for the Cholesky Decomposition; Department of EECS, University of California at Berkeley: Berkeley,
CA, USA, 2008.
28. Ultsch, J.; Ruggaber, J.; Pfeiffer, A.; Schreppel, C.; Tobolář, J.; Brembeck, J.; Baumgartner, D. Advanced controller development
based on eFMI with applications to automotive vertical dynamics control. Actuators 2021, 10, 301. [CrossRef]
29. Lenord, O.; Otter, M.; Bürger, C.; Hussmann, M.; le Bihan, P.; Niere, J.; Pfeiffer, A.; Reicherdt, R.; Werther, K. eFMI: An Open
Standard for Physical Models in Embedded Software. In Proceedings of the 14th International Modelica Conference, Linköping,
Sweden, 20–24 September 2021.
30. Modelica Association. Modelica Language Specification 3.5. 2021. Available online: https://modelica.org/documents/MLS.pdf
(accessed on 23 September 2022).
31. dSPACE GmbH. TargetLink. 2022. Available online: https://www.dspace.com/en/pub/home/products/sw/pcgs/targetlink.c
fm (accessed on 6 September 2022).
32. Brembeck, J.; Ho, L.M.; Schaub, A.; Satzger, C.; Tobolar, J.; Bals, J.; Hirzinger, G. ROMO—The Robotic Electric Vehicle. In
Proceedings of the 22nd IAVSD International Symposium on Dynamics of Vehicle on Roads and Tracks, Manchester, UK,
11–14 August 2011.
33. Ruggaber, J.; Brembeck, J. A novel Kalman filter design and analysis method considering observability and dominance properties
of measurands applied to vehicle state estimation. Sensors 2021, 21, 4750. [CrossRef] [PubMed]
34. Joos, H.-D.; Bals, J.; Looye, G.; Schnepper, K.; Varga, A. A Multi-Objective Optimisation-Based Software Environment for Control
Systems Design. In Proceedings of the IEEE International Conference on Control Applications and International Symposium on
Computer Aided Control Systems Design, Glasgow, UK, 18–20 September 2002.
35. The MathWorks, Inc. Write Level-2 MATLAB S-Functions. 2022. Available online: https://de.mathworks.com/help/simulink/s
fg/writing-level-2-matlab-s-functions.html (accessed on 4 October 2022).
36. The MathWorks, Inc. Simulink. 2022. Available online: https://www.mathworks.com/products/simulink.html?s_tid=hp_ff_p_
simulink (accessed on 6 September 2022).
37. dSPACE GmbH. MicroAutoBox II. 2022. Available online: https://www.dspace.com/en/inc/home/products/hw/micautob/mi
croautobox2.cfm (accessed on 4 October 2022).
Computers 2022, 11, 165 23 of 23
38. dSPACE GmbH. Real-Time Interface (RTI). 2022. Available online: https://www.dspace.com/en/inc/home/products/sw/imp
sw/real-time-interface.cfm (accessed on 6 September 2022).
39. dSPACE GmbH. ControlDesk. 2022. Available online: https://www.dspace.com/en/pub/home/products/sw/experimentand
visualization/controldesk.cfm (accessed on 6 September 2022).
40. Wan, E.A.; van der Merwe, R. The Unscented Kalman Filter for Nonlinear Estimation. In Proceedings of the IEEE Symposium on
Adaptive Systems for Signal Processing, Communications, and Control, Lake Louise, AB, Canada, 4 October 2000.