 So, let us get started with the second part of the this lecture. This is focused on generalization of some of the concepts that we started of developing with to our manipulator kind of a case ok. So, general mechanical system if we consider how its Lagrange formulation gets developed and what are the properties corresponding to that ok. So, we will just go back and notice once again the expression for the kinetic energy that we got ok. So, let us go into the slides ok. So, you see this kinetic energy expression that was there for 2 hour manipulator was expressed in this terms of this D 1 1 D 1 2 D 2 2 ok. So, this is part of this kinetic energy expression total kinetic energy expression ok. So, this is you can see that from equations derived here ok. So, here you can see that the kinetic energy is expressed in this D 1 now this D 1 2 is basically this D 0 by 2 term this D 0 is given here expression is given here. So, this D 0 D 1 1 D 1 2 D 2 1 and D 2 2 these are like 4 terms in this kind of a quadratic form matrix and then you have this Q 1 dot Q 2 dot multiplying here ok transpose and Q 1 dot Q 2 dot ok. So, this is like a quadratic form of expression for kinetic energy ok and you will find that all the mechanical systems kinetic energy can be expressed in this kind of a form. Now, this form gives us a clear indication that this matrix which forms is kinetic energy by this quadratic form matrix is going to be positive definite ok. Can you see that why it is going to be positive definite? Pause for a while and check like you know see why this matrix need to be positive definite. So, this is a quadratic form if you express for a quadratic form of a matrix ok then if the quadratic form has a value which is greater than 0 quadratic form is a scalar value. So, that value is greater than 0 then the matrix is positive definite right. So, you know the kinetic energy of any system will always be positive ok. From that simple kind of a physical analogy one can see that this matrix is going to be positive definite ok. So, this is one of the properties of this matrix for D is it is positive definite ok. Now, you can see that the same matrix appears in the final expression of the equations. This equation 1 if you see this term here this is D 1 1 q 1 double dot and D half D 0 or D 1 2 q 2 double dot ok. These terms appear here as well in one equation and in the second equation it is again half D 0 or D 2 1 q 1 double dot and D 2 2 q 2 double dot ok. So, these are this is a way like you know this D matrix appears in the final equations. So, the moment you write kinetic energy you know the part terms of the final equation ok. Even the second part has some kind of interesting mathematical expression in terms of this D matrix as well and maybe you have a potential energy terms also coming in there. So, we will see that. So, this can be generalized in general for you know any mechanical system ok. When you say mechanical system what we mean is that the systems which are expressible in the form of a kinetic energy for mechanical systems ok. So, we will just get a little bit details into that now. So, let us go back to our slides. So, as we see this kinetic energy gets expressed in terms of this D matrix and this D matrix now is positive definite. So, up to that we see like you know why the D matrix will be positive definite. Now, let us generalize this in general for you know kinetic energy of several body rigid body mechanical systems ok. So, to some extent it may be valid for you know even flexible body mechanical systems if they restrict the discussion about them to a finite number of modes. So, let us not worry right now about flexible body system, but we will just get into the rigid body system dynamics. So, for a rigid body the kinetic energy you know is expressible in this form kinetic energy is actually summation of all these different mass elements in the system and corresponding velocities of the CG's of the mass elements and then inertia of those elements and corresponding rotation kinetic energy part ok. So, corresponding omega for that element and summation of all such elements over this should be summation here over all different bodies will give you total kinetic energy of the system. Now, this kinetic energy we need to express in the form of a generalized coordinates ok. So, they this kind of a quadratic form for generalized in the generalized coordinates it can be expressible ok. So, this is possible by expressing as we have seen in 2 R manipulator the velocities of CG and omegas they should be expressed in generalized coordinates and you will have this expression possibility ok. Once we do that you get this kinetic energy as some summation of this q i q j dot elements and d i j. Now, we start off with our Lagrange formulation based on this expression ok. Let me give a check once if we are ok with the recording just pause for a while and you start doing this using this kinetic energy expression and deriving the some terms in the Lagrange formulation we will come to that immediately. So, if you see these terms. So, if you take this term ok first term ah. So, what we do is see potential energy in the system ok is a function of the q q is only the generalized coordinate or degrees of freedom variable and not its derivative ok or q dot. q dot is not appearing in the potential energy term. So, notice this is important. This is a q is a vector it may be like no all dependency on all generalized coordinates, but the derivative of q will not appear in the potential energy terms in general ok for a for a mechanical rigid body systems ok. Then now we if we see we start taking first partial derivative of L with respect to q dot ok. So, this will have this form now how this form comes ok you you need to think about that it is not like no straight forward or trivial to like this is be there no no. So, what we are doing is we are expressing this energy terms in the in d i j q dot i q dot j. Now, if you form these terms or look at these terms in the in the matrix where are they and then like now you see if I take the partial with respect to say q 1 dot here ok. So, any k q 1 dot then what terms are going to appear is what we are looking in this expression. So, if you see this d of q matrix that has these terms ok and now I will write these terms with the multiplication so, that we have summation of all these terms coming in the derivation ok q 1 dot q 1 dot ok. Then d 1 2 q 1 dot and q 2 dot like that there will be terms d 1 3 into q 1 dot q 3 dot ok and here d 2 1 again q 2 dot and q 1 dot is again coming here ok. So, notice that this q 1 dot is coming here like that d 3 1 q 2 dot and q 1 dot is coming here ok. So, this is how like the terms are going to come or q 1 dot part of it ok. So, when I take so, this is this will continue and so, and so forth and you will have this all these terms are actually summed up in the final expression for the. So, we are not saying just d q this is not really just d q ok. So, this is misnomer it is d q and like you know there is some kind of a quadratic part multiplication ok. So, and this is summation of all these elements which will happen in the final expression. So, you will have also here q dot transpose d q q dot that kind of a expression we are writing, but we are not writing as a summation, but like we are not writing the plus signs, but we are just putting these elements in place. So, that we know which of the terms are going to appear when I kind of do the partial derivative with so, if I take this partial now partial of d q or actually d q sorry this partial of kinetic energy with respect to d q 1 dot ok. So, this q this one is actually k now from our previous expression phase for generalization purpose and in here there are going to be terms which are based on so, the terms will come from both places from here also and here also ok. So, this d 1 d 2 1 and d 2 1 2 are same because this is symmetric matrix ok. So, this matrix is not only positive, but it also is a symmetric matrix ok. So, why it is symmetric like you will see that any quadratic form can be rearranged to get into a symmetric kind of a form ok. So, one can kind of see from there this will get into a symmetric matrix. So, if it is not symmetric we can kind of like now turn it into a symmetric matrix ok. So, this these are like you know cross these are like what you say cross diagonal terms they are not like non diagonal terms and this is a diagonal term diagonal term if you take see this is derivative with respect to q 1 dot it will be like now two times like so, this derivative is going to be ok. So, this diagonal term will have two times d 1 1 q 1 dot and half diagonal terms will have like now two again because if you see here this kind of a term and this term will get summed up and because they are symmetric with respect to each other because the matrix is symmetric like these both the terms are equal and that is why this is two times d say 1 2 into q 1 dot ok. So, this is this is going to be q 2 dot and I take when I take a derivative with respect to q 1 dot the q 2 dot will appear here in the here it is q 1 dot because like you know it is q 1 dot square ok. So, now if there is a half in the in the kinetic energy expansion. So, what we are writing is only for part of this this term del q v del kinetic energy by del q 1 dot which is now corresponding to first diagonal first term and its you know derivatives that will come. So, because now we are considering with respect to say q 1 which is k is now equal to 1. So, this will be in general summation of now you can see that the half will get cancelled out ok. So, when half gets cancelled out you get this d now d k j ok. So, k is my like no term which is here d 1 d 1 2 like that I will write in terms of d k j n q j dot. So, if you see this where j is equal to 1 to n ok. So, for k is equal to 1 if I see then j is equal to 1 to n like this q j dot will give me like you know this expression for the first partial derivative of kinetic energy with respect to q 1 dot ok. So, clear this part. So, like that you can you need to see and move on from here ok. So, let us see this expression this is d k j q j dot that is what we have seen. So, this is how you need to it is not do not consider this to be a trivial exercise. This is one has to kind of think about in terms of the expression for the matrix and then the terms coming from the quadratic form and then take them further to differentiate ok. Like that we do now for. So, you can do further for other terms now like now say d by dt of del l by del q dot and del l by del q ok. These kind of terms you can express now in a similar kind of a fashion and try yourself first doing that and then only you can go ahead and look at the further part of the lecture. So, please do this that is an important part of the exercise to get to the real understanding of what is happening and even if you have a difficulty no problem like you can get stuck no problem getting stuck is a very important step in understanding and once you get stuck then you come back and look at how things are done and then maybe things will be better clear ok. So, if you move on for further differentiation. So, you can see this is a term coming because of the complete differentiation with respect to time for the same term. So, you can see here this part first like now there are two derivatives that will come because of the multiplication. So, first is a derivative of this qj double dot ok. So, qj dot term will get differentiated to give you qj double dot and then you will come to the differentiation of d kj ok. Now, you can see that this first term yields you directly like a term in the in the final equation ok d kj qj double dot ok. This is this is a term that will appear in the final equation because now we will assemble these terms when you know this complete derivative no more derivatives will be executed after this. So, after this there is just assembly of the terms ok and then if you see this term ok this term can be expressed as under summation now ok. So, this d by dt of d kj of like you know internal coordinates vector q function of that. So, we take partial with respect to q and then q dot will be multiplied and that is how this becomes now this summation still remains, but inner this derivative can be expressed as a summation over i and the summation over j is already there. So, this becomes like a summation over both i and j d kj d del kj del qi and qi dot qi qj dot this kind of a term will come ok. This you can work it out and again do the way that I have expressed in the form of like in this matrix form with all the terms written there and then things will be clear for you ok. So, we will consider it that way. Now, for del L by del q you have these terms coming up and again these terms are quite straightforward to see probably because this is already from the kinetic energy will have these term coming we are just taking partial with respect to q. So, this is a partial with respect to q kind of a term and then this del p by del q again here ok. So, I would request you to kind of go through you know clearly in a in a in all expanded terms in the matrix kind of a form and then things will become little more clear how we are expressing this ok. So, now, if we move on assembling to assembly of these terms we get this kind of a assembly you just put this together together here in this a complete equation and you get these terms assembled in this form here. So, by interchanging the order of summation and using some kind of a symmetry in the system again this is not very trivial to see directly one has to kind of write these terms in in ij proper consideration of ij k and then you will find that this you know can be written by rearranging. So, this symmetry is used to kind of get this split part of the term centering with that and this kind of helps in some definitions later that is why this is done I mean. So, this c actually this is your c part of the term ok. See matrix if you want to say you know like you know some kind of a correlates and centrifugal kind of components which are coming in these terms ok there derivatives and things like that ok. So, yeah so, so, kinetic energy derivatives actually give you this centrifugal and courier kind of a force terms here when q i is equal to j you will have a you know q dot square term that is coming which will relate to somewhat like a centrifugal force term and when i is not equal to j there will be like a correlation terms ok. Now by doing this like some some kind of a readjustment is done for this particular term only and you get this expressed in this form ok and further you can express that in terms of this c ijk kind of a coefficients ok. This c ijk coefficients sometimes are called Christopher symbols ok. So, there is a mathematical kind of a jargon there, but let us not worry about that. It is basically like you get this kind of a c matrix multiplying some q dot and this d matrix we know already and q double dot and this potential energy terms are clubbed into this g matrix and then you get this complete expression for your final equation of motion ok. So, these how things happen here. So, let us now see this is this form has some certain other property ok. So, this important mechanical properties that we have seen important mathematical properties that we have seen for this mechanical system first is d matrix is symmetric and positive definite. Now, this is the other property ok this d matrix d dot minus 2 c is q symmetric. So, you see that this c matrix can be developed in many different kind of a ways ok. Given this as a quadratic form here ok, I can have like no different combinations of the terms coming to get it out to kind of find ok. No this is not a quadratic form sorry this is a quadratic expression, but we are not considering here the quadratic form ok. So, here the form is just c matrix multiplied by vector. So, for this by rearranging terms in c we can have different possibilities for c matrix it is not a unique ok. So, maybe we can see that with respect to our example of 2 r manipulator. So, we go back to our 2 r manipulator case. So, let us get here if you see this c q dot term ok. So, this is a c q dot term as a vector form. So, this is say this has some terms as 2 m 2 n 1 n this is q 1 q 1 dot kind of q 1 q 2 dot term and q 2 dot square term and q 1 dot square term. Now I can say like so, I can choose to express like you know this this is like c q dot. So, what should be the c matrix I can have different possibilities ok. So, one of the possibilities you can see up here I can say my c can be expressed as so, I have used some some symbol. So, just to kind of get rid of you know this complicated terms coming there I am just using this h as a symbol for some some term ok. So, this h q q 2 dot ok. So, this is like 2 h q 1 dot q 2 dot h q dot square and minus h q dot q 1 dot square is like you know c times q dot term which is a q dot is missing here ok. So, I am kind of trying to get my c matrix from from here ok. So, so this is my c q dot term and this is actually c matrix one of the possibilities. So, what I have done is like we can see that now this term is going to multiply in the first row by by q 1 dot. So, this h q 1 q 2 dot q 1 dot plus now this h q 1 dot square ok and h q 2 dots you know h q 1 dot this is the second term of the matrix. So, this h q 1 dot q 2 dot and h q 2 dot square. Now this h q 2 dot q 1 dot and h q 1 dot q 2 dot this is same term they will get added to 2 h q 1 dot q 2 dot here you see the way it is split. So, this term is split into two parts one part is put in this side and other part is put on the other side ok. And then like you know this is this is getting multiplied by q 2 dot when I have a multiplication q 1 dot q 2 dot as a vector here ok. So, this this term is getting multiplied by q 1 dot alone and this term is way getting multiplied by q 2 dot alone and then like you know when I am add these two terms as a as a first term of the matrix product matrix vector product then like you know I will get two h q 1 dot q 2 dot as we want up here ok. Like that you can express similarly like you know h q 1 dot term here h q 1 q 1 dot square term h q 1 dot here and nothing here ok. So, this is there is no q 2 dot term appearing there. So, like that we can we can this is one possibility of arrangement ok there can be other possibilities of arrangement also ok. So, I could have just said this term this part of the term to be 0 and in here I would say this is two times h q 1 dot that also would have been a possibility ok. All these diagonal terms are going to be 0 and like note I combine these two h q 1 dot q 2 dot on this side or I could say ok I will use two h q 2 dot here and I don't use this term here I just have this term to be equal to h q 2 dot. So, there are multiple possibilities for assembling this C matrix to get the same expression C q dot ok as a vector. So, so the my choice of this is going to be in a way. So, that like I use it for this property d dot minus 2 c to to express. So, by expressing in this kind of a form and I see this d dot minus 2 c. So, d expression is here. So, d dot expression is these ok again by using this h as as this value here I have used h to be equal to say minus m 2 n 1 c l c 2 sin q 2 ok. If I use that as a h value then I get d dot is equal to some part and when I take d dot minus 2 c it gets into the skew symmetry form ok. So, you just do it yourself starting from scratch and then like you know come to you know understanding of this is very important to get to because many times you will need to do this kind of a little bit mathematical manipulation to see how to get make sure that this once you have d dot using this d dot in some way to make sure that you know c is expressed in such a way that d dot minus 2 c gives you skew symmetry ok. So, so this exercise would be interesting to do to understand like know how this can be further generalized ok. So, I will leave this to you for generalization kind of a case I will not kind of get into generalization it is just a little bit of mathematical jugglery that I think you guys can do really nicely if at all need be maybe we can go through that or maybe I can post you know the expressions or the derivations ok. So, let us get back to our slides again ok. So, so this way we defined this c matrix in this. So, so this is one of the kind of a rearrangement is done to kind of get to this form and in this form you will find that when you define c matrix in this kind of a form you get this property d dot minus 2 c to have a skew symmetry that can be derived and shown will not get into the depth we have we will see now how we can use this form to further get you know to a control for this kind of a systems. So, digital body systems control when we see that time we will be using this property of skew symmetry and property of d to be positive definite matrix and one can see now if you go for the simulation then for simulation you need this q double dot to be expressed as a function of q's and q dot's and for that you will have to push this or this terms like on the right hand side c term and g term on the right hand side and then entire expression on the right side you need to multiply by d inverse to like you know isolate this q double dot terms. Once you isolate them then only you can use them in your simulation for getting the od 45 simulation going for the simulation you need this you know q double dot isolated terms. So, vector isolated vector you can get by this d inverse matrix multiplying all the terms which are pushed on the right hand side of this equation and that is how one can get going with the simulation of such complex systems which are in general like you know having this cross diagonal terms or off diagonal terms to have cross coupling between different variables that are there as a generalized coordinates in the system. So, this is how things go for the general mechanical system and these properties are going to hold for mechanical systems for sure with rigid bodies and this is important time invariant mass. So, the mass is not changing with respect to time there these properties will hold true. So, when the mass is changing with respect to time then we will have to again recheck and make sure that this will happen or not because we have so far in the thing we have like no dependency of d on the time is considered explicitly. It is implicit in q is fine no problem, but explicit dependency of d matrix on time is not considered in the whole derivation, explicit dependence of kinetic energy on the time, d matrix is just a part of the kinetic energy. So, this kinetic energy expressed as a time as a function of explicit function of time is not considered in this derivation that is why we cannot say these properties will hold for time invariant and time varying mass. These are like so far valid for time invariant mass. So, one can see what changes it may have and all this and so forth that can be a matter of further discussion. So, this is how we proceed with base development for general mechanical systems. So, all the mechanical systems with n rigid body so robotic systems are the part any mechanism is a part. So, everything is covered under these edges of these you know Lagrangian formulation and what we have we do not have so far here is the damping terms and any other kind of forms of a terms which are energy consuming. So, those terms are going to be forming like you know these external forces in the system. So, as a damping as we saw the damping will form this external torque in the system and they will come appear here external torques that you are applying or external forces that you are applying. So, this tau is just a term, but it can be in a force or it can be in a torque form or moment form or whatever form in the direction of this generalized coordinate. If the generalized coordinate is a linear kind of a quantity like you know the x then this will be a force. If the generalized coordinate is theta as a rotation kind of quantity then this will be a linear torque. So, this torques in the direction of generalized coordinates they need to be added you know the damping and other terms can be added into those parts. So, that is how we will proceed with the mechanical system derivation.