43 #include <visp3/core/vpLinearKalmanFilterInstantiation.h>
47 #ifdef ENABLE_VISP_NAMESPACE
52 unsigned int nsignal = 1;
53 unsigned int niter = 100;
55 std::string filename =
"/tmp/log.dat";
56 std::ofstream flog(filename.c_str());
64 unsigned int size_state_vector = kalman.
getStateSize() * nsignal;
65 unsigned int size_measure_vector = kalman.
getMeasureSize() * nsignal;
68 for (
unsigned int signal = 0; signal < nsignal; signal++)
69 sigma_measure = 0.0001;
71 for (
unsigned int signal = 0; signal < nsignal; signal++) {
72 sigma_state[3 * signal] = 0.;
73 sigma_state[3 * signal + 1] = 0.000001;
74 sigma_state[3 * signal + 2] = 0.000001;
82 for (
unsigned int signal = 0; signal < nsignal; signal++)
83 velocity_measure[signal] = 3 + 2 * signal;
86 kalman.
initFilter(nsignal, sigma_state, sigma_measure, rho, dt);
88 for (
unsigned int iter = 0; iter <= niter; iter++) {
89 std::cout <<
"-------- iter " << iter <<
" ------------" << std::endl;
90 for (
unsigned int signal = 0; signal < nsignal; signal++) {
91 velocity_measure[signal] = 3 + 2 * signal + 0.3 * sin(
vpMath::rad(360. / niter * iter));
93 std::cout <<
"measure : " << velocity_measure.t() << std::endl;
95 flog << velocity_measure.t();
98 kalman.
filter(velocity_measure);
99 flog << kalman.
Xest.
t();
100 flog << kalman.
Xpre.
t();
102 std::cout <<
"Xest: " << kalman.
Xest.
t() << std::endl;
103 std::cout <<
"Xpre: " << kalman.
Xpre.
t() << std::endl;
112 std::cout <<
"Catch an exception: " << e << std::endl;
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 filter(vpColVector &z)
void setStateModel(vpStateModel model)
void initFilter(unsigned int nsignal, vpColVector &sigma_state, vpColVector &sigma_measure, double rho, double dt)
@ stateConstAccWithColoredNoise_MeasureVel
static double rad(double deg)