‫Welcome back.
‫And so we have found our theater angle, and that was the expression for it.
‫And next, we have to find our fire angle.
‫If you remember in the previous video, we had two equivalent equations.
‫We had tangent by equals this expression, and we also had tangent y equals.
‫This expression here, these two expressions, they are the same thing, they compute the same thing.
‫They both give you a tangent, FYI, so you can use either of them to compute your attention, Fi.
‫And of course, you would find your fi angle like this, phi equals and then the inverse tangent.
‫And then inside these parentheses, you can either put this expression or this expression.
‫They will both give you a fi angle.
‫And of course, you have this Seeta angle here and also here and then also here and here.
‫However, you already have an expression for your seat diagonal.
‫So you can just put this entire expression here and then you can just put it inside these Seeta variables
‫here.
‫I'm not going to do it because that's a lot of writing.
‫But you get the idea.
‫You have already computed your theta angle.
‫You already have a number for that.
‫So you can just put it into these variables right away in the code.
‫You will also first compute your theta angle and then you will directly put that number, whatever it
‫is, you put it here and then here and also here and then here.
‫However, remember that D equals sine Sysop R and then C equals cosine sysop r and they are in your
‫denominator.
‫So tell me what happens when your sysop are equals.
‫Either plus pi over two or minus pi over to what's going to happen.
‫Well then your cosine sysop r will be zero, right.
‫And you will be dividing by zero.
‫And now tell me what's going to happen when your sysop are equals zero or pi radians or two pi irradiance
‫or three pi radians or four pi irradiance etc..
‫Well then your sine psi sabbar will be zero and you will be dividing by zero here.
‫And so when the denominator equals zero, then your tangent phi becomes indeterminate.
‫So we need to avoid that scenario.
‫And so how would we deal with these singularities?
‫Well, one way to look at it is like this.
‫So I'm going to have to access here.
‫This one will be cosine Sysop R and this one will be sine PSI subpar are I'm going to draw a circle
‫here and this point here will be one.
‫Also this point here will be one, this point here will be minus one and this point here will be minus
‫one.
‫So this is what we call a unit circle.
‫And so this angle here, this angle would be your sysop are.
‫So you can see that when you're sysop R equals zero radians, then your cosine sysop R equals one and
‫you're sine sysop R equals zero because you are in this point.
‫And then if you're sysop, our angle is pi over to some 90 degrees, then your sign isobar equals one
‫and then your cosine sysop R equals zero.
‫And so we have two equations here and what we can do is this.
‫We can define certain regions.
‫So, for example, this point here, that's when your sysop up are equals pi over four radians like
‫this.
‫Then here, it's three times pi, over four radians, here you have five times Pi over four radians,
‫and then here you will have seven times Pi over four radians.
‫So what we can do, we can say that if our size up our angle is in this region here or in this region
‫here.
‫Then choose this equation, because you will have a cosine sysop are in the denominator and then you
‫will avoid dividing by zero because cosine would be zero if you were in this region here.
‫And then if our sysop are is in this region instead or in this region.
‫Then we're going to choose this equation and we know that while we are in this region, we won't be
‫dividing by zero because in this region, sign cannot become zero.
‫Sign will become zero if I'm in the purple region.
‫And that's how we're going to avoid these singularities, the code is written in such a way that it
‫takes this angle and then it determines whether it's in this green region or in this purple region.
‫And then if you're in the green region, you choose this equation and then if you're in the purple region,
‫you choose this equation.
‫And then you take the inverse tangent of it in order to get your fi angle.
‫And by the way, it doesn't matter whether your size up or is in between.
‫Zero and two irradiance, or if it's.
‫Between two pi and four PI irradiance, or if it's between minus two Pi and Zero Radiance, because
‫remember, we have spiral trajectories so we can have multiple rotations and then we can also have rotations
‫in another direction.
‫In that case, your sysop are would be negative.
‫So if you look at this circle, it doesn't matter how many rotations you have had or in which direction
‫you rotate.
‫What matters is that if you are in this purple region, then you need to choose this equation.
‫Then you are guaranteed not to divide by zero.
‫And then if you're in this green region, then you have to choose this equation.
‫Then you will divide it by sine Sysop R and then you know that you will not have a situation where you
‫will divide by zero.
‫And so, in conclusion, if you are in the purple area, if you're Sysop are is in this purple region,
‫then you will choose this formula here to compute your fire angle.
‫So your inverse tangent and then here you have everything else.
‫And then if you're Sysop are is in this region here, the Green region will then you will choose this
‫formula, this one here.
‫And so you have your sea triangle, you have your fire angle.
‫And now finally we're going to find you one.
‫We have an expression, Z, double dot plus G, and that equals cosine five times cosine theta times
‫you one divided by and now you already know your fi angle and your angle.
‫And now it's very easy to find your new one.
‫If you rearrange these equations, then you one will equal mass times, the Z double dot plus G divided
‫by cosine five times cosine theta.
‫Now here, of course, you might look at it and you might think that OK, here I can also potentially
‫divide by zero.
‫However, in order for that to happen, either PHI or Theta angle must be plus or minus pi over to radians.
‫However, we will never have a phi angle or a to angle plus or minus pi over to radians.
‫It's not going to happen.
‫Your PSI angle could be plus or minus power to radians because it was your angle, it was rotation about
‫the body frame axis, but this is rotation about the body frame x axis and this is rotation about the
‫body frame y axis.
‫And now we're fine, thi tango's will be very small for our drone.
‫If, for example, our fire angle was pie over to radiance.
‫Then that means that our drone would be perpendicular to the ground.
‫So this is our force of gravity here, and then the propellers would give you thrust in this direction.
‫And obviously this kind of thing is not going to happen in our case.
‫So we don't have to worry about it.
‫We only had to worry about the angle because indeed, your drone can rotate like this without any limits.
‫And one other thing that I want to mention is that once you have your fly and see the angles, they
‫will be multiplied by an array of five once.
‫Because remember, the NPC needs an array of these fire and seetha values.
‫So, for example, this one here is your Feis up are that the NPC receives and then the NPC needs to
‫track it like this.
‫So the NPC controller will get these angles in this format, in this Fekter format, the role vector
‫format.
‫And of course, the planner will also give its size up our values to the NPC in this format, in the
‫format of a role vector, so you will have five elements here.
‫So that will come from the planner.
‫And there you go, you have found your fire fighter and you won control input.
‫And now I want to point out one thing.
‫As you know, the mathematical model of our drone for position control was anything but linear.
‫It was full of cosine and sine terms.
‫So if you look at this model and then you can see that it's not linear at all, so the system is not
‫linear.
‫However, we could still use the poor placement method that was only suitable for LTI systems because
‫remember, only in case of LTI systems, your poles were fixed in one place so we could use this technique
‫in our controller, despite of the fact that we have strong nonlinearities in our model because we had
‫these intermediate variables, error and error, dot and error double dot that did form an intermediate
‫LTI system or LTI differential equation.
‫So this one here.
‫In our controller as an intermediate thing, we were able to have something that was linear time invariant,
‫and it was this differential equation and because of that here, we could use our poor placement method
‫in order to find the right e double dot that would always drive our error and our error dot to zero.
‫As time goes to infinity and then you would connect the found e double dot with your Phi Theta and you
‫won variables and that's where the name comes from.
‫Feedback Lionization.
‫You use linear techniques on a nonlinear system by utilizing an intermediate form that's in the LTI
‫form, this one here.
‫And then you go from the LTI intermediate form to the original nonlinear form, just like we did it
‫in this section.
‫All right then.
‫And that is the end of this section and in fact it is almost the end of the course.
‫I have covered all the theory that had to be covered here in the next and final chapter.
‫I will give you a general overview of the code.
‫Thank you very much.