‫Welcome back.
‫So let's now shift our attention to the drone and let's see how to apply constraints to it.
‫I mentioned that the drone rotors have a minimum and the maximum rotational speed.
‫So the Omegas of your rotors had to stay between these minimum and maximum values.
‫You now know that when you want to apply constraints to your embassy controller, then you have to use
‫solvers for that in order to properly use solvers.
‫You have to give it your bull bar matrix and small if transposed vector, which come from your cost
‫function and also your matrix and each vector that come from your constraints.
‫That way, the solver knows what kind of cost, function and constraints you have.
‫The key for knowing exactly what constraints we are talking about is that the solver assumed that your
‫constraints are in this form.
‫G times delta, you global less than or equal to.
‫And then this h vector.
‫It's extremely important that your inequality sign points to the left.
‫Now what is Delta you global in our case?
‫Well, if Horizon period equals four, then your delta you global equals all that.
‫First of all, you have Delta use at K, then you have them at K plus one.
‫Then you have them as K plus two.
‫And then you have them at K Plus three, you have 12 elements in this vector.
‫Now, if we wanted to constrain our delta use directly, then it would have been quite easy.
‫Let's say that you have something like this your delta, your global vector, which is this one here.
‫And remember, it's transposed.
‫So actually as a vector, it's between these minimum values and these maximum values here.
‫So you simply give some kind of meaning values to all these elements and then some kind of maximum values
‫to all these elements.
‫And they will be in this vector here and this vector here, respectively.
‫And now you can separate them like this.
‫You can take this part.
‫Let's call one.
‫And then you can take this part here, and let's call it two.
‫And so this would be the first part, and this would be the second part.
‫Now, remember, in order to use the solver, all your inequality signs must point to the left.
‫And so in the second part, you have to multiply this one by minus one.
‫And this one by minus one and then your inequality sine changes its direction like this.
‫But I can also rewrite them.
‫Like this, I can have here an identity matrix, which is twelve by twelve times Delta U.
‫Global, less than or equal to Delta U.
‫Global Max and then minus an identity matrix.
‫Twelve by twelve times Delta you global less than or equal to minus Delta you global mean or I can rewrite
‫all that like this.
‫I have a twelve by twelve identity matrix here and then minus and then the same identity matrix times
‫delta you global less than or equal to.
‫And then I have Delta U.
‫Global Max here and minus Delta U.
‫Global mean.
‫And this i twelve by twelve.
‫That's simply your identity matrix.
‫It's simply your twelve by twelve identity matrix.
‫When you multiply by Delta, you global, then it's like multiplying something by one in one dimension.
‫And so that means that this matrix here, it has 24 rows and 12 columns.
‫Then Delta You Global has twelve rows and one column, and then this vector here it has 24 rows and
‫one column.
‫So the dimensions work out.
‫And then this matrix that your g matrix, this vector, that's your h vector, your inequality sine
‫points in the right direction.
‫And so that's what you would give to your solver.
‫This matrix and h vector, together with your h double bar matrix and small f transpose to vector.
‫And so you would simply write Delta your global.
‫See, which means that you take constraints into account.
‫It equals soul, underscore kewpie age, double bar small.
‫I've transposed G h vector transposed and then you would right here solver equals CV x orbit.
‫Or if you work in MATLAB, then you would write Delta you global.
‫Considering the constraints equals what?
‫Prog?
‫And then again, the same each double bar matrix small if transposed the G matrix and the H vector transposed.
‫And of course, in MATLAB, this one here and this one here, they can also be column vectors.
‫And that's how you find a solution that minimizes your cost function.
‫But make sure that you stay between your delta, your global men and delta, you global max, whatever
‫those values are.
‫However, that's not what we want in reality.
‫In reality, we want to constrain our Omegas.
‫So let's see how we are going to do it.
‫Well, first of all, we have to define what our omega men and omega max values are.
‫From what I've seen in other research papers for the UAV that we are considering, the reasonable values
‫are omega men equals 110 times pi over three radians per second and omega max eight hundred and sixty
‫pi over three radians per second.
‫So approximately this one is 115 radians per second, and this one, it's 900 radians per second.
‫That's great.
‫So we have our omega minimum and omega maximum, but now we have to find a way to take that information
‫and convert it into this form.
‫Our familiar G times delta your global less than or equal to.
‫And then the H vector.
‫So how would we do it?
‫Well, let me give you a thought exercise here before watching the next video.
‫Give it a thought only maybe for five or ten minutes or so.
‫And just think about all the possible ways you could go from your Omegas to your delta use and then
‫how to eventually reach this form here.
‫Just give it a thought, and let's continue in the next video.
‫Thank you very much.