48 #include <visp/vpKalmanFilter.h>
70 F.
resize(size_state*nsignal, size_state*nsignal) ;
71 H.
resize(size_measure*nsignal, size_state*nsignal) ;
73 R.
resize(size_measure*nsignal, size_measure*nsignal) ;
74 Q.
resize(size_state*nsignal, size_state*nsignal) ;
81 I.
resize(size_state*nsignal, size_state*nsignal) ;
137 init( size_state, size_measure, nsignal) ;
159 std::cout <<
" in vpKalmanFilter::prediction()" <<
Xest.
getRows()
161 std::cout <<
" Error : Filter non initialized " << std::endl;
173 std::cout <<
"F = " << std::endl <<
F << std::endl ;
174 std::cout <<
"Xest = "<< std::endl <<
Xest << std::endl ;
180 std::cout <<
"Xpre = "<< std::endl <<
Xpre << std::endl ;
181 std::cout <<
"Q = "<< std::endl <<
Q << std::endl ;
182 std::cout <<
"Pest " << std::endl <<
Pest << std::endl ;
189 std::cout <<
"Ppre " << std::endl <<
Ppre << std::endl ;
227 std::cout <<
"z " << std::endl << z << std::endl ;
231 std::cout <<
"S " << std::endl << S << std::endl ;
235 std::cout <<
"W " << std::endl <<
W << std::endl ;
239 std::cout <<
"Pest " << std::endl <<
Pest << std::endl ;
251 std::cout <<
"Xest " << std::endl <<
Xest << std::endl ;
310 vpKalmanFilter::initFilterCteAcceleration(
double dt,
320 double dt3 = dt2*
dt ;
321 double dt4 = dt3*
dt ;
322 double dt5 = dt4*
dt ;
338 F[3*i][3*i+2] = dt*dt/2 ;
339 F[3*i+1][3*i+1] = 1 ;
340 F[3*i+1][3*i+2] =
dt ;
341 F[3*i+2][3*i+2] = 1 ;
349 double sR = sigma_noise[i] ;
350 double sQ = sigma_state[i] ;
356 Q[3*i ][3*i ] = sQ * dt5/20;
357 Q[3*i ][3*i+1] = sQ * dt4/8;
358 Q[3*i ][3*i+2] = sQ * dt3/6 ;
360 Q[3*i+1][3*i ] = sQ * dt4/8 ;
361 Q[3*i+1][3*i+1] = sQ * dt3/3 ;
362 Q[3*i+1][3*i+2] = sQ * dt2/2 ;
364 Q[3*i+2][3*i ] = sQ * dt3/6 ;
365 Q[3*i+2][3*i+1] = sQ * dt2/2.0 ;
366 Q[3*i+2][3*i+2] = sQ *
dt ;
371 Pest[3*i ][3*i ] = sR ;
372 Pest[3*i ][3*i+1] = 1.5/dt*sR ;
373 Pest[3*i ][3*i+2] = sR/(dt2) ;
375 Pest[3*i+1][3*i ] = 1.5/dt*sR ;
376 Pest[3*i+1][3*i+1] = dt3/3*sQ + 13/(2*dt2)*sR ;
377 Pest[3*i+1][3*i+2] = 9*dt2*sQ/40.0 +6/dt3*sR ;
379 Pest[3*i+2][3*i ] = sR/(dt2) ;
380 Pest[3*i+2][3*i+1] = 9*dt2*sQ/40.0 +6/dt3*sR ;
381 Pest[3*i+2][3*i+2] = 23*dt/30.0*sQ+6.0/dt4*sR ;
387 Xest[3*i+1] = ( 1.5 *Z2[i] - Z1[i] -0.5*Z0[i] ) /( 2*dt ) ;
388 Xest[3*i+2] = ( Z2[i] - 2*Z1[i] + Z0[i] ) /( dt*dt ) ;
394 vpKalmanFilter::initFilterSinger(
double dt,
404 double dt3 = dt2*
dt ;
424 F[3*i][3*i+2] = 1/a2*(1+a*dt+exp(-a*dt)) ;
425 F[3*i+1][3*i+1] = 1 ;
426 F[3*i+1][3*i+2] = 1/a*(1-exp(-a*dt)) ;
427 F[3*i+2][3*i+2] = exp(-a*dt) ;
435 double sR = sigma_noise[i] ;
436 double sQ = sigma_state[i] ;
440 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) ) ;
441 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 ) ;
442 Q[3*i ][3*i+2] = sQ/a2*(1-exp(-2*a*dt)-2*a*dt*exp(-a*dt) ) ;
444 Q[3*i+1][3*i ] = Q[3*i ][3*i+1] ;
445 Q[3*i+1][3*i+1] = sQ/a2*(4*exp(-a*dt)-3-exp(-2*a*dt)+2*a*
dt ) ;
446 Q[3*i+1][3*i+2] = sQ/a*(exp(-2*a*dt)+1- 2*exp(-a*dt)) ;
448 Q[3*i+2][3*i ] = Q[3*i ][3*i+2] ;
449 Q[3*i+2][3*i+1] = Q[3*i+1][3*i+2] ;
450 Q[3*i+2][3*i+2] = sQ*(1-exp(-2*a*dt) ) ;
454 Pest[3*i ][3*i ] = sR ;
455 Pest[3*i ][3*i+1] = 1/dt*sR ;
456 Pest[3*i ][3*i+2] = 0 ;
458 Pest[3*i+1][3*i ] = 1/dt*sR ;
459 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));
460 Pest[3*i+1][3*i+2] = sQ/(a2*
dt)*(exp(-a*dt)+a*dt-1) ;
462 Pest[3*i+2][3*i ] = 0 ;
463 Pest[3*i+2][3*i+1] = Pest[3*i+1][3*i+2] ;
464 Pest[3*i+2][3*i+2] = 0 ;
470 Xest[3*i+1] = ( Z1[i] - Z0[i] ) /(dt ) ;
Definition of the vpMatrix class.
void resize(const unsigned int nrows, const unsigned int ncols, const bool nullify=true)
void filtering(vpColVector &z)
long iter
Filter step or iteration. When set to zero, initialize the filter.
unsigned int size_state
Size of the state vector .
vpMatrix R
Measurement noise covariance matrix .
unsigned int size_measure
Size of the measure vector .
vpMatrix I
Identity matrix .
unsigned int nsignal
Number of signal to filter.
void init(unsigned int size_state, unsigned int size_measure, unsigned int nsignal)
Class that provides a data structure for the column vectors as well as a set of operations on these v...
vpMatrix inverseByLU() const
vpMatrix F
Transition matrix that describes the evolution of the state.
unsigned int getRows() const
Return the number of rows of the matrix.
vpMatrix H
Matrix that describes the evolution of the measurements.
bool verbose_mode
When set to true, print the content of internal variables during filtering() and prediction().
vpMatrix Q
Process noise covariance matrix .
void resize(const unsigned int i, const bool flagNullify=true)