41 #include <visp3/core/vpDebug.h>
42 #include <visp3/core/vpException.h>
43 #include <visp3/core/vpLinearKalmanFilterInstantiation.h>
180 vpColVector &sigma_measure,
double rho,
double delta_t)
193 vpERROR_TRACE(
"Kalman state model is not set");
310 double dt2 =
dt *
dt;
311 double dt3 = dt2 *
dt;
313 for (
unsigned int i = 0; i <
size_measure * n_signal; i++) {
320 F[2 * i][2 * i + 1] =
dt;
321 F[2 * i + 1][2 * i + 1] = 1;
327 double sR = sigma_measure[i];
328 double sQ = sigma_state[2 * i];
334 Q[2 * i][2 * i] = sQ * dt3 / 3;
335 Q[2 * i][2 * i + 1] = sQ * dt2 / 2;
336 Q[2 * i + 1][2 * i] = sQ * dt2 / 2;
337 Q[2 * i + 1][2 * i + 1] = sQ *
dt;
339 Pest[2 * i][2 * i] = sR;
340 Pest[2 * i][2 * i + 1] = sR / (2 *
dt);
341 Pest[2 * i + 1][2 * i] = sR / (2 *
dt);
342 Pest[2 * i + 1][2 * i + 1] = sQ * 2 *
dt / 3.0 + sR / (2 * dt2);
508 if ((rho < 0) || (rho >= 1)) {
509 vpERROR_TRACE(
"Bad rho value %g; should be in [0:1[", rho);
525 for (
unsigned int i = 0; i <
size_measure * n_signal; i++) {
532 F[2 * i][2 * i + 1] = 1;
533 F[2 * i + 1][2 * i + 1] = rho;
539 double sR = sigma_measure[i];
540 double sQ = sigma_state[2 * i + 1];
547 Q[2 * i][2 * i + 1] = 0;
548 Q[2 * i + 1][2 * i] = 0;
549 Q[2 * i + 1][2 * i + 1] = sQ;
551 Pest[2 * i][2 * i] = sR;
552 Pest[2 * i][2 * i + 1] = 0.;
553 Pest[2 * i + 1][2 * i] = 0;
554 Pest[2 * i + 1][2 * i + 1] = sQ / (1 - rho * rho);
730 double rho,
double delta_t)
732 if ((rho < 0) || (rho >= 1)) {
733 vpERROR_TRACE(
"Bad rho value %g; should be in [0:1[", rho);
756 F[3 * i][3 * i + 1] = 1;
757 F[3 * i][3 * i + 2] =
dt;
758 F[3 * i + 1][3 * i + 1] = rho;
759 F[3 * i + 2][3 * i + 2] = 1;
766 double sR = sigma_measure[i];
767 double sQ1 = sigma_state[3 * i + 1];
768 double sQ2 = sigma_state[3 * i + 2];
774 Q[3 * i + 1][3 * i + 1] = sQ1;
775 Q[3 * i + 2][3 * i + 2] = sQ2;
777 Pest[3 * i][3 * i] = sR;
778 Pest[3 * i][3 * i + 1] = 0.;
779 Pest[3 * i][3 * i + 2] = sR /
dt;
780 Pest[3 * i + 1][3 * i + 1] = sQ1 / (1 - rho * rho);
781 Pest[3 * i + 1][3 * i + 2] = -rho * sQ1 / ((1 - rho * rho) *
dt);
782 Pest[3 * i + 2][3 * i + 2] = (2 * sR + sQ1 / (1 - rho * rho)) / (
dt *
dt);
784 Pest[3 * i + 1][3 * i] =
Pest[3 * i][3 * i + 1];
785 Pest[3 * i + 2][3 * i] =
Pest[3 * i][3 * i + 2];
786 Pest[3 * i + 2][3 * i + 1] =
Pest[3 * i + 1][3 * i + 2];
806 vpERROR_TRACE(
"Bad signal number. You need to initialize the Kalman filter");
824 vpERROR_TRACE(
"Kalman state model is not set");
831 else if (
iter == 1) {
Implementation of column vector and the associated operations.
error that can be emitted by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.
@ notInitialized
Used to indicate that a parameter is not initialized.
unsigned int size_state
Size of the state vector .
long iter
Filter step or iteration. When set to zero, initialize the filter.
vpMatrix R
Measurement noise covariance matrix .
void init(unsigned int size_state, unsigned int size_measure, unsigned int n_signal)
unsigned int nsignal
Number of signal to filter.
vpMatrix Q
Process noise covariance matrix .
void filtering(const vpColVector &z)
unsigned int size_measure
Size of the measure vector .
vpMatrix H
Matrix that describes the evolution of the measurements.
void initStateConstVel_MeasurePos(unsigned int nsignal, vpColVector &sigma_state, vpColVector &sigma_measure, double dt)
void filter(vpColVector &z)
void setStateModel(vpStateModel model)
void initStateConstAccWithColoredNoise_MeasureVel(unsigned int nsignal, vpColVector &sigma_state, vpColVector &sigma_measure, double rho, double dt)
void initFilter(unsigned int nsignal, vpColVector &sigma_state, vpColVector &sigma_measure, double rho, double dt)
@ stateConstVel_MeasurePos
@ stateConstVelWithColoredNoise_MeasureVel
@ stateConstAccWithColoredNoise_MeasureVel
void initStateConstVelWithColoredNoise_MeasureVel(unsigned int nsignal, vpColVector &sigma_state, vpColVector &sigma_measure, double rho)