Proportional-Integral Kalman Filters Steve Rogers An approach for modifying a Kalman filter to include an integral channel is presented in this section1. The basic equations for a Kalman filter are repeated below2. −¿= Ak ̂x k State project ahead: ̂x ¿k +1 −¿ H 'k + Rk H k P¿k ¿ Compute Kalman Gain: ¿ −¿ H 'k ¿ K k =P ¿k
Update estimate with measurement:
Error covariance:
−¿ z k −H k ̂x ¿k −¿+ K k ¿ ¿ ̂x k = ̂x k
−¿ P k =( I −K k H k ) P ¿k '
−¿= Ak P k Ak +Q k ¿ Project covariance ahead: P k +1
The above state project ahead and update estimate with measurement equations may be −¿ z k −H k ̂x ¿k combined as: −¿+ K k ¿ . For the purposes of this discussion the above algorithm is ¿ ̂x k = Ak ̂x k the proportional Kalman filter. We wish to add an integrator to it, that is, design a PI (proportional integral) Kalman filter. We may augment the system equations as:
−¿ ¿ −¿ ¿ z k −H k ̂x k
[ ]
K kP −¿ ̂ x̂ d k + I ¿ Kk ¿ k
[][
x̂ k Ak = d̂ k 0
]
Di ¿ Df
Di (integral effect coefficient) and Df (fading constant) are constant matrices to be P I designed9. K k and K k are Kalman gains. The following function script is a Kalman filter matlab implementation. % Kalman filter algorithm % A is state matrix % C is proportional KF state output matrix % Ci is PI KF state output matrix % z is the measurement % Q,R are the state & measurement weighting matrices % t is the time persistent X if isempty(X)||t==0 X.x = zeros(size(A(:,1))); X.P = 10*eye(length(X.x)); end X.x K = X.x X.P X.P y =
= A*X.x; X.P*Ci'/(Ci*X.P*Ci' + R); = X.x + K*(z - C*X.x(1:length(C))); = X.P - K*Ci*X.P; = A*X.P*A' + Q; C*X.x(1:length(C));
The following script is an implementation of the proportional Kalman filter. ‘alph’ represents the model error – 1 is no error, 1.1 is 10% error, 0.8 is – 20% error, etc. P = tf([1 5],[1 1 1]);alph = 1.0; [A,B,C,D] = ssdata(alph*P); dt = 0.05; % sample interval t = 0:dt:20; u = 0.5.*randn(size(t)); % mean of zero & standard deviation of 0.05 [y,t] = lsim(P,u,t); Q = eye(2);R = 1; for i = 1:length(t) z = y(i); yP(i) = KF(A,C,C,z,Q,R,t(i)); end
The proportional integral modifications are shown below. Di = diag([.6 .6]); Df = 1.0*eye(2); Abar = [A Di;zeros(2,2),Df]; Ci = [C 1 1]; Qi = [Q,zeros(2,2);zeros(2,2),Q]; for i = 1:length(t) z = y(i); yPI(i) = KF(Abar,C,Ci,z,Qi,R,t(i)); end
The results are plotted below. The performance index (pin) is the RMS deviation of the Kalman filter outputs from the measurement for proportional and proportional integral respectively.
The above show significant improvements with the PI Kalman filter when there is model error. The literature1 suggests improvement of PI vs. P when noise is higher. ‘Di’ and ‘Df’ are tunable parameters. ‘Di’ should be full rank and larger values ensure better accuracy at the expense of higher overshoot1. ‘Df’ is the fading matrix and usually Df =αI , 0<α ≤ 1 . The above method directly modifies the Kalman gain approach. The number of states is doubled as well. Another approach3 allows us to modify the measurement error inputs to an existing proportional Kalman filter. We can then place a proportional integral (PI)
transfer function on each error input. The general idea is presented in the diagram below. ‘y’ is the measurement, ‘ ̂y ’ is the measurement estimate, ‘ye’ is the estimate error, ‘Kp’ is the PI proportional gain, ‘Ki’ is the integral gain, and ‘KF’ is the existing Kalman filter.
This format may be used for each measurement error input. It should be noted that this structure adds an extra zero and pole to the system dynamics, which will impact stability and performance. A straightforward way to obtain the PI gains is discussed in the section on PI gains from tables. The IMC 2 gain selection method will be used. The −td∗s ke st IMC 2 PID method is based on assumed values for a simple 1 order model tc∗s+ 1 . Approximate values for the three parameters may come from inspection of a step response of the Kalman filter. The scripts below show the design of the PID controller. Values for the three parameters should reflect the Kalman filter dynamics. Those shown are for illustration only. % Compute PID gains using IMC2 k = 0.8;tc = 0.9;td = 0.5; kp = (2*tc+td)/2/k/(tc+td); ki = 1/k/(tc+td); kd = tc*td/2/k/(tc+td);
The same plant was used for testing the two versions of a Kalman filter estimation. The following plots show the results.
As in the previous matrix modification of the Kalman filter approach, the PI add-on improved the tracking of the Kalman filter. 1. Bas, O., Shafai, B., and Linder, S., â&#x20AC;&#x2DC;Design of Optimal Gains for the Proportional Integral Kalman Filter,â&#x20AC;&#x2122; No. FrMO5, Conference on decision and Control, Dec., 1999, Phoenix, AR, USA.
2. Brown, R., and Hwang, P., Introduction to Random Signals and Applied Kalman Filtering, 1997, Wiley, ISBN 0-471-12839-2.
3. Blight, J., Integral LQG Design, Boeing Military Airplane Company, Nov., 1987, Boeing Internal Document No. 71102-1 JB.