45 #include <visp3/core/vpKalmanFilter.h> 61 void vpKalmanFilter::init(
unsigned int size_state_vector,
unsigned int size_measure_vector,
unsigned int n_signal)
93 :
iter(0),
size_state(0),
size_measure(0),
nsignal(0),
verbose_mode(false),
Xest(),
Xpre(),
F(),
H(),
R(),
Q(),
106 :
iter(0),
size_state(0),
size_measure(0),
nsignal(n_signal),
verbose_mode(false),
Xest(),
Xpre(),
F(),
H(),
R(),
Q(),
125 :
iter(0),
size_state(0),
size_measure(0),
nsignal(0),
verbose_mode(false),
Xest(),
Xpre(),
F(),
H(),
R(),
Q(),
128 init(size_state_vector, size_measure_vector, n_signal);
154 std::cout <<
"F = " << std::endl <<
F << std::endl;
155 std::cout <<
"Xest = " << std::endl <<
Xest << std::endl;
161 std::cout <<
"Xpre = " << std::endl <<
Xpre << std::endl;
162 std::cout <<
"Q = " << std::endl <<
Q << std::endl;
163 std::cout <<
"Pest " << std::endl <<
Pest << std::endl;
170 std::cout <<
"Ppre " << std::endl <<
Ppre << std::endl;
206 std::cout <<
"z " << std::endl << z << std::endl;
210 std::cout <<
"S " << std::endl << S << std::endl;
214 std::cout <<
"W " << std::endl <<
W << std::endl;
218 std::cout <<
"Pest " << std::endl <<
Pest << std::endl;
230 std::cout <<
"Xest " << std::endl <<
Xest << std::endl;
287 vpKalmanFilter::initFilterCteAcceleration(
double dt,
297 double dt3 = dt2*
dt ;
298 double dt4 = dt3*
dt ;
299 double dt5 = dt4*
dt ;
315 F[3*i][3*i+2] = dt*dt/2 ;
316 F[3*i+1][3*i+1] = 1 ;
317 F[3*i+1][3*i+2] =
dt ;
318 F[3*i+2][3*i+2] = 1 ;
326 double sR = sigma_noise[i] ;
327 double sQ = sigma_state[i] ;
333 Q[3*i ][3*i ] = sQ * dt5/20;
334 Q[3*i ][3*i+1] = sQ * dt4/8;
335 Q[3*i ][3*i+2] = sQ * dt3/6 ;
337 Q[3*i+1][3*i ] = sQ * dt4/8 ;
338 Q[3*i+1][3*i+1] = sQ * dt3/3 ;
339 Q[3*i+1][3*i+2] = sQ * dt2/2 ;
341 Q[3*i+2][3*i ] = sQ * dt3/6 ;
342 Q[3*i+2][3*i+1] = sQ * dt2/2.0 ;
343 Q[3*i+2][3*i+2] = sQ *
dt ;
348 Pest[3*i ][3*i ] = sR ;
349 Pest[3*i ][3*i+1] = 1.5/dt*sR ;
350 Pest[3*i ][3*i+2] = sR/(dt2) ;
352 Pest[3*i+1][3*i ] = 1.5/dt*sR ;
353 Pest[3*i+1][3*i+1] = dt3/3*sQ + 13/(2*dt2)*sR ;
354 Pest[3*i+1][3*i+2] = 9*dt2*sQ/40.0 +6/dt3*sR ;
356 Pest[3*i+2][3*i ] = sR/(dt2) ;
357 Pest[3*i+2][3*i+1] = 9*dt2*sQ/40.0 +6/dt3*sR ;
358 Pest[3*i+2][3*i+2] = 23*dt/30.0*sQ+6.0/dt4*sR ;
364 Xest[3*i+1] = ( 1.5 *Z2[i] - Z1[i] -0.5*Z0[i] ) /( 2*dt ) ;
365 Xest[3*i+2] = ( Z2[i] - 2*Z1[i] + Z0[i] ) /( dt*dt ) ;
371 vpKalmanFilter::initFilterSinger(
double dt,
381 double dt3 = dt2*
dt ;
401 F[3*i][3*i+2] = 1/a2*(1+a*dt+exp(-a*dt)) ;
402 F[3*i+1][3*i+1] = 1 ;
403 F[3*i+1][3*i+2] = 1/a*(1-exp(-a*dt)) ;
404 F[3*i+2][3*i+2] = exp(-a*dt) ;
412 double sR = sigma_noise[i] ;
413 double sQ = sigma_state[i] ;
417 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) ) ;
418 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 ) ;
419 Q[3*i ][3*i+2] = sQ/a2*(1-exp(-2*a*dt)-2*a*dt*exp(-a*dt) ) ;
421 Q[3*i+1][3*i ] = Q[3*i ][3*i+1] ;
422 Q[3*i+1][3*i+1] = sQ/a2*(4*exp(-a*dt)-3-exp(-2*a*dt)+2*a*
dt ) ;
423 Q[3*i+1][3*i+2] = sQ/a*(exp(-2*a*dt)+1- 2*exp(-a*dt)) ;
425 Q[3*i+2][3*i ] = Q[3*i ][3*i+2] ;
426 Q[3*i+2][3*i+1] = Q[3*i+1][3*i+2] ;
427 Q[3*i+2][3*i+2] = sQ*(1-exp(-2*a*dt) ) ;
431 Pest[3*i ][3*i ] = sR ;
432 Pest[3*i ][3*i+1] = 1/dt*sR ;
433 Pest[3*i ][3*i+2] = 0 ;
435 Pest[3*i+1][3*i ] = 1/dt*sR ;
436 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));
437 Pest[3*i+1][3*i+2] = sQ/(a2*
dt)*(exp(-a*dt)+a*dt-1) ;
439 Pest[3*i+2][3*i ] = 0 ;
440 Pest[3*i+2][3*i+1] = Pest[3*i+1][3*i+2] ;
441 Pest[3*i+2][3*i+2] = 0 ;
447 Xest[3*i+1] = ( Z1[i] - Z0[i] ) /(dt ) ;
Implementation of a matrix and operations on matrices.
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
long iter
Filter step or iteration. When set to zero, initialize the filter.
unsigned int size_state
Size of the state vector .
vpMatrix inverseByLU() const
vpMatrix R
Measurement noise covariance matrix .
unsigned int size_measure
Size of the measure vector .
error that can be emited by ViSP classes.
unsigned int getRows() const
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)
void resize(unsigned int i, bool flagNullify=true)
Implementation of column vector and the associated operations.
vpMatrix H
Matrix that describes the evolution of the measurements.
vpMatrix Q
Process noise covariance matrix .