Professional Documents
Culture Documents
State Estimation
Navigation of an unmanned vehicle, always depends on a good estimation of the vehicle states. Espe-
cially if no external sensors or markers are available, more or less complex algorithms have to be used.
For this project, the orientation estimation is done by the widely used Kalman filter. However, position
estimation is still an object of ongoing research. The here described approach uses the company own
software R ECONSTRUCT M E.
4.1 Orientation
With using Euler angles (Z − Y ′ − X ′′ ) between −π and π, it should also be taken care of potential
problems referring to the transition between maxima. For this project, Φ and Θ do not need special
treatment, as the robot is not expected to exceed the maxima, since this would mean that the thrust vector
is pointing to the ground. For the same reason the singularity at Θ = 90◦ of the used Euler angle
representation of the orientation is irrelevant. However, the Ψ angle can and will make this mentioned
maxima transition. This demands special treatment considering the calculation of e in the PID controller
in Fig. 3.2b. To compensate this overflow, a simple algorithm can be used:
1 i f ( eΨ > π )
2 Ψ −= 2π ;
3 e l s e i f ( eΨ < −π )
4 Ψ += 2π ;
xk+1 = Ak xk + wk (4.1)
z k = Hk x k + v k (4.2)
with zk ∈ Rm , if process noise wk and the measurement noise vk are assumed to be independent random
variables with Gaussian probability density functions and zero mean value. The normal probability
distributions p are then
2 , σ2 , . . . }
p(w) ∼ N (0, Q) , with Q = diag{σw1 w2 (4.3)
2 , σ2 , . . . }
p(v) ∼ N (0, R) , with R = diag{σv1 v2
with σ 2 being the variance of the corresponding noise distribution. The n×n matix Ak in (4.1) describes
the transition of the system between time step k and k + 1, in the absence of neither input nor process
27
4 State Estimation 4.1.1 Kalman Filter 28
noise. The m × n matrix H in the measurement equation (4.2) relates the state xk to the measurement zk .
The filter (in one popular algebraic form) consists of two stages. First, a prediction of the state x̂−
k at time
k, using the system dynamic matrix Ak−1 and state x̂k−1 in (4.1) from the last iteration k − 1. This will
be referred to as a priori estimation1 . Second, a correction of this estimation, using the measurements
zk . Using the a priori estimation x̂−
k in (4.2), an innovation variable (or residual) yk can be defined as
yk = zk − Hk x̂−
k. (4.4)
The innovation variable is used to correct the a priori prediction using the n × m gain matrix Kk
x̂k = x̂−
k + Kyk . (4.5)
This estimation is referred to as a posteriori estimation x̂k . The gain matrix Kk describes a blending
factor between the model based prediction, and the measurement. To achieve a readable description of
the optimal choice for Kk , the a priori and a posteriori estimate errors are defined as
e−
k ≡ xk − x̂−
k (4.6)
ek ≡ xk − x̂k
The core task of the Kalman filter, is to choose the gain matrix Kk so that the a posterioiri estimate error
covariance Pk is minimized with respect of the mean square error. For more details on that derivation
see [50]. One popular form of the resulting Kk that minimizes the a posteriori estimate error covariance
is the so called Kalman gain
T − T
−1
K k = P−
k Hk Hk P k Hk + R k . (4.8)
It can be seen, that the covariance Rk of the measurement noise defined in (4.3) and the a priori error
covariance P− k defined in (4.7) have direct influence on the optimal gain matrix Kk . To point out the
extreme cases, if Rk is zero meaning that the measurement is very trustworthy, the gain matrix becomes
lim Kk = H−1
k (4.9)
Rk →0
a posteriori correction
a priori prediction (1) Compute the Kalman gain
T H P− HT + R −1
(1) Project the state ahead K k = P− k H k k k k k
x̂−
k+1 = Ak x̂k (2) Update estimate with measurement zk
(2) Project the error covariance ahead x̂k = x̂−
k + K k z k − H x̂
k k
−
P− T
k+1 = Ak Pk Ak + Qk (3) Update the error covariance
Pk = (I − Kk Hk ) P− k
zk = h(xk , vk ) (4.13)
with the measurement vector zk ∈ Rm . By deriving the Jacobian matrix of the partial derivatives of f
and h with respect to the state vector xk and the noise vectors wk and vk
∂f (xk , wk ) T
Alin,k = (4.14a)
∂xk −
x̂k
T
∂f (xk , wk )
Wlin,k = (4.14b)
∂wk
x̂−
k
T
∂h(xk , vk )
Hlin,k = (4.14c)
∂xk
x̂−
k
T
∂h(xk , vk )
Vlin,k = , (4.14d)
∂vk
x̂−
k
the EKF is implemented as shown in Fig. 4.2. A detailed derivation can again be found in [52] and [50].
4 State Estimation 4.1.3 Orientation Estimation in Use 30
a priori prediction
(1) Project the state ahead
x̂−
k+1 = f (x̂k , 0)
(2) Project the error covariance ahead
P− T
k+1 = Alin,k Pk Alin,k + Wlin,k Qk Wlin,k
a posteriori correction
(1) Compute the Kalman gain
−1
K k = P− H T H P − T
H + V R V
k lin,k lin,k k lin,k lin,k k lin,k
(2) Update estimate with measurement zk
x̂k = x̂−
k + K k z k − h(x̂ −
k , 0)
(3) Update the error covariance
Pk = (I − Kk Hlin,k ) P− k
with the angular velocity of the quadcopter B ω IB = [ω x , ω y , ω z ]T , the estimated angular acceleration
T T
B ω̇ IB = [ω̇ x , ω̇ y , ω̇ z ] , the vector of the earth’s gravitation field B rg = [B rg,x ,B rg,y ,B rg,z ] and
T
the magnetic field vector B rm = [B rm,x ,B rm,y ,B rm,z ] . The available measurements are the angular
velocities B ω̄ IB from the gyroscopic sensors, the vector of gravitation B r̄g from the acceleration sensors2
and the vector of the magnetic field of the earth B r̄m directly from the magnetic sensors on the IMU. Note
that all variables are described in the body fixed coordinate system (compare chapter 2.2.1). To simplify
notation, the left side index B will be omitted in the following explanation and if no other coordinate
index is given, the variable shall be referred with respect to the body fixed system.
For the two equations needed for the algorithm shown in Fig. 4.2, the matrices Alin,k and Wlin,k , as
shown in (4.14a) and (4.14b), are the calculated Jacobi matrices3
I I∆t 0 0
∂f (xk , wk )
0 I 0 0
Alin,k = =
− −e (4.19a)
∂xk x̂k
ra,k ∆t 0 I+ω e k ∆t 0
−e
rm,k ∆t 0 0 I+ω e k ∆t
I 0 0 0
∂f (xk , wk ) 0 I 0 0
Wlin,k = =
0
. (4.19b)
∂wk x̂−
0 I 0
k
0 0 0 I
The implemented formulas for the a priori prediction step at time k + 1 are
x̂−
k+1 = f (x̂k , 0) (4.20)
where the measurement noise matrix Qk holds the variances σ 2 of the states as diagonal entries. They
represent the uncertainty of the prediction. As this variances are unknown and can not be measured, they
act as tuning variables for the filter.
3
ab = −e
Note the cross product is anticommutative: e ba in line 3 and 4 of matrix definition Alin,k
4 State Estimation 4.1.3 Orientation Estimation in Use 32
Thus, the linear observation matrix H is already given, and also the Jacobian matrix from (4.14d), lin-
earizing the influence of the measurement noise R, degenerates to a identity matrix I. The implemented
functions for the correction step as listed in Fig. 4.2 are directly given with the Kalman gain
T − T
−1
K k = P−
k Hk Hk P k Hk + R k , (4.23)
Pk = (I − Kk Hk ) P−
k. (4.25)
For the first iteration, initial values for the first a posteriori have to be chosen. The first estimation x̂k is
initialized with measurements
B ω IB B ω̄ IB
B ω̇ IB 0
x̂k,init =
B ra
=
B r̄g
. (4.26)
The first error covariance is initialized4 with Pk,init = 100I. Over time, the chosen initial value of the
error covariance matrix does not have any influence, as it will converge, as long as it is not initialized
with equal to 0.
in case of gyroscope and a magnetometer measurements. The remaining formalism (4.23) to (4.25)
remains the same. Subsequently, only the states for which measurements are available will be corrected.
4
I is the identity matrix
4 State Estimation 4.2 Position 33
The three base vectors are extracted from the estimated acceleration vector B r̂a and the estimated mag-
netic field vector B r̂m . Note, that a NED inertial coordinate system is used. As mentioned above, by
neglecting the translational acceleration of the robot over the gravity field, the base vector in z-direction
is given by5
B ra
B eIz = − . (4.31)
kB ra k2
This estimation is especially accurate if the copter is hovering. Furthermore, the inertial system can
always be chosen in a way that the base vector in x direction corresponds with the magnetic field of
the earth. However, as the estimation will never be accurate, this vector is not directly taken to derive
B rIx . Rather to preserve orthogonality of the inertial system, it is used to calculate the base vector in
y-direction
B eI z × B r m
B eI y = . (4.32)
kB eIz × B rm k2
Given two base vectors, the third one can always be calculated for an orthogonal system:
B eI y × B eI z
B eI x = . (4.33)
kB eIy × B eIz k2
4.2 Position
Initial experiments were done using the PX4FLOW module [6]. It is a flow sensor module based on
low-cost components. See chapter 5.3.3 for a more detailed description of the module.To gather veloc-
ity information in x- and y direction, an optical flow estimation is done based on the sum of absolute
differences (SAD) block matching algorithm with angular rate compensation using the gyroscope mea-
surement [33]. The sensor module further delivers height measurement using a sonar sensor.
However, the results of using the PX4FLOW as a standalone position estimation by integrating the mea-
surements, were not very satisfying due to an unacceptable drift. For now, the position estimation process
is only based on the software R ECONSTRUCT M E [37]. Unlike common SLAM algorihms such as Davi-
son’s MonoSLAM [30] or Klein and Murray’s PTAM [36], the here used approach does create real
surfaces instead of than only dense maps.
4.2.1 ReconstructMe
The software R ECONSTRUCT M E that is used for position estimation, is developed by the company
P ROFACTOR in Steyr (Austria). It is a portable, low-cost 3D body scanning system [37]. It works with
publicly available low-cost active technology, such as the here used P RIME S ENSE C ARMINE 1.09 [5].
The algorithms are processed on decent standard computer hardware, which is designed for accelerated
processing (e.g. general purpose computation on graphics processing unit (GPGPU)). The sensor uses
the approach of structured light for depth calculation [35]. To do so, a constant pattern of speckles is
projected onto the scene by splitting up a laser beam via a diffraction grid. This pattern is captured by a
rP
5
To provide the normalized unit base vectors, the 2-Norm kvk2 = vi2 is used.
i