﻿1
00:00:00,590 --> 00:00:01,350
‫Welcome back.

2
00:00:01,940 --> 00:00:10,630
‫Let's now put our Newton oilor form into the state's equation for so that's your equation here.

3
00:00:11,120 --> 00:00:21,410
‫And then remember that these three terms here, they gave you a net force and moment vector, but now

4
00:00:21,410 --> 00:00:25,460
‫you're going to write it out in terms of these three terms.

5
00:00:26,270 --> 00:00:27,920
‫One term is for gravity.

6
00:00:28,580 --> 00:00:31,130
‫The other term is for gyroscopic effect.

7
00:00:31,430 --> 00:00:34,510
‫And then the third term is for control inputs.

8
00:00:35,420 --> 00:00:43,560
‫So the first order of business is that we're going to compute this, including the minus sign.

9
00:00:44,510 --> 00:00:55,280
‫So this matrix here that you see in the body frame matrix, this is your velocity vector in the body

10
00:00:55,280 --> 00:00:55,760
‫frame.

11
00:00:56,590 --> 00:00:59,210
‫And don't forget about the minus sign here.

12
00:01:00,020 --> 00:01:06,890
‫And if you're going to compute all that, then this is what you will get you will get this entire thing

13
00:01:06,890 --> 00:01:07,320
‫here.

14
00:01:08,300 --> 00:01:22,730
‫So when you multiply this first row with this velocity vector here with these six elements, then you

15
00:01:22,730 --> 00:01:25,150
‫will get this thing here.

16
00:01:25,940 --> 00:01:33,920
‫And when you do the same thing with the second row here and then you multiply that rule by these six

17
00:01:33,920 --> 00:01:34,950
‫vector elements.

18
00:01:35,420 --> 00:01:38,080
‫So it's a standard matrix vector multiplication.

19
00:01:38,750 --> 00:01:42,500
‫Then you will get this thing here like this.

20
00:01:43,440 --> 00:01:49,650
‫And so forward and you just do it for all the rows and then that's what you will get.

21
00:01:50,970 --> 00:02:02,670
‫So now you take this entire thing here and you put it right here and then you add the other terms to

22
00:02:02,670 --> 00:02:02,910
‫it.

23
00:02:03,840 --> 00:02:11,910
‫And then you take this inverse matrix here, this entire thing, and you multiply it by whatever you

24
00:02:11,910 --> 00:02:12,780
‫have here.

25
00:02:13,840 --> 00:02:17,770
‫So all that here in purple is.

26
00:02:18,850 --> 00:02:29,380
‫This so it's all here combined, and this is your mass and mass moment of inertia, matrix inverse.

27
00:02:30,070 --> 00:02:31,270
‫So that's what it is.

28
00:02:31,900 --> 00:02:34,660
‫And now you just have to multiply them together.

29
00:02:35,590 --> 00:02:45,360
‫Note that this purple thing is actually six by one vector, because, for example, if you take this

30
00:02:45,370 --> 00:02:50,530
‫first element here, this one, then this is just one row.

31
00:02:51,630 --> 00:02:58,230
‫And you only have one column here, so if you had numbers for all these variables, you would just get

32
00:02:58,440 --> 00:03:00,010
‫one scalar number here.

33
00:03:00,390 --> 00:03:07,170
‫So this is actually a six by one vector and this is a six by six matrix.

34
00:03:08,160 --> 00:03:15,490
‫So if you start multiplying them, then what will happen is that these one over Ms.

35
00:03:15,510 --> 00:03:23,870
‫And one over mass moments of inertia, they will start appearing here in the denominator's.

36
00:03:25,290 --> 00:03:27,990
‫So, for example, this would be for the first row.

37
00:03:29,280 --> 00:03:36,450
‫That's because you're taking this first element here and you're applying it to the first row of this

38
00:03:36,450 --> 00:03:37,210
‫vector.

39
00:03:37,890 --> 00:03:38,790
‫It's like this.

40
00:03:39,820 --> 00:03:43,900
‫Then the second element would be applied here.

41
00:03:44,380 --> 00:03:47,540
‫However, since it's zero, then it doesn't matter.

42
00:03:47,570 --> 00:03:50,230
‫Nothing will happen and it's better.

43
00:03:50,770 --> 00:03:57,280
‫And because of the fact that this yellow matrix here is a diagonal matrix, then.

44
00:03:58,460 --> 00:04:05,030
‫The first rule of this matrix only affects the first rule of this vector.

45
00:04:06,080 --> 00:04:14,090
‫The second diagonal element affects only the second row of this vector.

46
00:04:15,140 --> 00:04:18,680
‫The third element in this diagonal.

47
00:04:19,690 --> 00:04:27,040
‫Matrix only affects the third row of this vector and so forth.

48
00:04:27,880 --> 00:04:31,120
‫This would only affect this row.

49
00:04:32,130 --> 00:04:44,100
‫This one would only affect this row here and finally, this one will only affect this row here, and

50
00:04:44,100 --> 00:04:49,620
‫it's like that only because this is a diagonal matrix and all other elements here are zeroes.

51
00:04:50,700 --> 00:04:55,470
‫And that's why you have mass here in the denominator because of this.

52
00:04:56,610 --> 00:05:05,220
‫And you'll have mass in the denominator in the second row of this vector because of this in the third

53
00:05:05,220 --> 00:05:05,610
‫row.

54
00:05:05,790 --> 00:05:08,420
‫It's thanks to this element here.

55
00:05:09,240 --> 00:05:17,070
‫Now, in the fourth element in this diagonal, we have the mass movement of inertia about the body frame

56
00:05:17,070 --> 00:05:17,940
‫x axis.

57
00:05:18,920 --> 00:05:22,980
‫So this thing will be thanks to this element here.

58
00:05:24,470 --> 00:05:31,910
‫Then this element here will be applied to the fifth row, and that's mass moment of inertia, but the

59
00:05:31,910 --> 00:05:41,200
‫y axis body frame y axis and finally, this element is for the sixth row.

60
00:05:42,230 --> 00:05:51,680
‫And of course, when your purple vector is in this form, then this disappears because it's either the

61
00:05:51,680 --> 00:05:58,100
‫yellow matrix times the purple vector without these red denominators.

62
00:05:59,160 --> 00:06:05,880
‫Or when you have these denominators already, then that means that you have already multiplied the yellow

63
00:06:05,880 --> 00:06:12,420
‫matrix by the purple vector and so you can make quite a lot of simplifications here.

64
00:06:13,120 --> 00:06:22,610
‫You can cancel out these masses and these masses and these masses also here and here as well.

65
00:06:23,610 --> 00:06:25,560
‫And the rest you cannot cancel.

66
00:06:26,580 --> 00:06:29,160
‫And so that would be your first role.

67
00:06:29,190 --> 00:06:37,680
‫You take this, you dot equals and then this first rule here, that's this.

68
00:06:38,960 --> 00:06:40,280
‫That's your second role?

69
00:06:41,450 --> 00:06:45,190
‫Not that I have gotten rid of the masses because I was able to cancel them.

70
00:06:46,500 --> 00:06:48,670
‫This would be your third row here.

71
00:06:50,160 --> 00:06:58,770
‫This would be your fourth row note, would I have done here I have factor out queue are here and here.

72
00:06:59,790 --> 00:07:02,220
‫So I was able to write it down like this.

73
00:07:02,700 --> 00:07:13,590
‫I said y y minus I sub Z that you have here and then divide it by the mass movement of inertia about

74
00:07:13,590 --> 00:07:14,610
‫the x axis.

75
00:07:15,610 --> 00:07:24,520
‫That will be your fifth row and again, what I have done here, I have factored out PR in order to be

76
00:07:24,520 --> 00:07:25,980
‫able to write it down like this.

77
00:07:26,960 --> 00:07:37,980
‫And that would be your sixth row again, PKU was factored out right over here and there you go.

78
00:07:38,630 --> 00:07:49,490
‫You finally have your these mathematical model in the state space form, in the body frame.

79
00:07:50,510 --> 00:07:55,490
‫You took your equations of motion that came from the laws of physics.

80
00:07:56,750 --> 00:08:07,010
‫You adjusted it to a rotating body frame and then you converted it into a state space form, which is

81
00:08:07,010 --> 00:08:09,480
‫more convenient for control problems.

82
00:08:10,610 --> 00:08:19,460
‫Remember the equations of motion in the inertia frame, in the body frame and in the state's space form?

83
00:08:20,060 --> 00:08:26,580
‫They all mathematically describe the same thing, but simply in a different way, in a different form.

84
00:08:27,350 --> 00:08:36,050
‫And so depending on what you want to do, one form is more convenient than another form for that specific

85
00:08:36,050 --> 00:08:36,620
‫purpose.

86
00:08:37,220 --> 00:08:38,510
‫For control problems.

87
00:08:38,870 --> 00:08:43,520
‫The state space form is better and it is not hard to see why.

88
00:08:44,510 --> 00:08:52,040
‫In control problems, you constantly need to keep track of your states and the states based equations

89
00:08:52,040 --> 00:08:56,390
‫make it quite easy, just like you learned in the previous course.

90
00:08:56,390 --> 00:09:03,350
‫In this course series, you first define your initial states, which are the states when you start counting

91
00:09:03,350 --> 00:09:07,460
‫time or when you start your maneuver.

92
00:09:08,420 --> 00:09:11,870
‫And then you compute the new states like this.

93
00:09:13,320 --> 00:09:25,680
‫You can compute the new states at K plus one using your state values now at K, the time derivative

94
00:09:25,920 --> 00:09:28,410
‫of your state at K.

95
00:09:29,520 --> 00:09:31,980
‫Times your sample time interval.

96
00:09:33,000 --> 00:09:43,170
‫And divided by n your state time derivative at K, you get it from your state's base equations.

97
00:09:44,340 --> 00:09:55,860
‫You define your sample time interval, and in our case, it was zero point one seconds and then N was

98
00:09:55,860 --> 00:10:03,000
‫the number defining how many new state computations you do in one sample time interval.

99
00:10:03,930 --> 00:10:08,520
‫So, for example, if An equals five, then.

100
00:10:09,700 --> 00:10:22,450
‫If this is your tits, but you say three point three here and three point four here, then we compute

101
00:10:22,450 --> 00:10:30,420
‫a new state every zero point zero two seconds, which is this interval here.

102
00:10:31,330 --> 00:10:41,410
‫So we would do it at three point thirty two, then three point thirty four, three point thirty six,

103
00:10:41,410 --> 00:10:46,120
‫three point thirty eight until you get to three point four.

104
00:10:46,930 --> 00:10:55,900
‫So in each sub interval, you would compute a new state that increases the precision of your new state's.

105
00:10:56,970 --> 00:11:05,880
‫Because like I said in the previous course, in this core series, this method here, it's not 100 percent

106
00:11:05,880 --> 00:11:06,510
‫perfect.

107
00:11:06,870 --> 00:11:08,820
‫So it gives you some kind of error.

108
00:11:09,210 --> 00:11:18,450
‫So if you make these new state computations with a smaller interval, then you can decrease the error

109
00:11:18,480 --> 00:11:21,120
‫and increase the precision of your state.

110
00:11:22,060 --> 00:11:29,320
‫And of course, you don't only compute a new state for you variable, but you do the same thing for

111
00:11:29,320 --> 00:11:34,450
‫V, W, P, Q and R.

112
00:11:35,600 --> 00:11:44,270
‫So remember what they are, the first three states are the translational velocities of the drone in

113
00:11:44,270 --> 00:11:53,720
‫the body frame and the other three states are the angular velocities of the drone in the body frame

114
00:11:53,720 --> 00:11:54,260
‫as well.

115
00:11:55,460 --> 00:12:04,730
‫So these states base equations here in white, this is what you have been after pretty much throughout

116
00:12:04,730 --> 00:12:09,020
‫the entire course, and finally you have it.

117
00:12:10,250 --> 00:12:17,220
‫However, the story's not over yet because these equations are only in the body frame.

118
00:12:17,690 --> 00:12:24,200
‫However, we also have to work in the inertia frame because the reference values that we get.

119
00:12:25,210 --> 00:12:33,160
‫Or in other words, the reference values that the controller gets are in the inertia frame, so therefore

120
00:12:33,760 --> 00:12:41,050
‫we have to do something else in order to be able to make the plants suitable for the controller.

121
00:12:41,830 --> 00:12:44,200
‫And I'm going to do that in the next video.

122
00:12:44,410 --> 00:12:45,370
‫Thank you very much.

