We are now going to have a look at the initial conditions of the filter and how these initial conditions
or what we set the measures are going to affect the filters performance.
So in this exercise, we're going to implement filter state and covariance initialization on first measurement
rather than the first time sample.
So to do this, first off, we want to open up the Python file assignment one on the score initial on
the school conditions.
We want to run the simulation as is, and we can see that the object does not start at the origin.
So Peiyi and Paycheck's do not equal zero zero, but it starts at a random location that changes every
time you run the front of the file and it moves in a random direction and speed.
So if we run the simulation, what does the common filter response actually look like if we just use
the code from the previous assignment?
Now, the next step in the exercise is to set a non-zero initial covariance for the position, and then
we want to rerun the simulation and notice the new response.
So inside the initialization function, we have these variables for our position, standard deviation
and velocity, standard deviation for the initial covariance.
So what we want to do is basically we want to set the initial position, uncertainty, these two values
here controlled by this unit, standard deviation.
We want to get set them to a non-zero value.
This is basically telling us that this is basically telling Fuda that it does not know the position.
Exactly.
So when we set the initial position to be zero zero inside the vector, it tells the field that we are
not absolutely certain about the state.
So we're not absolutely certain that the state actually starts at zero zero, but we have some uncertainty
around it.
So this is what these parameters here control.
So if we do this and rerun this simulation, what happens to the response to the filter?
So in the example that we lost, implemented, we initialize the filter at time equals zero, and we
basically said the initial state is zero zero zero zero and the initial covariance is basically a diagonal
matrix that has some uncertainty in the position elements and some uncertainty in the velocity elements.
So this is one way to initialize the filter.
But depending on how the filter is used or what system the field is used in, there potentially is better
ways of doing this.
And another way of doing this is to initialize the filter on the first update.
So the first time we get a measurement in, we want to start the filter from that measurement.
So what would that would look like would be when we get the first measurement or the first update,
we want to set our X Factor to basically be that position measurement.
So we have the XP Y from the sensor and then 004 velocity.
When we do this, we can set the uncertainty for position being our sensor measurement uncertainty,
which is R and then we just set an initial velocity uncertainty just like we did in when we initialize
the filter on up.
So basically what this is doing is initializing the filter from the first time it gets any real information
about the system.
If you initialize a time, it goes zero.
You're making you're making all these assumptions about the initial side of the system, which might
not be correct.
So for step three, we want to use delayed initialization and we want to initialize the filter on the
first measurement.
So to do this in code first step is to comment about the filter initialization inside the initialization
function.
So coming out the state and the covariance, then we want to go down and initialize the field of state
and a variance on the first update.
So inside the update step here, you can see that this first step here checks out.
The field is initialized.
So we want to actually add in a new line here.
So if we're not initialized, we want to use the measurement information.
We want to set the initial state and covariance using the equations we had on the other slide before.
Once you've done this, rerun the simulation and notice the new response of the system.