45 #include <visp3/core/vpKalmanFilter.h>
62 unsigned int n_signal)
91 : iter(0), size_state(0), size_measure(0), nsignal(0), verbose_mode(false),
92 Xest(), Xpre(), F(), H(), R(), Q(), dt(-1), Ppre(), Pest(), W(), I()
104 : iter(0), size_state(0), size_measure(0), nsignal(n_signal), verbose_mode(false),
105 Xest(), Xpre(), F(), H(), R(), Q(), dt(-1), Ppre(), Pest(), W(), I()
122 : iter(0), size_state(0), size_measure(0), nsignal(0), verbose_mode(false),
123 Xest(), Xpre(), F(), H(), R(), Q(), dt(-1), Ppre(), Pest(), W(), I()
125 init( size_state_vector, size_measure_vector, n_signal) ;
147 std::cout <<
" in vpKalmanFilter::prediction()" <<
Xest.
getRows()
149 std::cout <<
" Error : Filter non initialized " << std::endl;
161 std::cout <<
"F = " << std::endl <<
F << std::endl ;
162 std::cout <<
"Xest = "<< std::endl <<
Xest << std::endl ;
168 std::cout <<
"Xpre = "<< std::endl <<
Xpre << std::endl ;
169 std::cout <<
"Q = "<< std::endl <<
Q << std::endl ;
170 std::cout <<
"Pest " << std::endl <<
Pest << std::endl ;
177 std::cout <<
"Ppre " << std::endl <<
Ppre << std::endl ;
215 std::cout <<
"z " << std::endl << z << std::endl ;
219 std::cout <<
"S " << std::endl << S << std::endl ;
223 std::cout <<
"W " << std::endl <<
W << std::endl ;
227 std::cout <<
"Pest " << std::endl <<
Pest << std::endl ;
239 std::cout <<
"Xest " << std::endl <<
Xest << std::endl ;
297 vpKalmanFilter::initFilterCteAcceleration(
double dt,
307 double dt3 = dt2*
dt ;
308 double dt4 = dt3*
dt ;
309 double dt5 = dt4*
dt ;
325 F[3*i][3*i+2] = dt*dt/2 ;
326 F[3*i+1][3*i+1] = 1 ;
327 F[3*i+1][3*i+2] =
dt ;
328 F[3*i+2][3*i+2] = 1 ;
336 double sR = sigma_noise[i] ;
337 double sQ = sigma_state[i] ;
343 Q[3*i ][3*i ] = sQ * dt5/20;
344 Q[3*i ][3*i+1] = sQ * dt4/8;
345 Q[3*i ][3*i+2] = sQ * dt3/6 ;
347 Q[3*i+1][3*i ] = sQ * dt4/8 ;
348 Q[3*i+1][3*i+1] = sQ * dt3/3 ;
349 Q[3*i+1][3*i+2] = sQ * dt2/2 ;
351 Q[3*i+2][3*i ] = sQ * dt3/6 ;
352 Q[3*i+2][3*i+1] = sQ * dt2/2.0 ;
353 Q[3*i+2][3*i+2] = sQ *
dt ;
358 Pest[3*i ][3*i ] = sR ;
359 Pest[3*i ][3*i+1] = 1.5/dt*sR ;
360 Pest[3*i ][3*i+2] = sR/(dt2) ;
362 Pest[3*i+1][3*i ] = 1.5/dt*sR ;
363 Pest[3*i+1][3*i+1] = dt3/3*sQ + 13/(2*dt2)*sR ;
364 Pest[3*i+1][3*i+2] = 9*dt2*sQ/40.0 +6/dt3*sR ;
366 Pest[3*i+2][3*i ] = sR/(dt2) ;
367 Pest[3*i+2][3*i+1] = 9*dt2*sQ/40.0 +6/dt3*sR ;
368 Pest[3*i+2][3*i+2] = 23*dt/30.0*sQ+6.0/dt4*sR ;
374 Xest[3*i+1] = ( 1.5 *Z2[i] - Z1[i] -0.5*Z0[i] ) /( 2*dt ) ;
375 Xest[3*i+2] = ( Z2[i] - 2*Z1[i] + Z0[i] ) /( dt*dt ) ;
381 vpKalmanFilter::initFilterSinger(
double dt,
391 double dt3 = dt2*
dt ;
411 F[3*i][3*i+2] = 1/a2*(1+a*dt+exp(-a*dt)) ;
412 F[3*i+1][3*i+1] = 1 ;
413 F[3*i+1][3*i+2] = 1/a*(1-exp(-a*dt)) ;
414 F[3*i+2][3*i+2] = exp(-a*dt) ;
422 double sR = sigma_noise[i] ;
423 double sQ = sigma_state[i] ;
427 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) ) ;
428 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 ) ;
429 Q[3*i ][3*i+2] = sQ/a2*(1-exp(-2*a*dt)-2*a*dt*exp(-a*dt) ) ;
431 Q[3*i+1][3*i ] = Q[3*i ][3*i+1] ;
432 Q[3*i+1][3*i+1] = sQ/a2*(4*exp(-a*dt)-3-exp(-2*a*dt)+2*a*
dt ) ;
433 Q[3*i+1][3*i+2] = sQ/a*(exp(-2*a*dt)+1- 2*exp(-a*dt)) ;
435 Q[3*i+2][3*i ] = Q[3*i ][3*i+2] ;
436 Q[3*i+2][3*i+1] = Q[3*i+1][3*i+2] ;
437 Q[3*i+2][3*i+2] = sQ*(1-exp(-2*a*dt) ) ;
441 Pest[3*i ][3*i ] = sR ;
442 Pest[3*i ][3*i+1] = 1/dt*sR ;
443 Pest[3*i ][3*i+2] = 0 ;
445 Pest[3*i+1][3*i ] = 1/dt*sR ;
446 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));
447 Pest[3*i+1][3*i+2] = sQ/(a2*
dt)*(exp(-a*dt)+a*dt-1) ;
449 Pest[3*i+2][3*i ] = 0 ;
450 Pest[3*i+2][3*i+1] = Pest[3*i+1][3*i+2] ;
451 Pest[3*i+2][3*i+2] = 0 ;
457 Xest[3*i+1] = ( Z1[i] - Z0[i] ) /(dt ) ;
Implementation of a matrix and operations on matrices.
void resize(const unsigned int nrows, const unsigned int ncols, const bool flagNullify=true)
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 .
void filtering(const vpColVector &z)
unsigned int nsignal
Number of signal to filter.
void init(unsigned int size_state, unsigned int size_measure, unsigned int n_signal)
unsigned int getRows() const
Return the number of rows of the 2D array.
Implementation of column vector and the associated operations.
vpMatrix inverseByLU() const
vpMatrix F
Transition matrix that describes the evolution of the state.
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)