Good now we're actually going to make these things do something. Lyapunov functions. And how do you come up with these. We talked about energy. Energy's a big inspiration for this stuff. But there's a modern mathematical structures especially for CRP, MRPs and all the parameters that I want to show you. Some of them you're going to prove the math in your homework. It's pretty straightforward, I'm going to show you the results. Coming up with them originally, that's the hard part. But now that you see them, it's not that hard. So we're going to start out with two things. We're going to start out with rate measures and that means you're tumbling. And you just want it to stop tumbling. Anybody remember that mission, what was it? One of the Gemini missions, where there were two astronauts in the Gemini, trying to dock with another capsule up there. And then something went wrong and they were tumbling. I mean, they were tumbling crazy rates. Amazed they didn't just black out. But they were able to figure out something was miswired in this firing strategy or what they thought would be improving it, no, they were moving off to infinity speed rate. At least as long as they had fuel. And they were going crazy revolutions, they finally got it to stabilize. Do you think those astronauts cared when they stop the spin if they point left or right? I wouldn't, right? I just want to have the bloody spinning stop, right? And that's kind of the strategy here. Tip offs, the classic thing with spacecraft. You get the little small sides that get released. Basically, they get chunked out of the spacecraft, right? And you know they're going to tumble. It's not going to be elegant. You're just a secondary, tertiary payload, so you're out, thank you. So now we have to always think about untumbling stuff, right. And how do we do this? So, we're going to talk about the open off controls just for tumbles. That makes it a first order system. I don't care about my attitude. Shayla earlier was talking about having attitude and rates. Now, I just care about my omegas and I've got the first order differential equation for my omega, right. I want to bring my rates to zero, that's the goal. That's everything that we're doing. I'm using this q notation. So, we're going to be talking a lot about specific single rigid body equations proving all these properties. I'm going to show you the stuff now for much more general, this is really any mechanical system can be written in this form. So if you're familiar with Lagrangian dynamics, congratulations! You'll know exactly where I'm going with this stuff. If you're not familiar with it, no problem. You're not asked to do it as an exam, or something. But I'm going to highlight the key concepts. This is how we get the equations. What I'm hoping you get out of this is that I can show you, some of these properties that we're using are actually really powerful. And you can do these on any kind of a mechanical system. And you can expand these controls. So the goal is, while it's a second order mechanical system, we have states and rates, I only care about my rates. The kinetic energy you can write with a system mass matrix. It looks something like mass over 2 times rate squared. If you have a rigid body this would be omega tranpose i omega, right? Before general mechanical system you may have multirobot links who knows. We can always write in that form that looks very, very similar. And it says symmetric posi definite matrix that's M is equals to M transpose it means it's symmetric, greater than 0 means it's posi definite. Its always going to be true with the mechanical system, not just for the inertia tensor. So we can write it this way, so kinetic energy becomes a very convenient positive definite measure of my errors, which are my rates. If you go through like Rajon Dynamics or Kaine's equations, or Dolombert's principle, you end up with these equations that are fairly long system mass matrix times acceleration. This would be something like inertia times I omega dot is equal to minus omega tilde, I omega. Which is kind of this term plus other stuff and the [INAUDIBLE]. You wouldn't have this in the rigid body dynamics. Because [INAUDIBLE] is constant. A simple body frame. But you get this general description. This thing is called the Christoffel operator. If you're very curious it has a lot to do with matrix math. But it's there, again, the detail is not important. Q here is just a generalized force. But you think attitude dynamics, that was the u. That was the external torque that we had on our dynamics. If this has translational forces and rotational torques this would all be in that q vector in a very general way. So we need a Lyapunov function. Step one is always, what do you care about? In this case, I only care about my q dots. So I want a Lyapunov function that's positive definite only in q dots. Q happens to appear in here, but it doesn't impact the definiteness of it. In fact, n, regardless of q, is always symmetric definite. So, no matter what, like a multi link system. No matter what I throw in, I'm guaranteed this is a symmetric posi-definite matrix. And this kinetic energy, essentially what I'm setting it to is equal to my v, all right? But over here, so while there's a q here, we don't care about the q, right? We only care about stability of the rates. Are the rates coming to zero? I don’t care if I point left or right. So, good, we’ve done this, you take a derivative, this is where I’m going to wave my hands a lot, because there's a lot of math goes into this, I’m just kind of showing you the pattern, right? Before we get into the details of [INAUDIBLE] that's where you have to own it. That's where you'll be doing it yourself. This stuff, chain rule, this kind of becomes this with the double dot. But then M itself depends on Q, which can depend on time and there's an extra term that you get. So lots of math. This takes a few pages putting it all together. You can write this out, rearrange this. MQ double dots. That comes from here, our equations of motion. So like with the spring mass damper system, we had x double dots. We plugged in to x double dots to see what happens. We have to apply the equations of motion at some point to your Lyapunov Rate Function. So we plug it in. That gives you this stuff. This term with extra math. You can prove there that that's going to be equal to this term. And with the minus half plus half, those two terms actually cancel. And lo and behold, my V dot, despite all this nastiness and implied craziness that happens, is extremely simple. And this is V here happens to be true kinetic energy, so that means this is my power equation. What's my time derivative of kinetic energy, which we've solved already for a rigid body? For a rigid body, what was T dot, if you're only looking at attitude motion. Andrea, do you remember? Anybody remember? It was omega dotted with l, right, that was it. And for force, it's force dotted with velocity. All right, there's a clear pattern. So you can see, no matter how complex, how weird the mechanical system, whatever these generalized forces are, are mixtures of torques, and forces, and craziness. In the end, it boils down to this very simple system. This is actually often called the work energy principle that we will re-examine when we get to motor torques and CMGs and so forth as well. I can predict what the power input will be, how it changes kinetic energy with an extremely simple term. If you derive this, this takes a lot of effort. And in six, two, ten you actually do that. So just, it's fun. So, this is my derivative. This is v dot. Now here, I'm looking for a control to arrest any q dots. So, what could I make my big q? That's my control. I get to pick what forces, torques are acting on the system. And there's lots of, there's an infinity of choices, really, in how you could pick this structure. Can anybody think of a simple choice of big Q to make this V dot negative definite? Sorry? >> [INAUDIBLE]. >> You could pick. Okay, let's actually. Let's go through this, I'm glad you mentioned that. So, I don't need pen, okay. V dot is q dot transposed with big Q. If you set Q = -q dot, I get a system like this. This is stable. Actually asymptotically stable. And looking at all the conditions it's globally asymptotically stable. Hallelujah, that's really fantastic. Would you want to sit in that spacecraft when I'm flying this control? What is the issue with this control right now? If the controls can be minus the rates that's it. What's the before, we've argued stability, does, like alpha and omega. Stability is the alpha. If you don't have stability, forget performance. But we have to also look at performance. So how can you control the closed loop of performance if you're setting this to just be equal to minus q. >> Wait, what was? Repeat that question. >> At this point, once you have rates, I am tumbling at six radians per second about this axis. That's it. >> Just doing the opposite? >> It's going to do the opposite and with the unit gain, essentially. And then that's it. There's no knob to tune to say, hey, I want to be aggressive or no, hey, I'm flying. >> Some K positive K, well that's a gain control I guess. >> Yeah so again, you're picking, you're making this control. You can pick a positive constant in there. And then in that case, this gets multiplied times K. It doesn't change the stability as long as your gain is positive. Right, now you've imposed a constraint on your control selection. But now I have a knob to tune, and I can make this basically just a proportional feedback, which is a linear control, but I can prove global asymptotic stability on the complex non linear system. Which is kind of cool. So we're going to do the same for this spacecraft. So, this is the one that we're going to use instead of a single gain. I can make it more complex and give the control designer a lot more knobs to tune by making it a fully populated, symmetric posi-definite p matrix. because then, the response will simply be, I think v dot is minus q dot pq dot, which is v is a symmetric posi-definite matrix. Minus data is going to be negative definite. And I have asymptotic stability. So now you've given him his. So your result with Q, it would be K times identity and we often do that in real life. It's just like okay same gain across all the axis. If you want more knobs that's were it goes. Does that make sense? So let's see if we can wrap up rates here. Tracking Instead of driving q dot to 0 what we want to drive is our rates minus our reference rates to 0. So if you got a spinner and you're supposed to be scanning across the sky and you have this constant rotation you should be doing you have a non zero rate. Then you want to compare your actual rate, I'm going at 1 degree per second and I'm supposed to be going at 10 degrees per second. And you're going I've got 9 degree per second error right. I want to make that match a non zero rate and even can be time varying this makes it a tracking problem. What we tend to do you will find is we use the same algebraic formula if this, if you drop the deltas this is kinetic energy on this mechanical system. By having deltas, it's something energy like in the algebraic structure. But it's not exactly kinetic energy anymore, right. But it's still positive definite, because m is positive definite. And this tends to be useful, because to plug in equations emotion, we always end up have mass times m x double dot somewhere. And with the derivatives of this, you're going to have some where delta Q double dots times this mass is going to make it easy to substitute. If you do this, plug it in, plug it in equations, the motion we have before, things don't just drop out where you have Q dots transposed with big Q but you have all these extra terms. And some of them have rs on them. So then I can solve for a Q here that will make this, there's a dot missing here. There defiantly should be a dot on this one too. So V dot would have to be negative definite, which makes it again globally asymptotically tracking. But I can track a reference rate not just a zero rate with this one. And if you look at the control, before we just had this part, that was the proportional feedback that made it work. The tracking ones always are more complicated. You often, to get asymptotic conversions we have to feed forward the reference motion. Hey, you should be moving at this rate ideally, and then that kind of dictates what, if your reference motion is time varying, you may have an open loop control. Torque that says, I need to accelerate, slow down, accelerate, slow down, that's the nominal one and then you super impose the rest of it. So these terms without that's your feedback terms and the ones with r, those are your class equals called feed-forward compensation. We're giving the control knowledge of what the nominal motion should be but we will go through these steps. This is going to go quickly it probably doesn't all sink in. I just wanted to show you this works on a very general dynamical system. We can apply it to a variety of stuff and then we're going to specialize the rest of the class on rigid body, rigid body, rigid body going through all the different primitive issue.