 For today's class, we are going to look at mathematical modeling continue with our discussion and specifically we will see this Lagrangian formulation of dynamics of problems ok. So let us begin with the slides. So this Lagrangian formulation is basically a method based on the energy. So you do not need to really worry about the free body diagrams that you draw in the case of Newtonian formulation. So this is purely based on energy and we will see how it is effective in many different cases. So internal reaction forces are not to be considered during this formulation that is what it is important to see that. And then this becomes like a very good tool for many different complex mechanical systems typically like complex 3D robot dynamics with multiple links connected together. In fact, it can be applied to the flexible robotic systems as well although we will not have it in the scope of this class, but flexible robot also that can be modeled by using the Lagrangian formulation. Then it is better in the Newton's method in the sense of you know couple of things actually. So as I said earlier like you know these equations are based purely on energy principles. And the equations that you finally get are having some kind of a mathematical structure which also will be there if the Newton's equation obtained by Newton's method both are equivalent to each other that is what is there is a proof that exists mathematical proof that exists at both the methods are equivalent. But the kind of way the Lagrangian formulation gets derived you get some kind of a structure that structure becomes an important aspect for the control purpose. So we will see how and how and why it becomes important as we proceed ok. So first thing that we will deal with the Lagrangian formation of these systems which are mainly the rigid body motion systems ok. So what are these rigid body motion systems mainly we are having like all these linkages here are rigid in the nature. So that we can write to kinetic energy and like you know you do not have a systems which are having infinite degrees of freedom. They have systems where the degrees of freedom are finite. For example there are four rigid bodies involved with ground as including the ground and only one degree of freedom in this case. Similarly in four bar case then in these there are multiple rigid links that are involved and then there are actuators also there is some kind of a mechanism that is get formed because of the placement of these actuators in different places. So this will have a different kind of a evolution of dynamics of the system ok. So there can be like no many different so there are these three actuators you can see. So this is typically a three degree of freedom arm and if you can consider if you want to consider you have this rotary degree of freedom also which is the fourth one ok. So considering this of course this bottom to be stationary. So one can consider like you know depending upon the needs of the problem of control what are the degrees of freedom that are to be included for modeling. There are some other examples of these rigid body systems robotic systems you have geared based systems you know in camera you will have like know some kind of a elements for gears and motors for motion of the lens this like again a robotic system ok covers that robot for different industrial applications thing like that. So all these systems ok they can be very nicely modeled by using the Grand Gen dynamics and based on the equations that you obtain in some generalized form control can be proposed for especially the systems which are fully actuated systems ok where all these robot joints every joint has the actuation ok no joint is left unactuated then you will get nice control that can be developed later. So the basic principle in which the grand formulation is based on is Hamiltonian principle the Hamilton's principle. Now what is this Hamilton's principle it states that the evolution of a system between the two time points T1 and T2 ok is a stationary point of an action functional. Now this action functional is defined in this kind of a way so you have a integral of Lagrangian function here which is a function in general of the states of a system Q and derivatives of the of the. So states are basically Q and Q dots actually Q are generalized coordinates and their derivatives also will be coming in the form of states and then this it can be a general function of explicit function of time as well. So this Lagrangian is defined in specific way which is like you know kinetic energy minus potential energy. So this is not a general function of generalized coordinates it is a very specific function called Lagrangian of the system ok. So this is very important. So this is a stationary point of this action functional which is based on this you know kinetic energy and potential energy. So in some gross sense one can see that you know the kinetic energy so for a for a system say let us say example of pendulum ok when the pendulum motion happens typically along the path of the pendulum what is happening to the energy can you think about that. You can see that the energy remains constant for the pendulum like you know kinetic energy getting converted into potential energy and vice versa at different points. For example, if the pendulum goes to go towards the end the potential energy is maximum kinetic energy is 0. So it becomes like you know stationary there in for a moment its velocity is 0 and when it comes to the center the potential energy is completely converted into kinetic energy and it has a maximum energy in the center. Now again it goes to other side ok that is how the pendulum can see that the total energy in some sense is conserved along the path. And the same kind of idea is there in this form of like you know integral form that is there for the functional. So if you take these points T1 and T2 are two states of the system say somewhere along the path of pendulum one can say ok corresponding to Q1 and Q2 as a generalized coordinates or Q in the generalized coordinate case of pendulum will be theta of or the angle of the pendulum. So between the two kind of thetas you will have this functional defined and now what we are interested is in finding the path in between these two points of a system ok along which this functional has a stationary value. What it means as like you know as you put up say suppose instead of the circular path that we know of we take some other path for theta not not really ok sorry the circular path remains the same but in time see this Q is defined as a function of time here ok. So we take whatever function of time some function of time for theta ok and that defines one path between the between the two theta points of our pendulum ok but that may not be the final path I mean the pendulum has some kind of a sinusoidal variation of theta. So let us say assume for the discussion purpose a small angle theta kind of a variation ok. So if you have if some path is linear that is defined then that is not a path where this function will have a stationary point in the sense like that this function functional is minimum. So what is what you mean by the stationary point is like you know when you take a derivative of these the derivative will give you with respect to Q or with respect to actually the curve Q in terms of time that that derivative will be equal to 0 first derivative will be equal to 0 which will give us a stationary point ok. So so that is a kind of idea that that goes into here. So you have many different paths defined for this evolution of Q and you choose a path ok in some way or mathematical we will see what is mathematical way of doing that basically by by using the Hamilton I mean the the variational principles. You choose a path along which this functional is stationary ok and to come to that point like you know we will need to take like you know partial derivative of or delta of S or variation of S with respect to Q that will be 0. So variation of S with respect to Q will be 0 that will give us equation which is you know the Lagrange equation. We will not get into the derivation part of this equation but we need to have this like the fundamental concept understood so as to see the applications ok. So for example in this case this L has only Q, Q dot and T and the L is defined as kinetic energy minus potential energy. So if this Q's are these are like you know generalized coordinates and they are equal to the number of degrees of freedom. So if you choose Q's in such a way that they are not matching the degrees of freedom of the system then we will be in trouble ok. So we will have to kind of express the kinetic energy and potential energy in terms of these generalized coordinates that is the most important aspect of point that one needs to remember ok. So we will as we proceed like we will talk a little more about this point. So what we are going to see is not a derivation of this equation but application of the Lagrange formulation ok. So let us see what is the Lagrange equation that we get after like doing this variational principles applied to this functional to minimize for a general system of n degree of freedom kind of system. How this functional minimization ok or del variation of del S ok variation of S which is del S with respect to Q's ok will be equal to 0. What it gives as a when we kind of mathematically derive it in terms of L that gives us this final equation ok. So just see carefully this equation states that this L here has a partial derivative with respect to Q dot ok. So this is so L will in general be dependent upon Q Q dots and time explicitly but here when we take for example the it is a partial derivative with respect to Q dot and here like you know you have a partial derivative with respect to Q and then this is a full derivative with respect to time. So this is not a partial derivative ok. So this is important to note here. So as we apply this you know things will become little more clear now and Q as I said are generalized coordinates. So generalized coordinates will be equal to the number of degrees of freedom of the system and if they are not then there will be some constraints that would exist between the coordinates. So for example if we talk of pendulum system my favorite system the theta is like a generalized coordinate we can take. But x and y coordinate if we express you know kinetic energy potential energies in terms of x and y. Now x and y we know are not like you know independent of each other for pendulum kind of a system because it is moving along a circular path ok. So that path gives some kind of a constraint between x and y. So then this particular equation may not be applicable ok. There is something else that we need to do in terms of if you want to use the coordinates x and y separately. We can make a choice to express everything in terms of x or everything in terms of y considering that it is moving along the circular path ok that is ok no problem. But if you want to use x and y separately then that is not not a good that is not possible with this kind of a discussion that we are doing in the class right now. There is some other formation called constrained Lagrangian formulation that will have to be employed for the case where we have x and y which are dependent upon each other. So we will have to have additional constraint that equation that is put and then some constrained Lagrangian that needs to be defined and then we need to apply the Lagrangian formation in a for a different setting. So right now we are looking at only a case where there is no constraint in the system and you have all the degrees of freedom are having independent of each other as a definition of degree of freedom says. And your kinetic energy potential energy are expressible in the in the form of generalized coordinates ok. This is these are some of the important considerations to apply for the Lagrangian formulation ok. So the L is defined as a difference between kinetic energy and potential energy. So kinetic energy in general for rigid body system can be defined as you know from the concepts of kinematics and dynamics that we have seen is half mb this v is of the center of mass of this c point is a center of mass of rigid body. So you just see the rigid body motion in motion. It may be part of some mechanism or part of robotic system or part of whatever system does not matter. We just see a center of mass and what is the velocity of we ask a question what is the velocity of center of mass of the rigid body. And the kinetic energy is defined as mass times v transposed into v for the center of mass. This v is v c is the velocity of the center of mass ok. So it is like a half mv square but like now generalized now into into this form ok for the rigid body or like in general kind of a motion in in 3D space. And then this is not a complete kinetic energy. This is just a translation part of the kinetic energy and then you have this as a rotational part of the kinetic energy. Again this we have seen in the in the like you know K Dom kind of a fundamental fundamentals. If you want you can just like you know just revise this kinetic energy expression revise some of the fundamentals of kinematics and dynamics and like you know you realize that this is expression for a general expression for kinetic energy when you have a rigid body motion having it in the 3D space. And this omega transpose i omega where i is the inertia matrix for the for the rigid body defined along the defined about like you know the axis of coordinate system passing through the center of gravity or center of mass of the body ok. So this is this is again another important point like you are not taking inertia this inertia matrix about any other point in the in the in the system. So you you are taking it about the axis passing through the center of mass of the body. This is these are the these are the two terms that are coming in the kinetic energy expression. And this inertia is this are mass moment of inertia are defined in in this kind of a fashion ok. So this is like a expression for general rigid body kinetic energy motion and then we need we can use that into into Lagrangian formulation ok. So we will see now the application with some some of the systems. See potential energy one can based on the some kind of a reference one can define potential energy in terms of these different generalized coordinates. We will see how this this definition of kinetic energy can be then finally, expressed in terms of some generalized coordinates and so on so forth. And then like now we can do some generalization in the later part of the this lecture or maybe the next lecture. Now we can see some some simple examples for the formulation. So let us take our famous spring mass damper system here. So kinetic energy for the system is is one can write very simply as half m x dot square. There is only one mass that is in motion. We are considering the spring and damper to have like massless properties as compared to the m. So this is our all like you know this one has to think ok what are our considerations ok. What we are considering as degrees of you know what part of the system we are modeling. What is the dynamics of significant importance. These all user has to have that that thing in the mind ok. Or mechanical engineer has to have very clear understanding ok look this is an important part of my system that is what I want to model and other parts I have I will I will kind of ignore in the morning. Otherwise like you know you start thinking of ok spring also has a mass or like damper has mass where is a kinetic energy potential energy or like because of the of these masses sorry the kinetic energy because of these masses which we are not considered here. So then like one can consider of course if we want to for formulation but then whether it is really worth considering or not is a question because the terms that we are getting in the final equations are completely ignorable as compared to this term which is coming because of this big mass. So that those kind of a calls is what user has to take and then he or she has to go ahead and define these energies. Now look here we are not really considering this damping in the system in any of these energies ok. The potential energy as you know from from the first principles that energy stored in the spring is half times k times x square. So we are not this C or the damper energy is not coming in these these two equations. So where it will be so let and then also this force is not coming into formulation of Lagrange equation. So these all terms like you know these terms which are not coming finally in the energy expression they have to be get somehow considered in this generalized force along the direction of the coordinates. So this tau i is a generalized force along the direction of q i ok. This is a statement very important because we need to make sure that ok this force is along this direction. If it is not then like now we need to find out what is the force along this direction ok by resolving the forces in inappropriate kind of a way ok. So say for example if I am applying this force to be in this direction ok that is what is given and I need to see what is the component of this force which is coming along the generalized coordinate which is x defined in this case ok. So those are the kind of nitty gritties that one has to be bothered about while applying this Lagrangian formulation to simple systems that we will consider. So then we define this Lagrangian as kinetic energy minus potential energy and now you take a pause here and diagnose you derive yourself what is the equation of motion coming when you apply this formula ok. So it is kind of going to be pretty straight forward because x dot is coming here only and then when you say dou L by dou x dot ok that time you get 2 x here 2 x dot here and then you differentiate anything like that ok. So you do that whole process and then after doing you come back ok. So after coming back you will see that ok this equation is of the sort this m x double dot plus k x is equal to now this force f is in the direction of generalized coordinate x ok. So in the direction of x any other forces that exist would be bundled into this f here and in addition to this external force f that is applied on the system this c x dot damping also can be considered. So this f can have value which is this f minus c x dot ok. So that is a generalized force that can exist on the system. Right now I have ignored the damping and I have just written this equation only with this f here. Ok. So one can consider also the damping in terms of energy part which is called Rayleigh damping function but we will introduce that later into the system. Most of the cases like you know it is easy to see that the damping can be resolved in the direction of generalized coordinate and incorporated in the equation later as a external force either ways is fine. So then we see some same system but now if it is considered in the vertical plane then how do you account for potential energy in this case. So it depends upon how do you define your generalized coordinate to measure from. So there are two possibilities one is like you know you see that ok your generalized coordinate x is defined when the spring is having 0 expansion ok that is one kind of a case and other kind of a case will be where the spring is having extension in such a way that the initial deformation of a spring balances the force mg ok. So we so for the grand formulation we can consider both of the cases but then the energies that are to be considered then have to be little different. So in first case when you consider the spring to be having free length here and from that is my reference point for x to begin then you consider like a normal way all the forces of like say now in there will be additional potential energy because of the lowering of this mass ok that has to be accounted for and then you write the equations of motion in that kind of a form. That is the most what you say general way to consider that is the best way to consider the derivation in you start off with the spring having a 0 deformation ok that is how like you know you should define there is no there should be no stored energy in the in the elements to begin with that that will give you formulation without any activities. Other formulation where one can see that ok if I deform the system allow it to kind of get into the equilibrium position with spring force balancing the mass then that I define that as my 0 and from there I start measuring x then the you know that you know from your Newton's formulations also that then the additional change of the gravity ok or gravity force will not come into picture in the formulation because that initial balance of the spring force is is already balancing the mass. So, this then once once that balance happens beyond that whatever displacement is happening exactly same as in the case of the horizontal version of this system ok. So, I would suggest that you apply Lagrangian formulation for the case where like know you have a free length of the system and see the equations for yourself and then if you have any doubts we can discuss more later ok. So, you do that and then you proceed for the for the for the recording.