#include <fstream>
#include <iostream>
#include <visp3/core/vpLinearKalmanFilterInstantiation.h>
int main()
{
try {
unsigned int nsignal = 1;
unsigned int niter = 100;
std::string filename = "/tmp/log.dat";
std::ofstream flog(filename.c_str());
unsigned int size_state_vector = kalman.
getStateSize() * 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.
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 + 0.3 * sin(
vpMath::rad(360. / niter * iter));
}
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 EXIT_SUCCESS;
std::cout << "Catch an exception: " << e << std::endl;
return EXIT_FAILURE;
}
}
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
unsigned int getMeasureSize()
unsigned int getStateSize()
This class provides an implementation of some specific linear Kalman filters.
void initFilter(unsigned int nsignal, vpColVector &sigma_state, vpColVector &sigma_measure, double rho, double dt)
void filter(vpColVector &z)
void setStateModel(vpStateModel model)
@ stateConstAccWithColoredNoise_MeasureVel
static double rad(double deg)