# Some Kalman filter implementation queries

Just to clear some doubts:

Qn 1. Does kalman filter require constant time step?

From my own study, it does not seem necessary to have a constant time step. You just need to take into account time interval between steps with the prediction steps

Qn 2. What if you need to have an output at constant time interval but only have measurements at irregular interval, say your timestep is at 0.5s but your measurement only comes around 1.5-3s

Does the conventional approach normally output the last kalman filtered result(doing prediction and measurement) at 0.5s or could they interpolate the result by kalman filter(doing only prediction and not measurement)?

1. Is there some form of implementation? (with code I can referred to?)
2. Or what other measures do people normally adopt?

Qn 3. If the measurements is irregularly timed and possibly delayed result say the measurements at 50s give actual reading of 49s result. What should we do?

The first idea I can think of is to increase measurement covariance. Am I right? What else can I do?

THanks

Qn 1. Does kalman filter require constant time step?

Correct it does not. The reason you may find in literature that it requires a constant time step has to do with with lack of computing power in the 60s-90s and the discretization of a continuous system. You can read more about this in something like this, or other books that deal with Kalman filters.

Essentially it boils down to computing $$e^{AT}$$ for every $$T$$. If you use a constant timestep you can compute this value once, and just reuse it.

Qn 2. What if you need to have an output at constant time interval but only have measurements at irregular interval, say your timestep is at 0.5s but your measurement only comes around 1.5-3s

You use whatever the last value was computed. That can come from either the measurement or the prediction step. No interpolation or anything else weird. Literally just the last value. The whole purpose of the prediction step is that it should accurately reflect how your model evolves with time.

Qn 3. If the measurements is irregularly timed and possibly delayed result say the measurements at 50s give actual reading of 49s result. What should we do?

There are a ton of different ways to deal with this and it is still an active area of research. I would say the easiest are the following options.

### Constant Known time delay

If you know what the time delay is, and it is constant then take that into account in your implementation of prediction and measurement updates. E.g if your measurement update is actually measured at 49s, then only run a prediction up to 49s.

### Time delay in filter

You can add the time delay as a state in your filter. You then hold off on predicting until you receive a measurement. You then run the prediction step up until $$t_m+t_d$$, and then run the measurement update. Note your measurement update has to somehow be able to also measure the time delay.

Here $$t_m$$ is your time of measurement, and $$t_d$$ is your time delay.

If you do need the predicted state value, at some earlier point then you run prediction as normal, except store the output somewhere differently.

### Rolling back Kalman Filter state.

If your implementation is a Linear System, and able to be modeled by a Kalman Filter and not an EKF, then you can do some magic with reversing the state to a previous value. You would have to do some research on this cause I don't know how it is actually done in practice.

• Thanks for the answer! Just some clarifications for Question 2. So the output will be computed as: [KF_(t-1), KF_(t-1), KF_(t-1), KF_(t), KF_(t)..........]. with each comma-separated result at 0.5s and t-step being 1.5s. – user1538798 Jan 15 at 0:21
• Add on for point 2. Is there implementation like [KF_(t-1), extrapolate, extrapolate, KF_(t), ......] ? – user1538798 Jan 15 at 0:23
• It should be this [KF_(t-1), KF_(t-1), KF_(t-1), KF_(t), KF_(t-1)..........]. After a measurement occurs and you move forward in time then you have to "predict" again. There is no extrapolation. The "prediction" step is essentially your extrapolation. – edwinem Jan 15 at 0:36
• Thanks for your answer.... the last output you wrote... [,....., KF_(t), KF_(t-1)] is a typo error? Should it be [........., KF_(t), KF_(t).....]? – user1538798 Jan 15 at 1:25
• No. Assuming every value is at a new timestamp, and (t) is a measurement and (t-1) is a prediction. After KF_(t) you then have to predict again. – edwinem Jan 15 at 17:31