1
00:00:03,910 --> 00:00:08,530
We are now going to have a look at the initial conditions of the filter and how these initial conditions

2
00:00:08,530 --> 00:00:11,580
or what we set the measures are going to affect the filters performance.

3
00:00:12,760 --> 00:00:18,730
So in this exercise, we're going to implement filter state and covariance initialization on first measurement

4
00:00:19,000 --> 00:00:20,920
rather than the first time sample.

5
00:00:21,460 --> 00:00:27,070
So to do this, first off, we want to open up the Python file assignment one on the score initial on

6
00:00:27,080 --> 00:00:28,060
the school conditions.

7
00:00:29,330 --> 00:00:34,300
We want to run the simulation as is, and we can see that the object does not start at the origin.

8
00:00:34,300 --> 00:00:41,620
So Peiyi and Paycheck's do not equal zero zero, but it starts at a random location that changes every

9
00:00:41,620 --> 00:00:47,050
time you run the front of the file and it moves in a random direction and speed.

10
00:00:47,560 --> 00:00:53,170
So if we run the simulation, what does the common filter response actually look like if we just use

11
00:00:53,170 --> 00:00:54,730
the code from the previous assignment?

12
00:00:56,490 --> 00:01:02,340
Now, the next step in the exercise is to set a non-zero initial covariance for the position, and then

13
00:01:02,340 --> 00:01:05,520
we want to rerun the simulation and notice the new response.

14
00:01:06,360 --> 00:01:11,970
So inside the initialization function, we have these variables for our position, standard deviation

15
00:01:11,970 --> 00:01:15,600
and velocity, standard deviation for the initial covariance.

16
00:01:16,230 --> 00:01:21,750
So what we want to do is basically we want to set the initial position, uncertainty, these two values

17
00:01:21,750 --> 00:01:25,140
here controlled by this unit, standard deviation.

18
00:01:25,680 --> 00:01:27,790
We want to get set them to a non-zero value.

19
00:01:28,140 --> 00:01:34,140
This is basically telling us that this is basically telling Fuda that it does not know the position.

20
00:01:34,140 --> 00:01:34,710
Exactly.

21
00:01:35,010 --> 00:01:40,560
So when we set the initial position to be zero zero inside the vector, it tells the field that we are

22
00:01:40,560 --> 00:01:42,750
not absolutely certain about the state.

23
00:01:43,140 --> 00:01:48,390
So we're not absolutely certain that the state actually starts at zero zero, but we have some uncertainty

24
00:01:48,390 --> 00:01:48,890
around it.

25
00:01:49,110 --> 00:01:51,630
So this is what these parameters here control.

26
00:01:52,350 --> 00:01:56,250
So if we do this and rerun this simulation, what happens to the response to the filter?

27
00:01:58,290 --> 00:02:03,480
So in the example that we lost, implemented, we initialize the filter at time equals zero, and we

28
00:02:03,480 --> 00:02:09,780
basically said the initial state is zero zero zero zero and the initial covariance is basically a diagonal

29
00:02:09,780 --> 00:02:15,570
matrix that has some uncertainty in the position elements and some uncertainty in the velocity elements.

30
00:02:16,020 --> 00:02:18,140
So this is one way to initialize the filter.

31
00:02:18,570 --> 00:02:24,360
But depending on how the filter is used or what system the field is used in, there potentially is better

32
00:02:24,360 --> 00:02:25,160
ways of doing this.

33
00:02:25,170 --> 00:02:29,370
And another way of doing this is to initialize the filter on the first update.

34
00:02:29,730 --> 00:02:33,960
So the first time we get a measurement in, we want to start the filter from that measurement.

35
00:02:34,410 --> 00:02:40,020
So what would that would look like would be when we get the first measurement or the first update,

36
00:02:40,230 --> 00:02:44,150
we want to set our X Factor to basically be that position measurement.

37
00:02:44,160 --> 00:02:48,840
So we have the XP Y from the sensor and then 004 velocity.

38
00:02:49,380 --> 00:02:54,690
When we do this, we can set the uncertainty for position being our sensor measurement uncertainty,

39
00:02:54,690 --> 00:03:02,000
which is R and then we just set an initial velocity uncertainty just like we did in when we initialize

40
00:03:02,000 --> 00:03:03,030
the filter on up.

41
00:03:04,410 --> 00:03:09,720
So basically what this is doing is initializing the filter from the first time it gets any real information

42
00:03:09,720 --> 00:03:10,500
about the system.

43
00:03:11,190 --> 00:03:13,110
If you initialize a time, it goes zero.

44
00:03:13,110 --> 00:03:17,100
You're making you're making all these assumptions about the initial side of the system, which might

45
00:03:17,100 --> 00:03:17,900
not be correct.

46
00:03:19,880 --> 00:03:24,980
So for step three, we want to use delayed initialization and we want to initialize the filter on the

47
00:03:24,980 --> 00:03:26,030
first measurement.

48
00:03:26,490 --> 00:03:32,060
So to do this in code first step is to comment about the filter initialization inside the initialization

49
00:03:32,450 --> 00:03:32,920
function.

50
00:03:33,500 --> 00:03:39,680
So coming out the state and the covariance, then we want to go down and initialize the field of state

51
00:03:39,680 --> 00:03:41,400
and a variance on the first update.

52
00:03:41,420 --> 00:03:45,770
So inside the update step here, you can see that this first step here checks out.

53
00:03:45,770 --> 00:03:46,940
The field is initialized.

54
00:03:47,580 --> 00:03:50,500
So we want to actually add in a new line here.

55
00:03:50,510 --> 00:03:53,750
So if we're not initialized, we want to use the measurement information.

56
00:03:54,020 --> 00:03:59,160
We want to set the initial state and covariance using the equations we had on the other slide before.

57
00:03:59,900 --> 00:04:03,830
Once you've done this, rerun the simulation and notice the new response of the system.

