[Script Info]
Title:
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:00:03.00,Default,,0000,0000,0000,,Let's now come to our programming exercise
Dialogue: 0,0:00:03.00,0:00:08.00,Default,,0000,0000,0000,,I want you to program exactly what we just talked about.
Dialogue: 0,0:00:08.00,0:00:11.00,Default,,0000,0000,0000,,We're given a two-dimensional world
Dialogue: 0,0:00:11.00,0:00:18.00,Default,,0000,0000,0000,,where we observe in 2D measurements of a moving object
Dialogue: 0,0:00:18.00,0:00:21.00,Default,,0000,0000,0000,,with an unknown but fixed velocity.
Dialogue: 0,0:00:21.00,0:00:27.00,Default,,0000,0000,0000,,Using a state vector of this type, I'd like you to implement the Kalman filter.
Dialogue: 0,0:00:27.00,0:00:30.00,Default,,0000,0000,0000,,Now, this Kalman filter now has 4 state variables
Dialogue: 0,0:00:30.00,0:00:33.00,Default,,0000,0000,0000,,whereas the one we used before had 2 state variables.
Dialogue: 0,0:00:33.00,0:00:36.00,Default,,0000,0000,0000,,I will give you the entire code for the Kalman filter,
Dialogue: 0,0:00:36.00,0:00:52.00,Default,,0000,0000,0000,,but I want you to set up the state vector x, the motion u, P, F, H, R, and I,
Dialogue: 0,0:00:52.00,0:00:57.00,Default,,0000,0000,0000,,which are all those variables that define the Kalman filter.
Dialogue: 0,0:00:57.00,0:01:01.00,Default,,0000,0000,0000,,Start with the assignment that we had in 2D
Dialogue: 0,0:01:01.00,0:01:05.00,Default,,0000,0000,0000,,and make it work in 4D.
Dialogue: 0,0:01:05.00,0:01:10.00,Default,,0000,0000,0000,,Here is exactly the same matrix class that I wrote you before.
Dialogue: 0,0:01:10.00,0:01:14.00,Default,,0000,0000,0000,,Here is the Kalman filter procedure.
Dialogue: 0,0:01:14.00,0:01:18.00,Default,,0000,0000,0000,,We'll go through our measurements and apply the Kalman filter equations.
Dialogue: 0,0:01:18.00,0:01:21.00,Default,,0000,0000,0000,,I should point out there's a slight difference to the code I gave you previously
Dialogue: 0,0:01:21.00,0:01:24.00,Default,,0000,0000,0000,,where I insert a zeta transpose.
Dialogue: 0,0:01:24.00,0:01:29.00,Default,,0000,0000,0000,,It makes it a little bit easier to work with multidimensional measurements than how I had it before.
Dialogue: 0,0:01:29.00,0:01:33.00,Default,,0000,0000,0000,,But you don't have to pay attention to this. It's just fixed. There was a kind of a bug before.
Dialogue: 0,0:01:33.00,0:01:40.00,Default,,0000,0000,0000,,As I scroll down, the output of the Kalman filter routine will be an x and a P.
Dialogue: 0,0:01:40.00,0:01:43.00,Default,,0000,0000,0000,,In our example, the measurements will be a sequence of measurements
Dialogue: 0,0:01:43.00,0:01:46.00,Default,,0000,0000,0000,,in two-dimensional spaces now--in x and y.
Dialogue: 0,0:01:46.00,0:01:49.00,Default,,0000,0000,0000,,Look at the x's 5, 6, 7, 8, 9, and 10.
Dialogue: 0,0:01:49.00,0:01:53.00,Default,,0000,0000,0000,,The y's go 10, 8, 6, 4, and 2.
Dialogue: 0,0:01:53.00,0:01:56.00,Default,,0000,0000,0000,,You can imagine what the regularity is and what the velocity is.
Dialogue: 0,0:01:56.00,0:02:00.00,Default,,0000,0000,0000,,We assume a dt of 0.1.
Dialogue: 0,0:02:00.00,0:02:04.00,Default,,0000,0000,0000,,That means when it goes from 5 to 6 the velocity is actually 10, not 1.
Dialogue: 0,0:02:04.00,0:02:09.00,Default,,0000,0000,0000,,We won't tell the system, but we will tell the system our initial x,y location, which is 4.
Dialogue: 0,0:02:09.00,0:02:16.00,Default,,0000,0000,0000,,That goes nicely into 5, 6, 7, and it's 12. That blends nicely into 10, 8, and 6.
Dialogue: 0,0:02:16.00,0:02:20.00,Default,,0000,0000,0000,,Our initial state vector I have already given you, which is the initial x and y.
Dialogue: 0,0:02:20.00,0:02:24.00,Default,,0000,0000,0000,,and 0, 0 for the two unknown velocities.
Dialogue: 0,0:02:24.00,0:02:29.00,Default,,0000,0000,0000,,The motion vector, just for completeness, will just be 0, 0, 0, 0.
Dialogue: 0,0:02:29.00,0:02:31.00,Default,,0000,0000,0000,,We have no external motion.
Dialogue: 0,0:02:31.00,0:02:35.00,Default,,0000,0000,0000,,That's a bit confusing, because there is actually motion in the system itself,
Dialogue: 0,0:02:35.00,0:02:38.00,Default,,0000,0000,0000,,but this will be more like an external change of the motion
Dialogue: 0,0:02:38.00,0:02:41.00,Default,,0000,0000,0000,,as if someone hit the object with an external force.
Dialogue: 0,0:02:41.00,0:02:43.00,Default,,0000,0000,0000,,So it's 0, 0, 0, 0--please don't change it.
Dialogue: 0,0:02:43.00,0:02:46.00,Default,,0000,0000,0000,,P is the initial uncertainty,
Dialogue: 0,0:02:46.00,0:02:51.00,Default,,0000,0000,0000,,and I want you to initialize it so that the uncertainty for the x,y coordinates is zero,
Dialogue: 0,0:02:51.00,0:02:56.00,Default,,0000,0000,0000,,but the covariance term for the velocities is 1000,
Dialogue: 0,0:02:56.00,0:02:59.00,Default,,0000,0000,0000,,indicating that we really don't know the initial velocity.
Dialogue: 0,0:02:59.00,0:03:01.00,Default,,0000,0000,0000,,We just know the initial position.
Dialogue: 0,0:03:01.00,0:03:04.00,Default,,0000,0000,0000,,I want you to plug in the f matrix.
Dialogue: 0,0:03:04.00,0:03:07.00,Default,,0000,0000,0000,,I want you to design an H matrix that's a projection matrix
Dialogue: 0,0:03:07.00,0:03:10.00,Default,,0000,0000,0000,,from 4-dimensional state space to 2 dimensions,
Dialogue: 0,0:03:10.00,0:03:14.00,Default,,0000,0000,0000,,reflecting the fact that we can only observe the first two state variables--x and y--
Dialogue: 0,0:03:14.00,0:03:16.00,Default,,0000,0000,0000,,but not the velocities.
Dialogue: 0,0:03:16.00,0:03:20.00,Default,,0000,0000,0000,,I want you to define the measurement uncertainty matrix, which now is a 2 x 2
Dialogue: 0,0:03:20.00,0:03:25.00,Default,,0000,0000,0000,,that has 0.1 as the main diagonal as measurement noise.
Dialogue: 0,0:03:25.00,0:03:27.00,Default,,0000,0000,0000,,This is an identity matrix over here.
Dialogue: 0,0:03:27.00,0:03:33.00,Default,,0000,0000,0000,,Once you design all those, you should get the following output.
Dialogue: 0,0:03:33.00,0:03:36.00,Default,,0000,0000,0000,,So when I run this, I get as an output
Dialogue: 0,0:03:36.00,0:03:42.00,Default,,0000,0000,0000,,for my 4-dimensional example the x coordinates 10 and 0.
Dialogue: 0,0:03:42.00,0:03:46.00,Default,,0000,0000,0000,,This makes sense given that these sequences over here
Dialogue: 0,0:03:46.00,0:03:55.00,Default,,0000,0000,0000,,has a final measurement 10 and 0--5, 6, 7, 8, 9, 10--10, 8, 6, 4, 2, 0.
Dialogue: 0,0:03:55.00,0:04:00.00,Default,,0000,0000,0000,,The interesting thing that I want your program to produce is the velocities.
Dialogue: 0,0:04:00.00,0:04:06.00,Default,,0000,0000,0000,,They are approximately 10, which makes sense given out delta-t of 0.1
Dialogue: 0,0:04:06.00,0:04:12.00,Default,,0000,0000,0000,,gives us per time step a 10 divided by 10 equals 1 increment over here.
Dialogue: 0,0:04:12.00,0:04:17.00,Default,,0000,0000,0000,,The second velocity is -20 multiplied by 0.1 gives us a -2.
Dialogue: 0,0:04:17.00,0:04:21.00,Default,,0000,0000,0000,,You can see it over here--10, 8, 6, 4, and 2.
Dialogue: 0,0:04:21.00,0:04:25.00,Default,,0000,0000,0000,,I also want you to output the covariance matrix,
Dialogue: 0,0:04:25.00,0:04:29.00,Default,,0000,0000,0000,,which has certain elements that are still 0, like these guys over here.
Dialogue: 0,0:04:29.00,0:04:34.00,Default,,0000,0000,0000,,We find that along the main diagonal our uncertainty has shrunk substantially.
Dialogue: 0,0:04:34.00,0:04:40.00,Default,,0000,0000,0000,,It's 0.03 for the coordinate estimates and 0.1 for the velocity estimates.
Dialogue: 0,0:04:40.00,0:04:44.00,Default,,0000,0000,0000,,Remember, this number over here was 1000 before.
Dialogue: 0,0:04:44.00,0:04:48.00,Default,,0000,0000,0000,,Here is a second example where we have an initial coordinate of -4 and 8.
Dialogue: 0,0:04:48.00,0:04:52.00,Default,,0000,0000,0000,,We can see the measurements 1, 6, 11, 16.
Dialogue: 0,0:04:52.00,0:04:55.00,Default,,0000,0000,0000,,It seems the increments are in x direction 5.
Dialogue: 0,0:04:55.00,0:05:00.00,Default,,0000,0000,0000,,In the y direction they are -4--8, 4, 0, -4, -8.
Dialogue: 0,0:05:00.00,0:05:06.00,Default,,0000,0000,0000,,If I now run this, I get for my x vector approximately 16--the number over here,
Dialogue: 0,0:05:06.00,0:05:08.00,Default,,0000,0000,0000,,approximately -8--the number over here.
Dialogue: 0,0:05:08.00,0:05:13.00,Default,,0000,0000,0000,,These are velocities--50 and -40 in approximation,
Dialogue: 0,0:05:13.00,0:05:21.00,Default,,0000,0000,0000,,which multiplied with 0.1 is our plus 5 and our -4.
Dialogue: 0,0:05:21.00,0:05:25.00,Default,,0000,0000,0000,,Here is yet another example. Initial state 1 and 19.
Dialogue: 0,0:05:25.00,0:05:29.00,Default,,0000,0000,0000,,You can see the first coordinate doesn't change at all. You should get a velocity of 0.
Dialogue: 0,0:05:29.00,0:05:34.00,Default,,0000,0000,0000,,The second coordinate goes 19, 17, 15, 13, and 11.
Dialogue: 0,0:05:34.00,0:05:39.00,Default,,0000,0000,0000,,Running it gives us 1--unchanged--and 11.
Dialogue: 0,0:05:39.00,0:05:43.00,Default,,0000,0000,0000,,Velocities are 0 and -20 for the decrements of -2.
Dialogue: 0,0:05:43.00,0:05:50.00,Default,,0000,0000,0000,,Going into the covariance, we see values along the main diagonals--
Dialogue: 0,0:05:50.00,0:05:55.00,Default,,0000,0000,0000,,0.05, 0.05, 0.33, and 0.33 for the velocities.
Dialogue: 0,0:05:55.00,0:05:58.00,Default,,0000,0000,0000,,There are certain off-diagonal elements.
Dialogue: 0,0:05:58.00,0:06:03.00,Default,,0000,0000,0000,,Make sure those all match what your code produces.
Dialogue: 0,0:06:03.00,0:06:08.00,Default,,0000,0000,0000,,I can now change some of these measurements to make a noisy measurement.
Dialogue: 0,0:06:08.00,0:06:12.00,Default,,0000,0000,0000,,One way to do this is to set an oscillating measurement between 2 and 0.
Dialogue: 0,0:06:12.00,0:06:15.00,Default,,0000,0000,0000,,Remember that this Kalman filter assumes a fixed velocity.
Dialogue: 0,0:06:15.00,0:06:20.00,Default,,0000,0000,0000,,There is no way to explain these measurements with a fixed velocity,
Dialogue: 0,0:06:20.00,0:06:22.00,Default,,0000,0000,0000,,so there has to be measurement noise.
Dialogue: 0,0:06:22.00,0:06:24.00,Default,,0000,0000,0000,,We can run the Kalman filter again.
Dialogue: 0,0:06:24.00,0:06:27.00,Default,,0000,0000,0000,,Your filter should output the following values:
Dialogue: 0,0:06:27.00,0:06:34.00,Default,,0000,0000,0000,,0.7 for the current state, 11 as before, and here are our two velocity estimates.
Dialogue: 0,0:06:34.00,0:06:41.00,Default,,0000,0000,0000,,It actually believes there is a slight velocity of -0.66
Dialogue: 0,0:06:41.00,0:06:42.00,Default,,0000,0000,0000,,in the x direction where we had noisy sensor input.
Dialogue: 0,0:06:42.00,0:06:45.00,Default,,0000,0000,0000,,The covariance matrix would look exactly as before,
Dialogue: 0,0:06:45.00,0:06:48.00,Default,,0000,0000,0000,,because it's not affected by the measurements themselves.
Dialogue: 0,0:06:48.00,9:59:59.99,Default,,0000,0000,0000,,Your job is to fill in these various matrices. Good luck.