## 02ps-12 Programming Exercise Solution

• 0:00 - 0:03
Here's my solution for the programming assignment.
• 0:03 - 0:06
There are many different ways to structure this, but that's what I've done.
• 0:06 - 0:09
I have a dt equals 0.1.
• 0:09 - 0:13
I set my initial state vector to be the initial x and y coordinates,
• 0:13 - 0:17
and for the two velocities I set them both to 0.
• 0:17 - 0:21
My u vector, as I said in the statement of the problem, is zero everywhere,
• 0:21 - 0:23
so just ignore it.
• 0:23 - 0:28
Interesting is my P matrix that measures the uncertainty.
• 0:28 - 0:31
I set the uncertainty initially for the locations to be zero.
• 0:31 - 0:33
These are the two main diagonal elements over here,
• 0:33 - 0:37
and the uncertainty for the velocity is to be really high--it's 1000.
• 0:37 - 0:39
So this is my initial uncertainty matrix.
• 0:39 - 0:43
That guarantees that I can really estimate the velocity based on data,
• 0:43 - 0:46
and I believe the initial state estimates are correct.
• 0:46 - 0:50
Our F matrix is a 4-dimensional generalization of the F matrix we had before
• 0:50 - 0:53
where we have 1 along the main diagonal.
• 0:53 - 0:58
This one says that the position is retained in expectation and the velocity is retained,
• 0:58 - 1:01
and we have two dt's over here.
• 1:01 - 1:04
The x dot, which is my third state vector influences
• 1:04 - 1:08
the x by a factor of dt for each time stamp.
• 1:08 - 1:10
The same is true for y dot.
• 1:10 - 1:15
These are the places where our velocities impact our position estimate.
• 1:15 - 1:21
As I scroll down, the H matrix is a 4 x 2 projection matrix
• 1:21 - 1:26
where we project out the x dimension and the y dimension without any velocities.
• 1:26 - 1:29
For the measurement uncertainty I assume
• 1:29 - 1:33
that each measurement has uncertainty covariance of 0.1,
• 1:33 - 1:38
and these are along the main diagonal of the 2 x 2 measurement noise uncertainty matrix.
• 1:38 - 1:43
This is obviously how a 4-dimensional identity matrix looks over here.
• 1:43 - 1:49
If I run this for my first example where the measurements are 5, 6, 7, 8, 9, and 10,
• 1:49 - 1:54
and the second dimension is 10, 8, 6, 4, and 2 and you can't see it but it's 0 over here.
• 1:54 - 2:03
In my output, I correctly get the estimate of 10 for my x and 0 for my y.
• 2:03 - 2:06
Velocity is 10 and -20.
• 2:06 - 2:10
As we had before, because dt equals 0.1,
• 2:10 - 2:13
a step from 5 to 6 within a 10th of a time unit
• 2:13 - 2:17
requires velocity of 10 and from 10 to 8 one of 20.
• 2:17 - 2:19
These numbers are correct.
• 2:19 - 2:21
But we want to look at the covariance matrix.
• 2:21 - 2:26
It's hard to read anything off it other than we are fairly certain as to what our location is,
• 2:26 - 2:29
and we have a fairly good estimate of what our velocities are.
• 2:29 - 2:32
Our covariance of velocity uncertainty is 0.1, and this is down from 1000,
• 2:32 - 2:36
which was the initial value in these uncertainties.
• 2:36 - 2:39
Going to the second example, I now commented away
• 2:39 - 2:42
the first example and put in place a second example.
• 2:42 - 2:48
If I run it again, here we see the first dimension go for -4, 1, 6, 11, 16.
• 2:48 - 2:51
The second dimension 8, 4, 0, -4, -8.
• 2:51 - 2:55
These are the exact same values over here--16 and -8.
• 2:55 - 3:00
For velocities I get 50 and -40, which are exactly the correct velocities.
• 3:00 - 3:05
Finally, for our third example, where the first coordinate doesn't change at all,
• 3:05 - 3:09
we get the correct 1 over here and velocity of 0.
• 3:09 - 3:12
Second coordinate goes from 19, 17 all the way to 11.
• 3:12 - 3:15
We get 11 over here and velocity of -20.
• 3:15 - 3:18
This is the implementation I wanted you to do.
• 3:18 - 3:22
If you implemented this thing over here, you got it right
• 3:22 - 3:27
and congratulations--you implemented a fairly nontrivial Kalman filter in stages,
• 3:27 - 3:30
but through this class, we now have code that allows you
• 3:30 - 3:33
to run Kalman filters on complicated problems,
• 3:33 -
and I hope you really got an understanding how the Kalman filter works.
Title:
02ps-12 Programming Exercise Solution
Description:

dummy description

more » « less
Video Language:
English
Team:
Udacity
Project:
CS373 - Artificial Intelligence
Duration:
03:36