#include <visp/vpLinearKalmanFilterInstantiation.h>
#include <iostream>
#include <fstream>
int
main()
{
try {
unsigned int nsignal = 1;
unsigned int niter = 100;
std::string filename = "/tmp/log.dat";
std::ofstream flog(filename.c_str());
kalman.setStateModel(model);
unsigned int size_state_vector = kalman.getStateSize()*nsignal;
unsigned int size_measure_vector = kalman.getMeasureSize()*nsignal;
for (unsigned int signal=0; signal < nsignal; signal ++)
sigma_measure = 0.0001;
for (unsigned int signal=0; signal < nsignal; signal ++) {
sigma_state[3*signal] = 0.;
sigma_state[3*signal+1] = 0.000001;
sigma_state[3*signal+2] = 0.000001;
}
double rho = 0.9;
double dt = 0.2;
for (unsigned int signal=0; signal < nsignal; signal ++)
velocity_measure[signal] = 3+2*signal;
kalman.verbose(false);
kalman.initFilter(nsignal, sigma_state, sigma_measure, rho, dt);
for (unsigned int iter=0; iter <= niter; iter++) {
std::cout << "-------- iter " << iter << " ------------" << std::endl;
for (unsigned int signal=0; signal < nsignal; signal ++) {
velocity_measure[signal] = 3+2*signal
}
std::cout <<
"measure : " << velocity_measure.
t() << std::endl;
flog << velocity_measure.
t();
kalman.filter(velocity_measure);
std::cout <<
"Xest: " << kalman.Xest.
t() << std::endl;
std::cout <<
"Xpre: " << kalman.Xpre.
t() << std::endl;
flog << std::endl;
}
flog.close();
return 0;
}
std::cout << "Catch an exception: " << e << std::endl;
return 0;
}
}