41 #include <visp3/core/vpKalmanFilter.h>
57 void vpKalmanFilter::init(
unsigned int size_state_vector,
unsigned int size_measure_vector,
unsigned int n_signal)
89 : iter(0), size_state(0), size_measure(0), nsignal(0), verbose_mode(false), Xest(), Xpre(), F(), H(), R(), Q(),
90 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()
121 : iter(0), size_state(0), size_measure(0), nsignal(0), verbose_mode(false), Xest(), Xpre(), F(), H(), R(), Q(),
122 dt(-1), Ppre(), Pest(), W(), I()
124 init(size_state_vector, size_measure_vector, n_signal);
151 std::cout <<
"F = " << std::endl <<
F << std::endl;
152 std::cout <<
"Xest = " << std::endl <<
Xest << std::endl;
158 std::cout <<
"Xpre = " << std::endl <<
Xpre << std::endl;
159 std::cout <<
"Q = " << std::endl <<
Q << std::endl;
160 std::cout <<
"Pest " << std::endl <<
Pest << std::endl;
167 std::cout <<
"Ppre " << std::endl <<
Ppre << std::endl;
203 std::cout <<
"z " << std::endl << z << std::endl;
207 std::cout <<
"S " << std::endl << S << std::endl;
211 std::cout <<
"W " << std::endl <<
W << std::endl;
215 std::cout <<
"Pest " << std::endl <<
Pest << std::endl;
227 std::cout <<
"Xest " << std::endl <<
Xest << std::endl;
284 vpKalmanFilter::initFilterCteAcceleration(
double dt,
294 double dt3 = dt2*
dt ;
295 double dt4 = dt3*
dt ;
296 double dt5 = dt4*
dt ;
312 F[3*i][3*i+2] =
dt*
dt/2 ;
313 F[3*i+1][3*i+1] = 1 ;
314 F[3*i+1][3*i+2] =
dt ;
315 F[3*i+2][3*i+2] = 1 ;
323 double sR = sigma_noise[i] ;
324 double sQ = sigma_state[i] ;
330 Q[3*i ][3*i ] = sQ * dt5/20;
331 Q[3*i ][3*i+1] = sQ * dt4/8;
332 Q[3*i ][3*i+2] = sQ * dt3/6 ;
334 Q[3*i+1][3*i ] = sQ * dt4/8 ;
335 Q[3*i+1][3*i+1] = sQ * dt3/3 ;
336 Q[3*i+1][3*i+2] = sQ * dt2/2 ;
338 Q[3*i+2][3*i ] = sQ * dt3/6 ;
339 Q[3*i+2][3*i+1] = sQ * dt2/2.0 ;
340 Q[3*i+2][3*i+2] = sQ *
dt ;
345 Pest[3*i ][3*i ] = sR ;
346 Pest[3*i ][3*i+1] = 1.5/
dt*sR ;
347 Pest[3*i ][3*i+2] = sR/(dt2) ;
349 Pest[3*i+1][3*i ] = 1.5/
dt*sR ;
350 Pest[3*i+1][3*i+1] = dt3/3*sQ + 13/(2*dt2)*sR ;
351 Pest[3*i+1][3*i+2] = 9*dt2*sQ/40.0 +6/dt3*sR ;
353 Pest[3*i+2][3*i ] = sR/(dt2) ;
354 Pest[3*i+2][3*i+1] = 9*dt2*sQ/40.0 +6/dt3*sR ;
355 Pest[3*i+2][3*i+2] = 23*
dt/30.0*sQ+6.0/dt4*sR ;
361 Xest[3*i+1] = ( 1.5 *Z2[i] - Z1[i] -0.5*Z0[i] ) /( 2*
dt ) ;
362 Xest[3*i+2] = ( Z2[i] - 2*Z1[i] + Z0[i] ) /(
dt*
dt ) ;
368 vpKalmanFilter::initFilterSinger(
double dt,
378 double dt3 = dt2*
dt ;
398 F[3*i][3*i+2] = 1/a2*(1+a*
dt+exp(-a*
dt)) ;
399 F[3*i+1][3*i+1] = 1 ;
400 F[3*i+1][3*i+2] = 1/a*(1-exp(-a*
dt)) ;
401 F[3*i+2][3*i+2] = exp(-a*
dt) ;
409 double sR = sigma_noise[i] ;
410 double sQ = sigma_state[i] ;
414 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) ) ;
415 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 ) ;
416 Q[3*i ][3*i+2] = sQ/a2*(1-exp(-2*a*
dt)-2*a*
dt*exp(-a*
dt) ) ;
418 Q[3*i+1][3*i ] =
Q[3*i ][3*i+1] ;
419 Q[3*i+1][3*i+1] = sQ/a2*(4*exp(-a*
dt)-3-exp(-2*a*
dt)+2*a*
dt ) ;
420 Q[3*i+1][3*i+2] = sQ/a*(exp(-2*a*
dt)+1- 2*exp(-a*
dt)) ;
422 Q[3*i+2][3*i ] =
Q[3*i ][3*i+2] ;
423 Q[3*i+2][3*i+1] =
Q[3*i+1][3*i+2] ;
424 Q[3*i+2][3*i+2] = sQ*(1-exp(-2*a*
dt) ) ;
428 Pest[3*i ][3*i ] = sR ;
429 Pest[3*i ][3*i+1] = 1/
dt*sR ;
430 Pest[3*i ][3*i+2] = 0 ;
432 Pest[3*i+1][3*i ] = 1/
dt*sR ;
433 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));
434 Pest[3*i+1][3*i+2] = sQ/(a2*
dt)*(exp(-a*
dt)+a*
dt-1) ;
436 Pest[3*i+2][3*i ] = 0 ;
437 Pest[3*i+2][3*i+1] =
Pest[3*i+1][3*i+2] ;
438 Pest[3*i+2][3*i+2] = 0 ;
444 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 .
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.
void init(unsigned int size_state, unsigned int size_measure, unsigned int n_signal)
Implementation of a matrix and operations on matrices.
vpMatrix inverseByLU() const