41 #include <visp3/core/vpKalmanFilter.h>
58 void vpKalmanFilter::init(
unsigned int size_state_vector,
unsigned int size_measure_vector,
unsigned int n_signal)
90 : iter(0), size_state(0), size_measure(0), nsignal(0), verbose_mode(false), Xest(), Xpre(), F(), H(), R(), Q(),
91 dt(-1), Ppre(), Pest(), W(), I()
102 : iter(0), size_state(0), size_measure(0), nsignal(n_signal), verbose_mode(false), Xest(), Xpre(), F(), H(), R(), Q(),
103 dt(-1), Ppre(), Pest(), W(), I()
120 : iter(0), size_state(0), size_measure(0), nsignal(0), verbose_mode(false), Xest(), Xpre(), F(), H(), R(), Q(),
121 dt(-1), Ppre(), Pest(), W(), I()
123 init(size_state_vector, size_measure_vector, n_signal);
150 std::cout <<
"F = " << std::endl <<
F << std::endl;
151 std::cout <<
"Xest = " << std::endl <<
Xest << std::endl;
157 std::cout <<
"Xpre = " << std::endl <<
Xpre << std::endl;
158 std::cout <<
"Q = " << std::endl <<
Q << std::endl;
159 std::cout <<
"Pest " << std::endl <<
Pest << std::endl;
166 std::cout <<
"Ppre " << std::endl <<
Ppre << std::endl;
202 std::cout <<
"z " << std::endl << z << std::endl;
206 std::cout <<
"S " << std::endl << S << std::endl;
210 std::cout <<
"W " << std::endl <<
W << std::endl;
214 std::cout <<
"Pest " << std::endl <<
Pest << std::endl;
226 std::cout <<
"Xest " << std::endl <<
Xest << std::endl;
283 vpKalmanFilter::initFilterCteAcceleration(
double dt,
310 F[3*i][3*i+2] =
dt*
dt/2;
312 F[3*i+1][3*i+2] =
dt;
321 double sR = sigma_noise[i];
322 double sQ = sigma_state[i];
328 Q[3*i][3*i] = sQ * dt5/20;
329 Q[3*i][3*i+1] = sQ * dt4/8;
330 Q[3*i][3*i+2] = sQ * dt3/6;
332 Q[3*i+1][3*i] = sQ * dt4/8;
333 Q[3*i+1][3*i+1] = sQ * dt3/3;
334 Q[3*i+1][3*i+2] = sQ * dt2/2;
336 Q[3*i+2][3*i] = sQ * dt3/6;
337 Q[3*i+2][3*i+1] = sQ * dt2/2.0;
338 Q[3*i+2][3*i+2] = sQ *
dt;
344 Pest[3*i][3*i+1] = 1.5/
dt*sR;
345 Pest[3*i][3*i+2] = sR/(dt2);
347 Pest[3*i+1][3*i] = 1.5/
dt*sR;
348 Pest[3*i+1][3*i+1] = dt3/3*sQ + 13/(2*dt2)*sR;
349 Pest[3*i+1][3*i+2] = 9*dt2*sQ/40.0 +6/dt3*sR;
351 Pest[3*i+2][3*i] = sR/(dt2);
352 Pest[3*i+2][3*i+1] = 9*dt2*sQ/40.0 +6/dt3*sR;
353 Pest[3*i+2][3*i+2] = 23*
dt/30.0*sQ+6.0/dt4*sR;
359 Xest[3*i+1] = (1.5 *Z2[i] - Z1[i] -0.5*Z0[i]) /(2*
dt);
360 Xest[3*i+2] = (Z2[i] - 2*Z1[i] + Z0[i]) /(
dt*
dt);
366 vpKalmanFilter::initFilterSinger(
double dt,
395 F[3*i][3*i+2] = 1/a2*(1+a*
dt+exp(-a*
dt));
397 F[3*i+1][3*i+2] = 1/a*(1-exp(-a*
dt));
398 F[3*i+2][3*i+2] = exp(-a*
dt);
406 double sR = sigma_noise[i];
407 double sQ = sigma_state[i];
411 Q[3*i][3*i] = sQ/a4*(1-exp(-2*a*
dt)+2*a*
dt+2*a3/3*dt3-2*a2*dt2-4*a*
dt*exp(-a*
dt));
412 Q[3*i][3*i+1] = sQ/a3*(1+exp(-2*a*
dt)-2*exp(-a*
dt)+2*a*
dt*exp(-a*
dt)-2*a*
dt+a2*dt2);
413 Q[3*i][3*i+2] = sQ/a2*(1-exp(-2*a*
dt)-2*a*
dt*exp(-a*
dt));
415 Q[3*i+1][3*i] =
Q[3*i][3*i+1];
416 Q[3*i+1][3*i+1] = sQ/a2*(4*exp(-a*
dt)-3-exp(-2*a*
dt)+2*a*
dt);
417 Q[3*i+1][3*i+2] = sQ/a*(exp(-2*a*
dt)+1- 2*exp(-a*
dt));
419 Q[3*i+2][3*i] =
Q[3*i][3*i+2];
420 Q[3*i+2][3*i+1] =
Q[3*i+1][3*i+2];
421 Q[3*i+2][3*i+2] = sQ*(1-exp(-2*a*
dt));
426 Pest[3*i][3*i+1] = 1/
dt*sR;
427 Pest[3*i][3*i+2] = 0;
429 Pest[3*i+1][3*i] = 1/
dt*sR;
430 Pest[3*i+1][3*i+1] = 2*sR/dt2 + sQ/(a4*dt2)*(2-a2*dt2+2*a3*dt3/3.0 -2*exp(-a*
dt)-2*a*
dt*exp(-a*
dt));
431 Pest[3*i+1][3*i+2] = sQ/(a2*
dt)*(exp(-a*
dt)+a*
dt-1);
433 Pest[3*i+2][3*i] = 0;
434 Pest[3*i+2][3*i+1] =
Pest[3*i+1][3*i+2];
435 Pest[3*i+2][3*i+2] = 0;
441 Xest[3*i+1] = (Z1[i] - Z0[i]) /(
dt);
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
unsigned int getRows() const
Implementation of column vector and the associated operations.
void resize(unsigned int i, bool flagNullify=true)
error that can be emitted by ViSP classes.
unsigned int size_state
Size of the state vector .
long iter
Filter step or iteration. When set to zero, initialize the filter.
vpMatrix R
Measurement noise covariance matrix .
void init(unsigned int size_state, unsigned int size_measure, unsigned int n_signal)
unsigned int nsignal
Number of signal to filter.
vpMatrix Q
Process noise covariance matrix .
void filtering(const vpColVector &z)
unsigned int size_measure
Size of the measure vector .
vpMatrix I
Identity matrix .
vpMatrix H
Matrix that describes the evolution of the measurements.
Implementation of a matrix and operations on matrices.
vpMatrix inverseByLU() const