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.36k stars 625 forks source link

Inability to combine filters with different models in IMM estimator #94

Closed Prokhozhijj closed 6 years ago

Prokhozhijj commented 6 years ago

Hello,

Do I understand correctly that in the current IMM estimator implementation it is impossible to combine Kalman filters with different models (I mean, for example, filter with constant velocity and filter with constant acceleration) because of the code below (it is from IMMEstimator.update method):

compute mixed initial conditions

for i, (f, w) in enumerate(zip(self.filters, omega.T)): x = np.zeros(self.x.shape) for kf, wj in zip(self.filters, w): x += kf.x * wj xs.append(x)

The matter is that each filter will have different shapes for x-property (kf.x).

Thanks for reply in advance.

rlabbe commented 6 years ago

I've been on vacation.

First, I don't really use IMMs in practice, so it is quite possible I missed something important.

I believe you just have to design the process model F correctly, For the constant velocity model you would just put zeros in the row that multiplies out the acceleration, for example. i.e, you would design x_cv = [x x' 0]^T and x_ca = [x x' x'']^T. How that would affect the computation of the acceleration of the mixed model I am not sure.

I'm unhappy with the current state of the IMM implementation and chapter in the book; if you are doing real work with these I'm particularly interested in supporting you and perhaps incorporating what you learn into both.