You are on page 1of 11

Team 18: The Kalman Filter Learning Tool Dynamic and Measurement Models

Greg Welch Monday, February 17, 2003 1:49 pm

UNC-Chapel Hill, COMP 145

1. DYNAMIC (PROCESS) MODELS We allow the dynamic model of the water level, also known as the process model, to be modled as the sum of three possible components: a constant component, a steadily increasing or decreasing component, and a sinusoidal component. The simplest model would consist of the constant component alone; the most complicated would consist of the combination (sum) of all three. In any case, the primary element of the state of the system is the water level L as shown in Figure 5. We represent the true state of the system as x and the estimated state as x . The estimated process covariance is P , and the process noise (covariance) matrix is Q . The state and the covariance matrices are all the same dimension, with the dimensionality depending on the specic combination of dynamic components.

1.1.3 Sloshing (Sinusoidal) In this case the water level is changing as sinusoidal function of time. In other words, L ( t ) = k s sin ( t + ) and d L ( t ) = k s cos ( t + ) . dt

1.1.2 Filling (Steady Increase) In this case the water level is increasing or decreasing at a constant rate r . In other words, d L(t ) = r dt for some r > 0 .

1.1.1 Constant In this case, the water level L does not change. In other words, L(t ) = c for some constant c .

1.1 Actual Dynamics (Truth) Here we look at the three components of the actual water level dynamics in the most fundamental forms. The actual water level would be modeled as summed combinations of these components. The valid combinations are the same as those in Section 1.2, where I cover the modeled (Kalman lter) formulations. (1)

(2)

(3)

1.2 The Models (Kalman Filter) Here I describe the nite set of possible KF (and EKF) models that we will use. Each combination would have a corresponding truth signal that could be generated using the models in Section 1.1, however of course the user will be able to select combinations of actual and modeled dynamics that do not match. 1.2.1 Constant In this case the estimated state would have only one element, i.e. it would be the scalar water level, simply x L L . The continuous time process model is depicted in Figure 1.

Because the level is modeled as constant, the continuous time state transition matrix would be simply A c = 0 and the continuous time process noise matrix would be Q c = q c . The

1.2.2 Filling In this case the estimated state would have two elements, the current water level x L L and the water ll rate, dx L . dt as in (2). The continuous time process model is depicted in Figure 2. f

corresponding discrete time state transition matrix is A ( t ) = 1 , and from (17) the discrete time process noise matrix would be Q ( t ) = q c t , where 0 < q c F for the full water level F . The time update equations are simply x+( t + t ) = x( t ) and P+( t + t ) = A( t )P( t ) AT ( t ) + Q( t ) = P(t ) + qt

Figure 1: Constant level process model.

xL

c ~N ( 0, q c )

Figure 2: Filling process model.

xr

xr

xL

f ~N ( 0, q f )

The overall state is then

x =

xL xr

The continuous time state transition matrix is

and the continuous time process noise matrix is Q =

A = 01 00 0 0 . 0 qf

The discrete time state transition matrix is

and from (17) the discrete time process noise matrix is

A ( t ) = 1 t 0 1

(4)

where 0 < q f F , for the full water level F . The lter update equations are the usual linear Kalman lter equations: x + ( t + t ) = A ( t )x ( t ) and P + ( t + t ) = A ( t )P ( t ) A T ( t ) + Q ( t )

q f t 3 q f t 2 ------------- ------------3 2 Q ( t ) = q f t 2 ------------- q f t 2

(5)

1.2.3 Sloshing In this case the estimated state would have two elements, the current water level x L L and the magnitude of the sinusoidal component x s k s for some constant k s . The continuous time process model is depicted in Figure 3. s

s ~N ( 0, q s )

xs

ks

cos ( t + )

Figure 3: Sloshing process model. In state form we have,

xL

The present water level would be modeled as function of both the previous level and the changing sinusoidal components. For the sake of simplicity we will assume that is known and = 0 . We model the new state x at time t + t as x L ( t + t ) = x L ( t ) + x s ( t ) cos ( t ) x s ( t + t ) = x s ( t ) .

x =

xL xs

The continuous time state transition matrix is

and the continuous time process noise matrix is Q =

A = 0 cos ( t ) 0 0 0 0 . 0 qs (6)

The discrete time state transition matrix is

and from (17) the discrete time process noise matrix is

A ( t ) = 1 cos ( t ) 0 1

1.2.4 Filling + Sloshing In this case the estimated state would have three elements, the present water level x L L , the magnitude of the sinusoidal component x s k s , and the water ll rate, dx L . dt The continuous time process model is depicted in Figure 4. s

q s 2 t ( 3t 2 + 3tt + t 2 ) q s t ----------------------------------------------------------- ---------------3 2 Q ( t, t ) = q s t ---------------q s t 2 where = cos ( t ) , = 2t + t , and 0 < q s F , for the full water level F . The lter update equations are the usual linear Kalman lter equations: x + ( t + t ) = A ( t )x ( t ) and P + ( t + t ) = A ( t )P ( t ) A T ( t ) + Q ( t )

(7)

xr

xs

f ~N ( 0, q f )

s ~N ( 0, q s )

ks

cos ( t + ) f

Figure 4: Filling + sloshing process model.

xr

xL

In state form we have, x =

xL xs

xr .

The present water level would be modeled as function of the previous level, the ll rate, and the changing sinusoidal components. Again for the sake of simplicity we will assume that is known and = 0 . We model the new state x at time t + t as x L ( t + t ) = x L ( t ) + t x r ( t ) + x s ( t ) cos ( t ) x r ( t + t ) = x r ( t ) x s ( t + t ) = x s ( t ) .

The continuous time state transition matrix is

and the continuous time process noise matrix is

0 1 cos ( t ) A = 00 0 00 0 0 0 0 Q = 0 qf 0 . 0 0 qs

So the discrete time state transition matrix is

and from (17) the discrete time process noise matrix is

1 t cos ( t ) A ( t ) = 0 1 0 0 0 1

(8)

t ( 3t 2 + 3tt + t 2 ) ( q f + q s 2 ) q f t q s t ---------------------------------------------------------------------------- -------------- ---------------3 2 2 q f t Q ( t, t ) = -------------q f t 0 2 q s t ---------------0 q s t 2

(9)

where = cos ( t ) , = 2t + t , and 0 < q f , q s F , for the full water level F . The lter update equations are the usual linear Kalman lter equations: x + ( t + t ) = A ( t )x ( t ) and P + ( t + t ) = A ( t )P ( t ) A T ( t ) + Q ( t )

2. MEASUREMENT MODELS To determine the measurement models we need to determine (specify in this case) the mechanical and electrical characteristics of the actual system. The following schematic diagram will be used to identify variables in the measurement equations.

water

float

tank

measurement z L

Figure 5: The two possible measurement methods. Left: the system returns a noisy voltage z representing the height of the oat. Right: system returns a noisy voltage z representing the angle between the xed base segment d b and the pivoting oat segment d f .

Level (Linear)

db

df

2.1 Level (Linear) In the simplest case, the system returns a noisy voltage z representing the height of the oat, which is proportional to (i.e. a linear function of) the water level L . In other words, z L = --kl where k l is some a priori known constant scale factor. By solving this linear expression for z we obtain a linear model of the measurement: z = klL . In more general notation, we model the measurement z as a linear function of the system state x , z = Hx where the hats on z and x reect the notion that they are estimates of the actual measurement and state.

{
Angle (Non-Linear)
measurement z

If we use a one-dimensional state x to estimate the water level L , the measurement matrix is simply H = kl . (10) If we use a two-dimensional state x to estimate the water level L , and the estimate of the water level is in the rst position/element of the state, the measurement matrix is Finally if we use a three-dimensional state to estimate the water level L , and the estimate of the water level is in the rst position/element of the state, the measurement matrix is H = kl 0 0 . H = kl 0 . (11)

where k a is some a priori known constant scale factor. Bysolving this non-linear expression for z we obtain a non-linear model of the measurement: db L z = k a asin -------------- . df Again in more general notation, we model the measurement z as a non-linear function of the system state x , z = h( x) where

2.2 Angle (Non-Linear) In this case the system returns a noisy voltage z representing the angle between the xed base segment d b and the pivoting oat segment d f . The water level L is a non-linear function of this angle as follows. z L = d b d f sin ---- k a

In the actual lter, either (10), (11), or (12) would be used to both for measurement prediction and in the Kalman gain equation. Which of (10), (11), and (12) is used depends on the number of state elements.

(12)

Because we have a non-linear measurement model, we will have to use an extended Kalman lter. For the EKF we need the Jacobian of the measurement functionthe derivative of the measurement function (13) with respect to the state: H = h( x) . x In our situation, the measurement model (13) is only a function of x L the element of the state representing the water level, so the Jacobian elements corresponding to any other state elements

d b xL (13) h ( x ) = k a asin ---------------- , df x L is the element of the state vector that represents the water level, and again the hats on z and x reect the notion that they are estimates of the actual measurement and state.

will always be zero. Specically if we use a one-dimensional state x to estimate the water level L (Section 1.2.1), the measurement matrix is simply (14) d h( x) H = d xL where k a d h ( x ) = -------------------------------------------- . d xL d b x L 2 d f 1 --------------- df If we use a two-dimensional state x to estimate the water level L (Section 1.2.2 or Section 1.2.3), and the estimate of the water level is in the rst position/element of the state, the measurement matrix is Finally if we use a three-dimensional state to estimate the water level L (Section 1.2.4), and the estimate of the water level is in the rst position/element of the state, the measurement matrix is H = d h( x) 0 0 . d xL H = d h( x) 0 . d xL (15)

(16)

In the actual lter, (13) would be used to predict the measurement, and the Jacobian (14), (15), or (16) would be used in the Kalman gain equation.

APPENDIX A: DISCRETE TIME PROCESS NOISE Q ( t ) =


t
T

Given continuous time state transition and process noise matrices A and Q , one can compute the discrete time (sampled) process noise matrix as follows: For example, given and

0 e A Qe A d .

(17)

A = 01 00 Q = 0 0 , 0 qc

where q c is is the autocorrelation of the continuous process noise, the discrete time time process noise matrix would be t 3 q c t 2 q c ------------ -----------3 2 . Q ( t ) = t 2 q c ------------ tq c 2

You might also like