﻿1
00:00:00,600 --> 00:00:01,420
‫Welcome back.

2
00:00:02,100 --> 00:00:09,210
‫And so we have found our theater angle, and that was the expression for it.

3
00:00:10,080 --> 00:00:13,100
‫And next, we have to find our fire angle.

4
00:00:13,890 --> 00:00:19,470
‫If you remember in the previous video, we had two equivalent equations.

5
00:00:20,310 --> 00:00:29,580
‫We had tangent by equals this expression, and we also had tangent y equals.

6
00:00:30,750 --> 00:00:38,730
‫This expression here, these two expressions, they are the same thing, they compute the same thing.

7
00:00:38,760 --> 00:00:45,780
‫They both give you a tangent, FYI, so you can use either of them to compute your attention, Fi.

8
00:00:46,530 --> 00:00:54,810
‫And of course, you would find your fi angle like this, phi equals and then the inverse tangent.

9
00:00:55,590 --> 00:01:02,850
‫And then inside these parentheses, you can either put this expression or this expression.

10
00:01:03,690 --> 00:01:07,230
‫They will both give you a fi angle.

11
00:01:07,920 --> 00:01:13,890
‫And of course, you have this Seeta angle here and also here and then also here and here.

12
00:01:14,280 --> 00:01:18,930
‫However, you already have an expression for your seat diagonal.

13
00:01:19,140 --> 00:01:28,770
‫So you can just put this entire expression here and then you can just put it inside these Seeta variables

14
00:01:28,770 --> 00:01:29,160
‫here.

15
00:01:29,370 --> 00:01:32,040
‫I'm not going to do it because that's a lot of writing.

16
00:01:32,040 --> 00:01:34,170
‫But you get the idea.

17
00:01:34,200 --> 00:01:36,780
‫You have already computed your theta angle.

18
00:01:36,780 --> 00:01:38,340
‫You already have a number for that.

19
00:01:38,760 --> 00:01:44,880
‫So you can just put it into these variables right away in the code.

20
00:01:44,880 --> 00:01:52,950
‫You will also first compute your theta angle and then you will directly put that number, whatever it

21
00:01:52,950 --> 00:01:59,270
‫is, you put it here and then here and also here and then here.

22
00:02:00,090 --> 00:02:16,050
‫However, remember that D equals sine Sysop R and then C equals cosine sysop r and they are in your

23
00:02:16,050 --> 00:02:17,000
‫denominator.

24
00:02:17,700 --> 00:02:23,070
‫So tell me what happens when your sysop are equals.

25
00:02:23,070 --> 00:02:31,570
‫Either plus pi over two or minus pi over to what's going to happen.

26
00:02:32,490 --> 00:02:37,620
‫Well then your cosine sysop r will be zero, right.

27
00:02:37,860 --> 00:02:39,830
‫And you will be dividing by zero.

28
00:02:40,740 --> 00:02:53,010
‫And now tell me what's going to happen when your sysop are equals zero or pi radians or two pi irradiance

29
00:02:53,760 --> 00:02:58,460
‫or three pi radians or four pi irradiance etc..

30
00:02:59,250 --> 00:03:06,960
‫Well then your sine psi sabbar will be zero and you will be dividing by zero here.

31
00:03:07,800 --> 00:03:15,440
‫And so when the denominator equals zero, then your tangent phi becomes indeterminate.

32
00:03:16,260 --> 00:03:18,750
‫So we need to avoid that scenario.

33
00:03:19,820 --> 00:03:23,090
‫And so how would we deal with these singularities?

34
00:03:23,720 --> 00:03:26,560
‫Well, one way to look at it is like this.

35
00:03:27,470 --> 00:03:29,420
‫So I'm going to have to access here.

36
00:03:29,960 --> 00:03:42,290
‫This one will be cosine Sysop R and this one will be sine PSI subpar are I'm going to draw a circle

37
00:03:42,290 --> 00:03:46,180
‫here and this point here will be one.

38
00:03:46,790 --> 00:03:55,190
‫Also this point here will be one, this point here will be minus one and this point here will be minus

39
00:03:55,190 --> 00:03:55,580
‫one.

40
00:03:56,180 --> 00:03:58,370
‫So this is what we call a unit circle.

41
00:03:59,090 --> 00:04:05,870
‫And so this angle here, this angle would be your sysop are.

42
00:04:06,650 --> 00:04:17,000
‫So you can see that when you're sysop R equals zero radians, then your cosine sysop R equals one and

43
00:04:17,000 --> 00:04:23,470
‫you're sine sysop R equals zero because you are in this point.

44
00:04:24,350 --> 00:04:35,540
‫And then if you're sysop, our angle is pi over to some 90 degrees, then your sign isobar equals one

45
00:04:35,540 --> 00:04:40,310
‫and then your cosine sysop R equals zero.

46
00:04:41,240 --> 00:04:46,130
‫And so we have two equations here and what we can do is this.

47
00:04:47,150 --> 00:04:49,550
‫We can define certain regions.

48
00:04:50,560 --> 00:05:01,210
‫So, for example, this point here, that's when your sysop up are equals pi over four radians like

49
00:05:01,210 --> 00:05:01,630
‫this.

50
00:05:02,650 --> 00:05:14,710
‫Then here, it's three times pi, over four radians, here you have five times Pi over four radians,

51
00:05:15,010 --> 00:05:21,550
‫and then here you will have seven times Pi over four radians.

52
00:05:22,530 --> 00:05:36,150
‫So what we can do, we can say that if our size up our angle is in this region here or in this region

53
00:05:36,150 --> 00:05:36,870
‫here.

54
00:05:37,930 --> 00:05:46,630
‫Then choose this equation, because you will have a cosine sysop are in the denominator and then you

55
00:05:46,630 --> 00:05:55,450
‫will avoid dividing by zero because cosine would be zero if you were in this region here.

56
00:05:56,450 --> 00:06:04,580
‫And then if our sysop are is in this region instead or in this region.

57
00:06:05,740 --> 00:06:13,660
‫Then we're going to choose this equation and we know that while we are in this region, we won't be

58
00:06:13,660 --> 00:06:19,170
‫dividing by zero because in this region, sign cannot become zero.

59
00:06:19,540 --> 00:06:22,330
‫Sign will become zero if I'm in the purple region.

60
00:06:23,260 --> 00:06:30,010
‫And that's how we're going to avoid these singularities, the code is written in such a way that it

61
00:06:30,010 --> 00:06:38,860
‫takes this angle and then it determines whether it's in this green region or in this purple region.

62
00:06:39,850 --> 00:06:46,000
‫And then if you're in the green region, you choose this equation and then if you're in the purple region,

63
00:06:46,000 --> 00:06:47,590
‫you choose this equation.

64
00:06:48,550 --> 00:06:54,100
‫And then you take the inverse tangent of it in order to get your fi angle.

65
00:06:55,270 --> 00:07:01,210
‫And by the way, it doesn't matter whether your size up or is in between.

66
00:07:02,280 --> 00:07:05,790
‫Zero and two irradiance, or if it's.

67
00:07:06,860 --> 00:07:16,100
‫Between two pi and four PI irradiance, or if it's between minus two Pi and Zero Radiance, because

68
00:07:16,100 --> 00:07:23,920
‫remember, we have spiral trajectories so we can have multiple rotations and then we can also have rotations

69
00:07:23,930 --> 00:07:25,160
‫in another direction.

70
00:07:25,940 --> 00:07:30,440
‫In that case, your sysop are would be negative.

71
00:07:31,310 --> 00:07:38,840
‫So if you look at this circle, it doesn't matter how many rotations you have had or in which direction

72
00:07:38,840 --> 00:07:39,570
‫you rotate.

73
00:07:39,800 --> 00:07:48,710
‫What matters is that if you are in this purple region, then you need to choose this equation.

74
00:07:49,700 --> 00:07:52,240
‫Then you are guaranteed not to divide by zero.

75
00:07:52,580 --> 00:07:58,190
‫And then if you're in this green region, then you have to choose this equation.

76
00:07:58,850 --> 00:08:06,410
‫Then you will divide it by sine Sysop R and then you know that you will not have a situation where you

77
00:08:06,410 --> 00:08:08,000
‫will divide by zero.

78
00:08:09,060 --> 00:08:16,560
‫And so, in conclusion, if you are in the purple area, if you're Sysop are is in this purple region,

79
00:08:17,190 --> 00:08:23,220
‫then you will choose this formula here to compute your fire angle.

80
00:08:23,790 --> 00:08:28,440
‫So your inverse tangent and then here you have everything else.

81
00:08:29,380 --> 00:08:36,430
‫And then if you're Sysop are is in this region here, the Green region will then you will choose this

82
00:08:36,430 --> 00:08:38,680
‫formula, this one here.

83
00:08:39,590 --> 00:08:45,390
‫And so you have your sea triangle, you have your fire angle.

84
00:08:46,210 --> 00:08:49,350
‫And now finally we're going to find you one.

85
00:08:50,260 --> 00:09:02,350
‫We have an expression, Z, double dot plus G, and that equals cosine five times cosine theta times

86
00:09:03,040 --> 00:09:10,500
‫you one divided by and now you already know your fi angle and your angle.

87
00:09:10,780 --> 00:09:13,630
‫And now it's very easy to find your new one.

88
00:09:14,650 --> 00:09:26,980
‫If you rearrange these equations, then you one will equal mass times, the Z double dot plus G divided

89
00:09:26,980 --> 00:09:33,980
‫by cosine five times cosine theta.

90
00:09:34,930 --> 00:09:40,840
‫Now here, of course, you might look at it and you might think that OK, here I can also potentially

91
00:09:41,440 --> 00:09:42,650
‫divide by zero.

92
00:09:43,570 --> 00:09:53,860
‫However, in order for that to happen, either PHI or Theta angle must be plus or minus pi over to radians.

93
00:09:54,730 --> 00:10:02,350
‫However, we will never have a phi angle or a to angle plus or minus pi over to radians.

94
00:10:02,350 --> 00:10:03,490
‫It's not going to happen.

95
00:10:04,270 --> 00:10:12,220
‫Your PSI angle could be plus or minus power to radians because it was your angle, it was rotation about

96
00:10:12,220 --> 00:10:19,180
‫the body frame axis, but this is rotation about the body frame x axis and this is rotation about the

97
00:10:19,180 --> 00:10:20,980
‫body frame y axis.

98
00:10:21,950 --> 00:10:26,780
‫And now we're fine, thi tango's will be very small for our drone.

99
00:10:27,860 --> 00:10:32,600
‫If, for example, our fire angle was pie over to radiance.

100
00:10:33,730 --> 00:10:37,100
‫Then that means that our drone would be perpendicular to the ground.

101
00:10:37,300 --> 00:10:44,320
‫So this is our force of gravity here, and then the propellers would give you thrust in this direction.

102
00:10:44,650 --> 00:10:49,470
‫And obviously this kind of thing is not going to happen in our case.

103
00:10:49,480 --> 00:10:51,260
‫So we don't have to worry about it.

104
00:10:52,120 --> 00:10:59,710
‫We only had to worry about the angle because indeed, your drone can rotate like this without any limits.

105
00:11:00,550 --> 00:11:09,190
‫And one other thing that I want to mention is that once you have your fly and see the angles, they

106
00:11:09,220 --> 00:11:15,100
‫will be multiplied by an array of five once.

107
00:11:16,330 --> 00:11:22,820
‫Because remember, the NPC needs an array of these fire and seetha values.

108
00:11:23,890 --> 00:11:32,740
‫So, for example, this one here is your Feis up are that the NPC receives and then the NPC needs to

109
00:11:32,740 --> 00:11:34,300
‫track it like this.

110
00:11:35,380 --> 00:11:43,540
‫So the NPC controller will get these angles in this format, in this Fekter format, the role vector

111
00:11:43,540 --> 00:11:44,140
‫format.

112
00:11:45,140 --> 00:11:53,360
‫And of course, the planner will also give its size up our values to the NPC in this format, in the

113
00:11:53,360 --> 00:11:57,770
‫format of a role vector, so you will have five elements here.

114
00:11:57,950 --> 00:12:00,230
‫So that will come from the planner.

115
00:12:07,470 --> 00:12:14,030
‫And there you go, you have found your fire fighter and you won control input.

116
00:12:14,820 --> 00:12:17,310
‫And now I want to point out one thing.

117
00:12:18,000 --> 00:12:24,960
‫As you know, the mathematical model of our drone for position control was anything but linear.

118
00:12:25,770 --> 00:12:28,350
‫It was full of cosine and sine terms.

119
00:12:29,560 --> 00:12:35,290
‫So if you look at this model and then you can see that it's not linear at all, so the system is not

120
00:12:35,290 --> 00:12:35,840
‫linear.

121
00:12:36,790 --> 00:12:44,680
‫However, we could still use the poor placement method that was only suitable for LTI systems because

122
00:12:44,680 --> 00:12:52,810
‫remember, only in case of LTI systems, your poles were fixed in one place so we could use this technique

123
00:12:52,960 --> 00:13:00,010
‫in our controller, despite of the fact that we have strong nonlinearities in our model because we had

124
00:13:00,010 --> 00:13:08,770
‫these intermediate variables, error and error, dot and error double dot that did form an intermediate

125
00:13:09,250 --> 00:13:13,330
‫LTI system or LTI differential equation.

126
00:13:14,290 --> 00:13:16,030
‫So this one here.

127
00:13:17,080 --> 00:13:24,370
‫In our controller as an intermediate thing, we were able to have something that was linear time invariant,

128
00:13:24,820 --> 00:13:33,220
‫and it was this differential equation and because of that here, we could use our poor placement method

129
00:13:33,760 --> 00:13:45,590
‫in order to find the right e double dot that would always drive our error and our error dot to zero.

130
00:13:46,420 --> 00:13:58,240
‫As time goes to infinity and then you would connect the found e double dot with your Phi Theta and you

131
00:13:58,240 --> 00:14:02,050
‫won variables and that's where the name comes from.

132
00:14:02,230 --> 00:14:03,820
‫Feedback Lionization.

133
00:14:04,270 --> 00:14:14,050
‫You use linear techniques on a nonlinear system by utilizing an intermediate form that's in the LTI

134
00:14:14,050 --> 00:14:15,850
‫form, this one here.

135
00:14:16,660 --> 00:14:25,120
‫And then you go from the LTI intermediate form to the original nonlinear form, just like we did it

136
00:14:25,420 --> 00:14:26,460
‫in this section.

137
00:14:27,260 --> 00:14:28,020
‫All right then.

138
00:14:28,660 --> 00:14:35,860
‫And that is the end of this section and in fact it is almost the end of the course.

139
00:14:35,980 --> 00:14:42,490
‫I have covered all the theory that had to be covered here in the next and final chapter.

140
00:14:43,180 --> 00:14:46,370
‫I will give you a general overview of the code.

141
00:14:47,260 --> 00:14:48,190
‫Thank you very much.

