Kalman filters and missing measurements

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Kalman filters and missing measurements

lindley.french
Let's say I have a cvKalman filter and a series of measurements at times t=1,2,3,4,5, etc.

I know how to set up the Kalman filter's fields, and that typically usage would be an alternating series of cvKalmanPredict() and cvKalmanUpdate() calls.

But what if I have no measurement at time t=3? I can't call update with something that isn't there, yet I still want to generate a reasonable prediction at t=4.

Looking at the code, it does not appear that simply calling cvKalmanPredict() twice will have the desired result. Predict() will always return the same thing until an Update() occurs. Thus t=4 would be stuck using the prediction from t=3, which is not what I want!

Are there any plans for generalizing the cvKalman functionality to allow this usage? Anything currently exist to facilitate it? Or will I just have to code something myself?

Reply | Threaded
Open this post in threaded view
|

Re: Kalman filters and missing measurements

규형
I had the same problem before.

Even though it seemed to be right if we take prediction of the states for frames of missing measurements based on the dynamics(velocity and acceleration), I just use the same prediction which means no velocity and acceleration, because (1) I did not know what is the right way for this case (Even though I use dynamics, what should I do on the uncertainty(covariance matrix) ?) (2) I did not think I could modify openCV source (3) using dynamic model for long missing measurements seemed to be dangerous for me.

--- In [hidden email], "lindley.french" <lfrench1@...> wrote:

>
> Let's say I have a cvKalman filter and a series of measurements at times t=1,2,3,4,5, etc.
>
> I know how to set up the Kalman filter's fields, and that typically usage would be an alternating series of cvKalmanPredict() and cvKalmanUpdate() calls.
>
> But what if I have no measurement at time t=3? I can't call update with something that isn't there, yet I still want to generate a reasonable prediction at t=4.
>
> Looking at the code, it does not appear that simply calling cvKalmanPredict() twice will have the desired result. Predict() will always return the same thing until an Update() occurs. Thus t=4 would be stuck using the prediction from t=3, which is not what I want!
>
> Are there any plans for generalizing the cvKalman functionality to allow this usage? Anything currently exist to facilitate it? Or will I just have to code something myself?
>


Reply | Threaded
Open this post in threaded view
|

Re: Kalman filters and missing measurements

afb1022
I don't use OpenCV Kalman but I do know Kalman filtering.  I assume that in each update you can specify the variance of the measurement noise. Or at least you can change it before an update if it is not constant.  For a missing measurement, just use the last state estimate as a measurement but set the covariance matrix of the measurement to essentially infinity.  (If the system uses inverse covariance just set the values to zero.)  This would cause a Kalman filter to essentially ignore the new measurement since the ratio of the variance of the prediction to the measurement is zero.  The result will be a new prediction that maintains velocity/acceleration but whose variance will grow according to the process noise.

Hope that helps. - afb


> --- In [hidden email], "lindley.french" <lfrench1@> wrote:
> >
> > Let's say I have a cvKalman filter and a series of measurements at times t=1,2,3,4,5, etc.
> >
> > I know how to set up the Kalman filter's fields, and that typically usage would be an alternating series of cvKalmanPredict() and cvKalmanUpdate() calls.
> >
> > But what if I have no measurement at time t=3? I can't call update with something that isn't there, yet I still want to generate a reasonable prediction at t=4.
> >
> > Looking at the code, it does not appear that simply calling cvKalmanPredict() twice will have the desired result. Predict() will always return the same thing until an Update() occurs. Thus t=4 would be stuck using the prediction from t=3, which is not what I want!
> >
> > Are there any plans for generalizing the cvKalman functionality to allow this usage? Anything currently exist to facilitate it? Or will I just have to code something myself?
> >
>


Reply | Threaded
Open this post in threaded view
|

Re: Kalman filters and missing measurements

lindley.french
Indeed it does, but as it happens I've found a simpler approach. If you take the "infinite measurement error" concept and propagate it through the Kalman equations, I'm fairly certain you find that the Update (cvKalmanCorrect) step reduces to

state_post <- state_pre
cov_post <- cov_pre

Which suggests the following function:

void cvKalmanNoObservation(CvKalman* kalman)
{
    cvCopy(kalman->error_cov_pre, kalman->error_cov_post);
    cvCopy(kalman->state_pre, kalman->state_post);
}

--- In [hidden email], "afb1022" <afb@...> wrote:

>
> I don't use OpenCV Kalman but I do know Kalman filtering.  I assume that in each update you can specify the variance of the measurement noise. Or at least you can change it before an update if it is not constant.  For a missing measurement, just use the last state estimate as a measurement but set the covariance matrix of the measurement to essentially infinity.  (If the system uses inverse covariance just set the values to zero.)  This would cause a Kalman filter to essentially ignore the new measurement since the ratio of the variance of the prediction to the measurement is zero.  The result will be a new prediction that maintains velocity/acceleration but whose variance will grow according to the process noise.
>
> Hope that helps. - afb
>
>
> > --- In [hidden email], "lindley.french" <lfrench1@> wrote:
> > >
> > > Let's say I have a cvKalman filter and a series of measurements at times t=1,2,3,4,5, etc.
> > >
> > > I know how to set up the Kalman filter's fields, and that typically usage would be an alternating series of cvKalmanPredict() and cvKalmanUpdate() calls.
> > >
> > > But what if I have no measurement at time t=3? I can't call update with something that isn't there, yet I still want to generate a reasonable prediction at t=4.
> > >
> > > Looking at the code, it does not appear that simply calling cvKalmanPredict() twice will have the desired result. Predict() will always return the same thing until an Update() occurs. Thus t=4 would be stuck using the prediction from t=3, which is not what I want!
> > >
> > > Are there any plans for generalizing the cvKalman functionality to allow this usage? Anything currently exist to facilitate it? Or will I just have to code something myself?
> > >
> >
>