Tài liệu Lọc Kalman - lý thuyết và thực hành bằng cách sử dụng MATLAB (P7) - Pdf 10

7
Practical Considerations
``The time has come,'' the Walrus said,
``To talk of many things:
Of shoesÐand shipsÐand sealing waxÐ
Of cabbagesÐand kingsÐ
And why the sea is boiling hotÐ
And whether pigs have wings.''
From ``The Walrus and the Carpenter,'' in Through the Looking Glass, 1872
Lewis Carroll [Charles Lutwidge Dodgson] (1832±1898)
7.1 CHAPTER FOCUS
The discussion turns now to what might be called Kalman ®lter engineering, which
is that body of applicable knowledge that has evolved through practical experience
in the use and misuse of the Kalman ®lter. The material of the previous two chapters
(extended Kalman ®ltering and square-root ®ltering) has also evolved in this way
and is part of the same general subject. Here, however, the discussion includes many
more matters of practice than nonlinearities and ®nite-precision arithmetic.
7.1.1 Main Points to Be Covered
1. Roundoff errors are not the only causes for the failure of the Kalman ®lter to
achieve its theoretical performance. There are diagnostic methods for identi-
fying causes and remedies for other common patterns of misbehavior.
2. Pre®ltering to reduce computational requirements. If the dynamics of the
measured variables are ``slow'' relative to the sampling rate, then a simple
pre®lter can reduce the overall computational requirements without sacri®cing
performance.
270
Kalman Filtering: Theory and Practice Using MATLAB, Second Edition,
Mohinder S. Grewal, Angus P. Andrews
Copyright # 2001 John Wiley & Sons, Inc.
ISBNs: 0-471-39254-5 (Hardback); 0-471-26638-8 (Electronic)
3. Detection and rejection of anomalous sensor data. The inverse of the matrix

7.2 DETECTING AND CORRECTING ANOMALOUS BEHAVIOR
7.2.1 Convergence, Divergence, and ``Failure to Converge''
De®nitions of Convergence and Divergence. A sequence Z
k
k  1; 2; 3; 
of real vectors Z
k
is said to converge to a limit Z

if, for every e > 0, for some n, for all
k > n, the norm of the differences Z
k
 Z

 < e. Let us use the expressions
lim
k
Z
k
 Z

or Z
k
 Z

to represent convergence. One vector sequence is said to converge to another vector
sequence if their differences converge to the zero vector, and a sequence is said to
converge
1
if, for every e > 0, for some integer n, for all k;`> n, Z

x
k
; the estimated state;
~
x
k
 
^
x
k
 x
k
; the a priori estimation error;
~
x
k
 
^
x
k
 x
k
; the a posteriori estimation error;
P
k
; the covariance of a priori estimation errors;
P
k
; the covariance of a posteriori estimation errors.
One may also be interested in whether or not the sequences P

deemed to differ signi®cantly from its expected value (as computed by the Riccati
equation), the ®lter is said to diverge from its predicted performance. We will now
consider how one might go about detecting divergence.
Examples of typical behaviors of Kalman ®lters are shown in Figure 7.1, which is
a multiplot of the estimation errors on 10 different simulations of a ®lter imple-
mentation with independent pseudorandom-error sequences. Note that each time the
®lter is run, different estimation errors
~
xt result, even with the same initial
condition
^
x0: Also note that at any particular time the average estimation error
(across the ensemble of simulations) is approximately zero,
1
N

N
i1

^
x
i
t
k
xt
k
 
E
i
^

t
traceP
sub-opt
 P
opt
  0; 7:2
Fig. 7.1 Dispersion of multiple runs.
7.2 DETECTING AND CORRECTING ANOMALOUS BEHAVIOR 273
and the asymptotic estimation error is unbiased,
lim
t
E
~
xt  0: 7:3
Example 7.1: Some typical behavior patterns of suboptimal ®lter convergence are
depicted by the plots of Pt in Figure 7.2a, and characteristics of systems with these
symptoms are given here as examples.
Case A: Let a scalar continuous system equation be given by
_
xtFxt; F > 0; 7:4
in which the system is unstable, or
_
xtFxtwt7:5
in which the system has driving noise and is unstable.
Case B: The system has constant steady-state uncertainty:
lim
t
_
Pt0: 7:6
Case C: The system is stable and has no driving noise:

_
xtFxtwt; F < 0;
ztxtvt;
is shown in Figure 7.2c.
The following features may be observed in the behavior of Pt:
1. Processing the measurement tends to reduce P:
2. Process noise covariance Q tends to increase P:
3. Damping in a stable system tends to reduce P:
4. Unstable system dynamics F > 0 tend to increase P:
5. With white Gaussian measurement noise, the time between samples T can be
reduced to decrease P:
The behavior of P represents a composite of all these effects (1±5) as shown in
Figure 7.2c.
Causes of Predicted Nonconvergence. Nonconvergence of P predicted by
the Riccati equation can be caused by
1. ``natural behavior'' of the dynamic equations or
2. nonobservability with the given measurements.
The following examples illustrate these behavioral patterns.
Example 7.4: The ``natural behavior'' for P in some cases is for
lim
t
PtP

(a constant): 7:8
For example,
_
x  w; covwQ
z  x  v; covvR
I
e

R
or
_
P  Q 
P
2
R
:
The solution is
Pta
P
0
cosh bta sinh bt
P
0
sinh bta cosh bt

; 7:10
where
a 

RQ
p
; b 

Q=R
p
: 7:11
Note that the solution of the Riccati equation converges to a ®nite limit:
1. lim

with initial conditions
P
0

s
2
1
0
0 s
2
2
45

P
11
0 0
0 P
22
0
45
: 7:14
The continuous Kalman ®lter equations
_
P  FP  PF
T
 GQG
T
 KRK
T
;

12
p
22
R
;
_
p
22

p
2
22
R
; 7:16
the solution to which is
p
11
tp
11
0Qt; p
12
t0; p
22
t
p
22
0
1  p
22
0=R

s
2
1
0 0
0 s
2
2
0
!
; H 11;
z  H
x
1
x
2
!
 v; covvR;
7:19
in which only the sum of the two state variables is measurable. The difference of the
two state variables will then be unobservable.
Problem in discrete time. This example also illustrates a dif®culty with a
standard shorthand notation for discrete-time dynamic systems: the practice of
using subscripts to indicate discrete time. Subscripts are more commonly used to
indicate components of vectors. The solution here is to move the component indices
``upstairs'' and make them superscripts. (This approach only works here because the
problem is linear. Therefore, one does not need superscripts to indicate powers of the
components.) For these purposes, let x
i
k
denote the ith component of the state vector

2
k
45
 v
k:
7:22
Let
^
x
0
 0:
The estimator then has two sources of information from which to form an optimal
estimate of x
k
:
1. the a priori information in
^
x
0
and P
0
and
2. the measurement sequence z
k
 x
1
k
 x
2
k

1
, one
can obtain the gain in the form
K
1

s
2
1
0
s
2
1
0s
2
2
0R
s
2
2
0
s
2
1
0s
2
2
0R
P
T

s
2
1
0s
2
2
0
s
2
1
0s
2
2
0R
s
2
1
0s
2
2
0
s
2
1
0s
2
2
0R
s
2

p
12
p
12
p
22
45
; 7:25
where the correlation coef®cient (de®ned in Equation 3.138) is
r
12

p
12

p
11
p
22


s
2
1
0s
2
2
0

s

z
1
 H
^
x
1
0  I  K
1
H
^
x
1
0K
1
z
1
: 7:27
However, for the noise-free case,
v
1
 0; R  covv
1
0;
the correlation coef®cient is
r
12
1; 7:28
and the estimates for
^
x

1

s
2
2
0
s
2
1
0s
2
2
0

x
1
1
 x
2
1
ÀÁ
;
are totally insensitive to the difference x
1
1
 x
2
1
. As a consequence, the ®lter will
almost never get the right answer! This is a fundamental characteristic of the

x
2
1
x
1
1
7:30
will also be a constant, such that the sum
x
1
1
 x
2
1
1  Cx
1
1

1 C
C

x
2
1
:
Then
^
x
1
1

2
0
 1;
^
x
2
1

s
2
2
0
s
2
1
0s
2
2
0

1 C
C

x
2
1
 x
2
1
only if

2
1
0 and s
2
2
0 are nonnegative numbers.
Likelihood of serendipitous design. For the ®lter to obtain the right answer, it
would be necessary that
1. x
1
1
and x
2
1
have the same sign and
2. it is known that their ratio C  x
2
1
=x
1
1
.
Since both of these conditions are rarely satis®ed, the ®lter estimates would rarely be
correct.
What can be done about it. The following methods can be used to detect
nonconvergence due to this type of structural unobservability:
 Test the system for observability using the ``observability theorems'' of Section
2.5.
 Look for perfect correlation coef®cients (r 1) and be very suspicious of
high correlation coef®cients (e.g., r > 0:9).

2
k
 x
2
k1
; H
k
 HkT; z
k
 H
k
x
1
k
;
x
2
k
45
 v
k
;
where T is the intersample interval.
What happens when Murphy's law takes effect. With the choice of intersampling
interval as T  2p=o and t
k
 kT; the components of the measurement sensitivity
matrix become equal and constant:
H
k

is a better choice.
Causes of unpredicted nonconvergence. Unpredictable nonconvergence may be
caused by
1. bad data,
2. numerical problems, or
3. mismodeling.
Example 7.8: Unpredicted Nonconvergence Due to Bad Data ``Bad data'' are
caused by something going wrong, which is almost sure to happen in real-world
applications of Kalman ®ltering. These veri®cations of Murphy's law occur princi-
pally in two forms:
 The initial estimate is badly chosen, for example,

^
x0x
2

~
x
2
 trace P
0
: 7:33
 The measurement has an exogenous component (a mistake, not an error) that is
excessively large, for example,
v
2
 trace R: 7:34
Asymptotic recovery from bad data. In either case, if the system is truly linear, the
Kalman ®lter will (in theory) recover in ®nite time as it continues to use measure-
ments z

handler'' (often a human, but sometimes a second-level data analysis program) to
locate and remedy the causes of the bad data that are occurring.
Arti®cially increasing process noise covariance to improve bad data recovery.If
bad data are detected after they have been used, one can keep the ®lter ``alive'' (to
pay more attention to subsequent data) by increasing the process noise covariance Q
in the system model assumed by the ®lter. Ideally, the new process noise covariance
should re¯ect the actual measurement error covariance, including the bad data as
well as other random noise.
^
Fig. 7.6 Failure to recover in short period.
^
()t
Fig. 7.7 Failure to recover due to gain decay.
7.2 DETECTING AND CORRECTING ANOMALOUS BEHAVIOR 283
Example 7.9: Nonconvergence Due to Numerical Problems This is sometimes
detected by observing impossible P
k
behavior. The terms on the main diagonal of P
k
may become negative, or larger, immediately after a measurement is processed than
immediately before, that is, s > s. A less obvious (but detectable) failure
mode is for the characteristic values of P to become negative. This can be detected
by eigenvalue±eigenvector decomposition of P. Other means of detection include
using simulation (with known states) to compare estimation errors with their
estimated covariances. One can also use double precision in place of single precision
to detect differences due to precision. Causes of numerical problems can sometimes
be traced to inadequate wordlength (precision) of the host computer. These problems
tend to become worse with larger numbers of state variables.
Remedies for numerical problems. These problems have been treated by many
``brute-force'' methods, such as using higher precision (e.g., double instead of

Example 7.10: Nonconvergence Caused by Unmodeled State Variables Consi-
der the following example:
284 PRACTICAL CONSIDERATIONS
Real World (Creeping State) Kalman Filter Model (Constant State)
_
x
1
 0
_
x
2
 0
_
x
2
 x
1
z  x
2
 v
z  x
2
 v
 x
2
tx
2
0x
1
0t  x

^
x
k
) can be useful for spotting characteristic frequencies of
the unmodeled state dynamics. If the ®lter is modeled properly, then the innovations
should be uncorrelated, having a power spectral density (PSD) that is essentially ¯at.
Persistent peaks in the PSD would indicate the characteristic frequencies of
unmodeled effects. These peaks can be at zero frequency, which would indicate a
bias error in the innovations.
Remedies for unmodeled state variables. The best cure for nonconvergence
caused by unmodeled states is to correct the model, but this not always easy to
do. As an ad hoc ®x, additional ``®ctitious'' process noise can be added to the system
model assumed by the Kalman ®lter.
Example 7.11: Adding ``Fictitious'' Process Noise to the Kalman Filter
Model Continuing with the continuous-time problem of Example 7.10, consider
the alternative Kalman ®lter model
_
x
2
twt; ztx
2
tvt:
``Type-1 servo'' behavior. The behavior of this ®lter can be analyzed by applying
the continuous Kalman ®lter equations from Chapter 4, with parameters
F  0; H  1; G  1;
~
()t
^
Fig. 7.8 Divergence due to mismodeling.
7.2 DETECTING AND CORRECTING ANOMALOUS BEHAVIOR 285

R
r
: 7:36
The equivalent steady-state model of the Kalman ®lter can now be formulated as
follows
2
:
_
^
x
2
 F
^
x
2
 Kz  H
^
x
2
: 7:37
Here, F  0; H  1;
K  K;
^
x 
^
x
2
, so that
_
^

tx
2
0x
1
0t with v  0:
Taking the Laplace transform of the equation yields
zsx
2
s
x
2
0
s

x
1
0
s
2
:
2
This steady-state form is the Wiener ®lter discussed in Chapter 4.
286 PRACTICAL CONSIDERATIONS
The error in x
2
t is
~
x
2
t

2
s:
Applying the ®nal-value theorem, one gets
~
x
2
 
^
x
2
 x
2

ÂÃ
 lim
s0
s
^
x
2
sx
2
s
ÂÃ
 lim
s0
s 
s
s 
K

If the steady-state bias in the estimation error is unsatisfactory with the approach
in Example 7.11, one can go one step further by adding another state variable and
®ctitious process noise to the system model assumed by the Kalman ®lter.
Example 7.12: Effects of Adding States and Process Noise to the Kalman Filter
Model Suppose that the model of Example 7.11 was modi®ed to the following
^
^
^
Fig. 7.9 Type 1 servo (a) and estimates (b).
7.2 DETECTING AND CORRECTING ANOMALOUS BEHAVIOR 287
form:
Real World
_
x
1
 0
_
x
2
 x
1
z  x
2
 v
Kalman Filter Model
_
x
1
 w
_

T
 PH
T
R
1
HP and K  PH
T
R
1
7:43
become in the steady state
_
p
11
 Q 
p
2
12
R
 0
_
p
12
 p
11

p
12
p
22

12
 

RQ

;
p
22
 

2

R
3
Q
1=4
;
p
11
 

2

Q
3
R
1=4
;
K 


7:44
and these can be Laplace transformed to yield
^
xssI F 
KH
1
Kzs: 7:45
^
^
^
Fig. 7.10 Type 2 servo (a) and servo estimates (b).
288 PRACTICAL CONSIDERATIONS
In component form, this becomes:
^
x
2
s
K
2
s K
1
=s
2
1 K
2
s K
1
=s
2
zs: 7:46

s;
~
x
2
  lim
s0
s
s
2
s
2
 K
2
s K
1

x
2
0
s

x
1
0
s
2

 0:
This type of behavior is shown in Figure 7.10b.
Example 7.13: Statistical Modeling Errors Due to Unmodeled System Driving


1
R
p
2
12
_
p
12
 p
11

p
12
p
22
R
_
p
22
 2p
12

p
2
22
R
W
b
b

^
x
2
 ramp:
7:48
Since x
1
is not constant (due to the driving noise w), the state estimates will not
converge to the states, as illustrated in the simulated case plotted in Figure 7.11. This
®gure shows the behavior of the Kalman gain
K
1
, the estimated state component
^
x
1
,
and the ``true'' state component x
1
in a discrete-time simulation of the above model.
Because the assumed process noise is zero, the Kalman ®lter gain
K
1
converges to
zero. Because the gain converges to zero, the ®lter is unable to track the errant state
vector component x
1
, a random-walk process. Because the ®lter is unable to track the
true state, the innovations (the difference between the predicted measurement and the
actual measurement) continue to grow without bound. Even though the gains are

2
45
 0
z sin Otcos Ot
x
1
x
2
45
 v
v  white noise
No a priori information exists
Kalman Filter Model
_
x
1
_
x
2
45
 0
z sin otcos ot
x
1
x
2
45
 v
v  white noise
No a priori information exists


T
0
H
T
H
^
x dt; 7:51
where
^
x is unknown but constant. Therefore,
^
x 

T
0
H
T
Hdt
!
1

T
0
H
T
zdt
!
; 7:52
where

1

Np
0
sinotztdt

Np
0
cosotztdt
P
T
T
T
R
Q
U
U
U
S

2
Np

Np
0
ztsin otdt
2
Np

Np





tNp
t0
@A
x
1

2
Np
coso Ot
2o O

coso Ot
2o O
!




tNp
t0
@A
x
2

2
Np

2o O
!
x
2
:
For the case that o  O,
sino ONp
2o O

Np
2
sin x
x




x0

Np
2
;
sino ONp
2o O

sin 4p=pNp
2O
 0;
1 coso ONp
2o O

 U
1
x
1
 U
2
x
2
; where U
1
 1; U
2
 0: 7:57
Similar behavior occurs with
^
x
2
.
Wrong parameters in the system and=or output matrices may not cause the ®lter
covariance matrix or state vector to look unusual. However, the innovations vector
z H
^
x will generally show detectable effects of nonconvergence.
This can only be cured by making sure that the right parameter values are used in
the ®lter model. In the real world, this is often impossible to do precisely, since the
``right'' values are not known and can only be estimated. If the amount of
degradation obtained is unacceptable, consider letting the questionable parameters
become state variables to be estimated by extended (linearized nonlinear) ®ltering.
Example 7.15: Parameter Estimation This reformulation provides an example of
a nonlinear estimation problem:

~
x
3
0a measure of uncertainty in
~
x
3
0:
Nonlinearities in the real-world system also cause nonconvergence or even diver-
gence of the Kalman estimates.
7.2.5 Analysis and Repair of Covariance Matrices
Covariance matrices must be nonnegative de®nite. By de®nition, their characteristic
values must be nonnegative. However, if any of them are theoretically zeroÐor even
close to zeroÐthen there is always the risk that roundoff will cause some roots to
become negative. If roundoff errors should produce an inde®nite covariance matrix
(i.e., one with both positive and negative characteristic values), then there is a way to
replace it with a ``nearby'' nonnegative-de®nite matrix.
Testing for Positive De®niteness. Checks that can be made for the de®nite-
ness of a symmetric matrix P include the following:
 If a diagonal element a
ii
< 0, then the matrix is not positive de®nite, but the
matrix can have all positive diagonal elements and still fail to be positive
de®nite.
 If Cholesky decomposition P  CC
T
fails due to a negative argument in a
square root, the matrix is inde®nite, or at least close enough to being inde®nite
that roundoff errors cause the test to fail.
 If modi®ed Cholesky decomposition P  UDU

R
Q
U
U
S
1000; 100; 1
343:388 248:976 320:22
248:976 337:245 369:744
320:22 369:744 419:367
P
T
T
R
Q
U
U
S
1: 0:731631 0:843837
0:731631 1: 0:983178
0:843837 0:983178 1:
P
T
T
R
Q
U
U
S
1000; 100; 0
Repair of inde®nite covariance matrices. The symmetric eigenvalue±eigenvector

 TD

T
T
; 7:63
D

 diag
i
d

i
ÈÉ
; 7:64
d

i

d
i
if d
i
 0;
0ifd
i
< 0:
V
`
X
7:65


Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status