44 #include "EST_kalman.h"
46 static bool kalman_filter_param_check(
EST_FVector &x,
66 if(!kalman_filter_param_check(x,P,Q,R,A,H,z))
68 cerr <<
"Kalman filter parameters inconsistent !" << endl;
78 cerr <<
"predict" << endl;
86 cerr <<
"correct" << endl;
97 if(!inverse( HPHt_R , HPHt_R_inv, singularity))
101 cerr <<
" H * P * Ht + R is singular !" << endl;
104 cerr <<
"Matrix inversion failed for an unknown reason !" << endl;
108 K = PHt * HPHt_R_inv;
109 x = add(x, K * subtract(z,H * x));
140 if(!kalman_filter_param_check(x,Pinv,Q,Rinv,A,H,z))
142 cerr <<
"Kalman filter parameters inconsistent !" << endl;
154 cerr <<
"Compute P" << endl;
159 Pinv = Pinv + (Ht * Rinv * H);
161 if(!inverse(Pinv,P,singularity))
163 if(singularity != -1)
165 cerr <<
"P is singular !" << endl;
168 cerr <<
"Matrix inversion failed for an unknown reason !" << endl;
178 x = add(x, K * subtract(z,H*x));
184 if(!inverse(P,Pinv,singularity))
186 if(singularity != -1)
188 cerr <<
"Pinv is singular !" << endl;
191 cerr <<
"Matrix inversion failed for an unknown reason !" << endl;
217 int measurement_dim=z.
length();
221 if((state_dim <= 0) ||
222 (measurement_dim <= 0))
224 cerr <<
"No state or measurements !!" << endl;
234 cerr <<
"P, or Pinv, must be a symmetrical square matrix of the same dimension" << endl;
235 cerr <<
"as the state vector, x" << endl;
243 cerr <<
"Q must be a symmetrical square matrix of the same dimension" << endl;
244 cerr <<
"as the state vector, x" << endl;
249 if((R.
num_rows() != measurement_dim) ||
252 cerr <<
"R, or Rinv, must be a symmetrical square matrix of the same dimension" << endl;
253 cerr <<
"as the measurement vector, z" << endl;
260 cerr <<
"A must be a square matrix of the same dimension" << endl;
261 cerr <<
"as the state vector, x" << endl;
265 if((H.
num_rows() != measurement_dim) ||
268 cerr <<
"H must have dimensions to fit z = Hx" << endl;