rlabbe / filterpy

Python Kalman filtering and optimal estimation library. Implements Kalman filter, particle filter, Extended Kalman filter, Unscented Kalman filter, g-h (alpha-beta), least squares, H Infinity, smoothers, and more. Has companion book 'Kalman and Bayesian Filters in Python'.
MIT License
3.31k stars 617 forks source link

Batch filter doesn't save initial values #233

Open rlabbe opened 3 years ago

rlabbe commented 3 years ago

Consider the typical workflow:

mu, cov, _, _ = kf.batch_filter(zs[1:], saver=saver)
rxs, Ps, Ks, pPs = kf.rts_smoother(mu, cov)

We have typically initialized the KF with the first measurement or 2 measurements (to get velocity). Hence we need to skip the first measurement. So len(mu) +1 = len(zs), and the rts smoother skips the first measurement.

You can get around this by setting zs[0] to None, and update_first=True, but then the final kf state is the prior of predicting past zs, which is not the end of the world, but not awesome either.

I'm not sure what I want here. A flag to just copy the initial x, P of the kf?