‫Welcome back.
‫Let's now put our Newton oilor form into the state's equation for so that's your equation here.
‫And then remember that these three terms here, they gave you a net force and moment vector, but now
‫you're going to write it out in terms of these three terms.
‫One term is for gravity.
‫The other term is for gyroscopic effect.
‫And then the third term is for control inputs.
‫So the first order of business is that we're going to compute this, including the minus sign.
‫So this matrix here that you see in the body frame matrix, this is your velocity vector in the body
‫frame.
‫And don't forget about the minus sign here.
‫And if you're going to compute all that, then this is what you will get you will get this entire thing
‫here.
‫So when you multiply this first row with this velocity vector here with these six elements, then you
‫will get this thing here.
‫And when you do the same thing with the second row here and then you multiply that rule by these six
‫vector elements.
‫So it's a standard matrix vector multiplication.
‫Then you will get this thing here like this.
‫And so forward and you just do it for all the rows and then that's what you will get.
‫So now you take this entire thing here and you put it right here and then you add the other terms to
‫it.
‫And then you take this inverse matrix here, this entire thing, and you multiply it by whatever you
‫have here.
‫So all that here in purple is.
‫This so it's all here combined, and this is your mass and mass moment of inertia, matrix inverse.
‫So that's what it is.
‫And now you just have to multiply them together.
‫Note that this purple thing is actually six by one vector, because, for example, if you take this
‫first element here, this one, then this is just one row.
‫And you only have one column here, so if you had numbers for all these variables, you would just get
‫one scalar number here.
‫So this is actually a six by one vector and this is a six by six matrix.
‫So if you start multiplying them, then what will happen is that these one over Ms.
‫And one over mass moments of inertia, they will start appearing here in the denominator's.
‫So, for example, this would be for the first row.
‫That's because you're taking this first element here and you're applying it to the first row of this
‫vector.
‫It's like this.
‫Then the second element would be applied here.
‫However, since it's zero, then it doesn't matter.
‫Nothing will happen and it's better.
‫And because of the fact that this yellow matrix here is a diagonal matrix, then.
‫The first rule of this matrix only affects the first rule of this vector.
‫The second diagonal element affects only the second row of this vector.
‫The third element in this diagonal.
‫Matrix only affects the third row of this vector and so forth.
‫This would only affect this row.
‫This one would only affect this row here and finally, this one will only affect this row here, and
‫it's like that only because this is a diagonal matrix and all other elements here are zeroes.
‫And that's why you have mass here in the denominator because of this.
‫And you'll have mass in the denominator in the second row of this vector because of this in the third
‫row.
‫It's thanks to this element here.
‫Now, in the fourth element in this diagonal, we have the mass movement of inertia about the body frame
‫x axis.
‫So this thing will be thanks to this element here.
‫Then this element here will be applied to the fifth row, and that's mass moment of inertia, but the
‫y axis body frame y axis and finally, this element is for the sixth row.
‫And of course, when your purple vector is in this form, then this disappears because it's either the
‫yellow matrix times the purple vector without these red denominators.
‫Or when you have these denominators already, then that means that you have already multiplied the yellow
‫matrix by the purple vector and so you can make quite a lot of simplifications here.
‫You can cancel out these masses and these masses and these masses also here and here as well.
‫And the rest you cannot cancel.
‫And so that would be your first role.
‫You take this, you dot equals and then this first rule here, that's this.
‫That's your second role?
‫Not that I have gotten rid of the masses because I was able to cancel them.
‫This would be your third row here.
‫This would be your fourth row note, would I have done here I have factor out queue are here and here.
‫So I was able to write it down like this.
‫I said y y minus I sub Z that you have here and then divide it by the mass movement of inertia about
‫the x axis.
‫That will be your fifth row and again, what I have done here, I have factored out PR in order to be
‫able to write it down like this.
‫And that would be your sixth row again, PKU was factored out right over here and there you go.
‫You finally have your these mathematical model in the state space form, in the body frame.
‫You took your equations of motion that came from the laws of physics.
‫You adjusted it to a rotating body frame and then you converted it into a state space form, which is
‫more convenient for control problems.
‫Remember the equations of motion in the inertia frame, in the body frame and in the state's space form?
‫They all mathematically describe the same thing, but simply in a different way, in a different form.
‫And so depending on what you want to do, one form is more convenient than another form for that specific
‫purpose.
‫For control problems.
‫The state space form is better and it is not hard to see why.
‫In control problems, you constantly need to keep track of your states and the states based equations
‫make it quite easy, just like you learned in the previous course.
‫In this course series, you first define your initial states, which are the states when you start counting
‫time or when you start your maneuver.
‫And then you compute the new states like this.
‫You can compute the new states at K plus one using your state values now at K, the time derivative
‫of your state at K.
‫Times your sample time interval.
‫And divided by n your state time derivative at K, you get it from your state's base equations.
‫You define your sample time interval, and in our case, it was zero point one seconds and then N was
‫the number defining how many new state computations you do in one sample time interval.
‫So, for example, if An equals five, then.
‫If this is your tits, but you say three point three here and three point four here, then we compute
‫a new state every zero point zero two seconds, which is this interval here.
‫So we would do it at three point thirty two, then three point thirty four, three point thirty six,
‫three point thirty eight until you get to three point four.
‫So in each sub interval, you would compute a new state that increases the precision of your new state's.
‫Because like I said in the previous course, in this core series, this method here, it's not 100 percent
‫perfect.
‫So it gives you some kind of error.
‫So if you make these new state computations with a smaller interval, then you can decrease the error
‫and increase the precision of your state.
‫And of course, you don't only compute a new state for you variable, but you do the same thing for
‫V, W, P, Q and R.
‫So remember what they are, the first three states are the translational velocities of the drone in
‫the body frame and the other three states are the angular velocities of the drone in the body frame
‫as well.
‫So these states base equations here in white, this is what you have been after pretty much throughout
‫the entire course, and finally you have it.
‫However, the story's not over yet because these equations are only in the body frame.
‫However, we also have to work in the inertia frame because the reference values that we get.
‫Or in other words, the reference values that the controller gets are in the inertia frame, so therefore
‫we have to do something else in order to be able to make the plants suitable for the controller.
‫And I'm going to do that in the next video.
‫Thank you very much.