So now let's have a more detailed look in how we initialize the filter and what the effects of that
initialization has on the actual response of the filter.
So let's run the code as is at the moment.
So when we do this, we can see that outraced state starts up over here and shoots off in this direction.
Now the common filter starts again at our origin zero zero.
So up over here and it tracks down this way here.
But you can see there's still an error between the common filter estimate and the true state estimate.
So if we have a look at the error positions, you can see that our estimated position and our trade
position is offset.
So there's a bias in here.
So you can see that we actually have a bias position error inside our common filter response.
And this is because the common filter still starts at our origin zero zero.
But the true state doesn't start at our origin.
So I can see here the true state starts at a non-zero value of about one hundred here and another hundred
here, whereas our Common Filter estimate starts at zero zero.
So this bias in the initial state causes this buys over long term.
This is because the initial position of the filter estimate is outside the uncertainty bubble of the
initial covariance.
So the filter is inconsistent at this stage.
So you can say here he is, a three sigma uncertainty bounds for the position in the X and this is one
for the Y.
And you can see in both cases the error is outside these bounds.
So the filter is inconsistent.
So the filter does not have enough uncertainty inside the system to let the system actually catch up
with the true state and converge to the true state.
So how we set the initial conditions is quite important in terms of the overall field of performance.
If we had to sort of like this, this tracking filter would not work properly.
It would give us the wrong result.
So one easy fix of this is to set the initial standard deviation for the position to be a large value
such that when we start at a non-zero origin location, it will be inside the uncertainty bubble.
So the filter will be consistent.
So let's try this again.
Aha, so now you can see that the filter is tracking the story straight pretty well, where you can
have a look at precision error and was the you can see now that the position starts at a non-zero value.
It's still withinside uncertainty bubble here for the X and for the Y.
So I can see that as we get measurements, it converges down quite nicely.
And he can see our initial filter started out with zero zero position.
But since the uncertainty of our initial estimate is so large, it allows the filter to quickly adapt
when we get the first measurement and start tracking nicely along the actual motion of the object.
So whenever we initialize a filter, we always want to make sure that the filter is as consistent as
possible.
We want to make sure that the true state, which we don't know, is withinside our uncertainty bubble
around our estimated position.
This makes a filter consistent and this will make the filter work correctly.
So this step relied on us initializing a filter at TimeStep zero before we get any information about
the system, but this might not be the best way to go about it, depending on the application.
Devanny of this is that it allows the filter to start running from T was not.
But the information that is providing at the initial time might not be relevant for what we want to
use the information from or if it's controlling the heading of the vehicle and we stay at the heading
of zero.
But a vehicle is really traveling at 180 degrees from that.
Then any information we get from this filter is going to be wrong into the filter converges to the true
value.
But during this time we can't use that information.
So even though we start the filter, so even though we start the filter at tale's not, we can't use
the information from the filter until the filter has converged.
A different way to approach this problem is to use delayed initialization, so instead of initializing
the filter at time zero, we initialize the filter on the first measurement and then we can actually,
instead of setting our initial origin position to be zero zero, we can set up to the first position
measurement.
So we get the MPI from the measurement.
So let's have a look at that.
So if we comment out this part of the code here.
So we now are using delayed initialization inside the step down here where we initialize our state from
the first measurement and we initialize our covariance for the position from the matrix.
So the sentence and measurement, noise, uncertainty.
And then we set an initial velocity variance, just like we did before, to a constant value of ten
standard deviation.
So now if we run this.
You can see the filter is working quite nicely, and in fact, you can see that we don't start off with
a large error.
We always start off with innovation being consistent with our measurement covariance.
And if you look at our position errors, you can see that now we have a very sort of smaller position,
error position errors inside the bounds and the initial bounds are a lot smaller.
The uncertainty bounds are a lot smaller.
So if we use this condition, even though we don't start at Tegus not, we still have a bit of a delay
between here and the first measurement.
As soon as we start running the filter, the information that the field is providing is pretty good.
It allows us to use this information directly from this time forward, inside an additional process
or whatever we're trying to control or estimate.
Whereas if we start to filter from agency recognition, we'll have to wait for the filter to converge
before we get good information about the positions.
So hopefully this should have given you a bit of an overview of two different ways that we can start
or initialize the filter.
One is to assume a initial condition that works for all conditions and let the uncertainty bubble around
that be large enough to actually encompass the truth.
Or the second way is to use the first measurement information and use that to initialize the state using
this known information.