So the last step is - we've done kinematics, we've done all that stuff, we've done our control laws, we've gone through the up and off definitions, right? And we've developed them. But so far we've developed controls laws just for you. We had these equations of motion, I kinda - I think I've got that equation here. Yeah. Pretty much like this, right? And we found out some method to come up with this U, L is treated as a non-torical; if it's known, you can include it. Right? But there's certain steps that require it. What I want to do now is show you, in this one simple example, how we can use everything you've just learned to become answers for and apply it to a different dynamical system and come up with a control very, very quickly. And you get the same stability argument, the same analysis, all the stuff, but the control will look differently because it's a different dynamical system. All right? That's the goal. That's what we want to do and that's what we'll end with here. So now it's a control with multiple things. It's where everything kind of comes together. Here is our equations of motion. This is a single spacecraft with N reaction wheels. We were able to write the momentum of each reaction wheel into the h vector. That's what we got here. And this us is nothing but an N by one of motor torques. We have that form. That's still some external torque. And everything else is fixed. I(RW) in this case is I(RW) fixed as seen by the body. All right. If you look at the definition here, this is a system of reaction wheels. So our gt and gg fixed as seen by the body. Yeah. Right. So that's going to be nice. So in our earlier - the Lyapunov function that we had, you will see there's a slight modification; but we can use the same tricks as if it was just this one as we had earlier. Before we basically just had a rigid body which was - which we're now calling Is. So now, we want to do three Xs attitude control. I want to point my heading and control the rate simultaneously to do a tracking problem or regulation. But I think I'll do a - a tracking here in a moment, the most general form. So that means I want to come up with a control law for us, a set of motor torques that will make this craft spin up the wheels, gyrate, spin around and stabilize smoothly, pointing in the desired direction or stabilize and smoothly follow a time-varying history. Right? That's the reference-tracking problem. Outline for me quickly what the steps were. How did we do this? Tepa - we'll start from left to right in the room. If we do a control, first question is what states are we gonna control? So in this problem, what all has to go to zero? The Omegas - oh, well - yeah. I guess if we want a - well, not Omega, depending on the frame. The frame-to-satellite omega has to go to zero; frame being the goal frame. So the reference frame? Reference frame. If it's in - if it's in trackings or Omega B relative to R has to go to zero? Maybe R. So which Omega is this? This often causes confusions to people. BN, isn't it? This is BN, right? If you see that, that's just the body. When you simulate in the code, you're simulating BN. And then you're somehow keeping track of what the reference has to be and you always have to compute separately. You never compute BR, Omega BR, even Sigma BR directly. You compute Sigma BN just hey, this is my system and it's spinning and gyrating and this is the reference. And then you do all your proper kinematics. Good. So that's one of them. What's the other? So our rates want to go to zero. Relative angles. Yep, definite Sigmas. You know me, I like Sigmas. Right? So our Sigmas, which are Sigma B relative to R. Right? But we just write Sigma for shorthand a little bit. But if you would like it merbose - good. Now, Mariel, we know what states want to go to zero. What's the next step? What do we have to create now to devise a control? A Lyapunov function. Okay. So, Andrew, what does a Lyapunov function have? What properties must it have? So the function itself has to be opposite semi-definite [inaudible]. Negative definite? Negative definite - or negative semi-definite. And the - Depending on what kind of stability you want, right? Just stay at stability right now. Okay. So Vdot has to be negative set. Yeah, that's the next step. But right now, the V function is set positive semi-definite? So I can make a V function that is all zero? That would be three positive-definite. Yeah. At least it has to be a neighborhood somewhere that is positive-definite. Ideally, it's globally positive-definite, that would be ideal, right? But yeah, so it has to be a negative. Good. So now we go to V. What's the next step, Mondar? Oh, we have to take the derivative of it. Right. And then - So you take Vdot. Now, we want this - and you already gave that, saying it had to be negative semi-definite. So what do - so, Kevin, what do we make Vdot equal to to make it semi-definite? Minus the term Omega transpose P. Yeah. So the rate measure squared which - Omega transpose P - Omega, something like that. Could you make - for a secular mechanical system, can you make Vdot negative definite directly? I mean, it depends if you want to subtract the attitude on it, but - All right. So if you're looking at this - I don't need fire, hold on. So we have V, that's a Sigma. And let me just do Omega on the regulation. This is a little bit quicker. So we've got this and we say one-half Omega transpose I Omega plus two k natural log 1 plus Sigma squared. All right. That's our favorite MRP, the Lyapunov function. You do this - you take the derivative of this whole thing and you end up always factoring out Omegas. Okay. Sigma, right? If we would say - no, we - what you described first was minus Omega transposed P Omega. Why is this only negative semi-definite? Casey? Why is it not negative? This looks negative definite to me, but why is this actually only negative semi-definite? Because of the K Sigma term? No, that's not here. Doesn't it depend on Sigma, so - It doesn't, right? It's a - this V, we care both about states and rates. This - this Vdot is negative definite in terms of the rates, but that's only half of the states we care about. The Sigma doesn't appear. So if Omega is zero, the Sigma is zero; but Sigma could be 50 and the Vdot is still zero, right? That's why it's only semi-definite. Only we know with higher order derivatives, we can prove asymptotic stability on this control in this case, but that's kind of what we do. But now, why do we make it negative semi-definite? Because with these mechanical systems, you - you tend to have a quadratic rate measure and a quadratic state measure. Taking a derivative with chain rule, you're going to get rates on both sides. And we can always factor out rates. And then we make it negative semi-definite in terms - or you know, negative definite in terms of rates. And then we can say this bracketed term must be equal to minus P Omega. And you have to - the last step is plug in the equations of motion. Right? And that's where the control variables appear. And you solve for the right control to make this work. Or sometimes we can find some of them. There's an Omega tilde, if you plug it in then we can say Omega transpose, Omega tilde vanishes. There are some tricks we can play that you get the same negative definite function. It's not just one control that gives you that behavior. But that was a step. If we had minus K Sigma transpose Sigma and we did this stuff, what happens then is we can't just factor out Omegas and solve for this. This gives you a set of differential - a set of algebraic equations that we just can't solve for that control variable. And that's the classic problem with this stuff. So that's why, in mechanical systems, we can't just do this and that's why we always end up with negative semi-definiteness with these Lyapunov approaches. And then we look at LaSalle's in-variance or Mukuchi Chan, we discussed in class, to analyze and study asymptotic conversions. Good. So that was the process. Right? Now we have something that looks a lot more complicated with whole systems of reaction wheels instead of just having that little U. Now, I'll show you how we modify this approach to get there. So good, we're here. First thing is - Tepa already gave this away, right? This is the body relative to reference. Exact same notations that we had earlier. This is really Sigma BR. This del Omega is Omega BR, but you can write it as Omega BN minus Omega RN. Same thing. We come up with a Lyapunov function. What's the only difference in this Lyapunov function, compared to the one we used for a single rigid body? There's one term that's different. Yeah, I changed this. Now this is still a symmetric positive definite matrix. Why do you think I replaced I of the hub with I(RW)? What appears in our - in our equation; in our differential equation. Yeah. When we differentiated this, this is Omega minus Omega R. You can have an I(RW) times Omega dot, which makes it really easy now because then, if you go look at your differential equations, I can just substitute it in directly. I could have an array to the Lyapunov function, it's just one-half Omega transpose Omega. But then you have to invert that inertia tensor to solve for Omega dot and plug it in. Throwing in that I there is a nice algebraic trick to avoid some silly matrix inverses. Because in the end, with the gains, you can always compensate for that. It doesn't make any - you know? If this a - as we said, if this is a Lyapunov function, I can take this function and multiply it times 10 and it's still a Lyapunov function, right? It has no impact. It just - you make your gains 10 times smaller, but it's the same the same control, the same response. So that's it. We just change this out of convenience. It's still a symmetric positive definite function the way we defined it. And now, when we take derivatives, as with a single rigid body, we only end up with the body frame derivatives of del Omega. There is no body frame derivative of this I(RW); whereas for reaction wheels, that inertia tensor, even with 16 wheels in there, it's still fixed. Right? The wheels are perfectly balanced. If they're not balanced, all hell breaks loose and it gets very complicated. But if they're balanced, nice and easy. Right? So this looks pretty much exactly what we had before. We take a derivative, we set it equal to something that's negative semi-definite, it's negative definite in terms of the rates. Then when you plug this in, we get this. Now at this stage, we have to actually substitute in the true body for a derivative del Omega, as we did before. And then you introduce the equations of motion. We plug it in and that's the only part that's different now. All of a sudden, instead of just having I Omega dot equal to minus Omega tilde I Omega plus U, we have a few other gyroscopic terms that appear. Right? But you still just solve for the same U. And in this case, I'm solving for GS times U and this is the right-hand side. So the motor torques times the projection axis have to give you - this is the K Sigma P del Omega. If we didn't have momentum of the wheels, this looks just like Omega I Omega that we had in the other control. And this is the part that has to do with the reference trajectory, the feed forward part, that this is the trajectory you should be following to get asymptotic convergence. And we feedback compensate for known external torques. It's almost the same. It just has a few extra terms. So you can see the strategy that we applied, actually Lyapunov, very quickly at least, I'm leaving with something that works. We aren't spending much time on this, but if you understand the earlier Lyapunov, it's a trivial expansion. It's almost the same control. It just - you have to not come up with a motor torque that generates this. And that's where the trick is. So let's look at some conditions. So I'll - on this right-hand side, I'm just going to call it LR, that's my required control torque. I need to come up with a set of motor torques that produces that torque. If we have this popular arrangement where you have three wheels, each spin axis of the wheel - spin axes one lines up with B1, spin axis two lines up with B2, spin axis three lines up with B3; in that case, GS becomes identity. Right? That's it. And then us must be equal to LR. So really, just the three components of LR is motor torque one, motor torque two, motor torque three. That's it. There's no wiggle room. There's no optimization. It's just one answer. Hopefully, you can do that. If these exceed your available torque, you just saturate it. That's it. That's - that's all you're doing at that stage. A more common situation is maybe - or more and more I should say common, is that you have N reaction wheels. So now we have a cluster of reaction wheels. A popular configuration is four, can also in a pyramid-like configuration, they could all run simultaneously. They can all help each other so much produce this torque. So now we have to figure out how do we invert this matrix. This is now a three by N. So this becomes a three by four. And you can't just invert a three by four, you can only invert square matrices. So there's different inverses you can take. This one is the matrix form of a minimum norm inverse. Anybody not heard of a minimum norm? Good. I won't ask Mandar, then. So Andrew, since you've heard of it - he raised his hand, he was - yeah, he was smarter than you. By now, you should be up to these tricks. All right? So what is a minimum norm inverse? What answer does it find? It finds the answer, the minimum at the linear least squares answer. No. Those are two different things. They're very similar. The - the least squares solution has this inverse, kind of, over here and the things are transposed. They are very close cousins, right? So let's go look at this. This is a little bit linear algebra I want to review. So I'm assuming you've seen this before. It's - it comes down to how do we solve systems of equations. Little less fire - okay. So if - now, we'll do this in red. Why not? So if we have GS one, GS two, GS three, GS four times us one, us two, us three, us four equal to one, two, three as LR. Just easy numbers. Right? I have four unknowns. I have four control variables. What are the four motor torques? How many constraints do I have with this equation? They must set - these four torques must satisfy how many constraints? Three, right? They all - whatever torques you pick times - you know, this is a three by four matrix. The first row times this better give me one. The second row times the same motor torques better give me two. And the third row times the same motor torques better give me three. How many possible answers are there to this problem? Infinite, actually. There's an infinity of answers, because we got more parameters and constraints. That means you could have superimposed extra conditions or just make something up. What people are doing - which is the most popular way, has been the norm - is to just make something up and say hey, out of all the possible infinity of answers, I'm picking the answer that has the smallest norm, the L2 norm, of this stack. That's what you're doing. All right? Which makes sense physically, too, because you really - you're finding the one set that has, kind of, the smallest motor torques required at this instant to produce that. It's a very - you're making it up, but it turns out to be a very practical answer. So this is the least effort. And if you're moving a big object, that's kind of the challenge, right? How do we do this? The least squares answer you're asking about, that's where the matrix looks different. So let's say we have a three by two and two unknowns. Let's call it x one and two and three by two, two by one gives you a two by one. A three by two - no, that should give me a three by one. Right? What am I doing wrong? No, that makes sense. That's a three by one. Yup. Okay. In this case, we have two variables, but three constraints. This, generally, you can't satisfy unless there's three constraints or somehow compliance. You found a way that hey, everybody has to be in a line and the only option is to be on the line. You know, that's going to work. But if you look at the classic least squares fitting - if you take data or anything - one constraint has it here, one there, one there. You've got three data points and you kind of pick the best nearest line. That's the least squares inverse. And in matrix form, it looks very similar to that. It's just the - the inverse is more on the left versus the right. So those - those are the two answers. If you don't have a square matrix that's full rank. If it's full rank, in a square matrix as if it's identity, there's only one answer. Right? So what I'm showing you here is the minimum norm inverse. And if you - if you can go look up a linear algebra book, if you're curious. It gives us the smallest set of the L2 norm of this motor torque vector to implement this control at this instant. Right? And that's what we got here now. That's what that minimum norm inverse does. So that's only one possible answer. Actually, I've published a few papers in the last five years. Maybe six, seven now - it's been longer. On other answers, there's different theories on this. This shows my use of research. This minimizes my instantaneous motor torque requirements so you can keep your motor torques as small as possible, but it doesn't necessarily instantaneously minimize your power usage. So because there's an infinity of answers, if you have more than three wheels - if I have five wheels, there's, like, two dimensional sub-manifold. Here it is a one dimensional sub-manifold that you could choose. Play with that. We actually can come up with analytic answers on how to come up with a different motor torque solution that, at this instant, actually minimizes my power, which is given here. This is my motor torque equation. So if you - especially for small sides, this becomes interesting. They're not as much torque limited, those little motors are quite good with torque, but they're very limited in how much energy they can dissipate. Right? There's this little bitty thing and you get all this power inside. That's fantastic. A big battery and it's running all these high-speed wheels. You know, it becomes a little nuclear meltdown. It - basically, it just - you know, it takes up too much heat, so you might be worried about energy usage. Or maybe you're more energy-limited with a small side and you go hey, do these maneuvers back up this little battery? It's only going to last me for x amount. Well, this other one will get you there with the smallest motor. There's other solutions we've come up with that get you there - where at this instant, I'm not minimizing my motor torques; I'm - I'm actually minimizing my power equation. And it comes out of the work energy principle. And then you do all the optimization around it. But we can come up with analytic answers and show - at times we can do big maneuvers, we've shown, especially, if you have some non-zero wheel speeds. With zero wheel speeds, normally it kind of becomes a wash, but you can save 20-30 percent of energy to do - you know, it's the exact same control response. From a stability point of view, nothing changes. As long as GS times us gives me LR, all the Lyapunov stability holds. I will have that control torque and I will have exactly this convergence; this close to performance undershooting, overshooting, whatever you've designed it to be. The only difference is what effort is involved to generate that. So that's the minimum norm solution. I just don't want to leave you with the idea that this is one, but not the only one. There's others. We have L2 norms. You can think about hey, braking a wheel. Not breaking it like this, but slowing it down as in braking a wheel. You can actually retract energy and some of the modern reactions will do that. So you can actually account for that in optimization as well. Or it becomes an L infinity optimization. Actually, Robin Blendon did a paper - or his master's thesis - on that. So he has a few papers out on how to do - at this instant, optimize my power usage. You know? Or if you want to extract power from the wheels, how do you do that at that instant? It doesn't give you a global guarantee because this is all, at this instant, what generates this torque. I have no guarantee that if I put in a little bit more effort going left that I would have a less power, less requirement. You know? It's not a maneuver-wide optimization. It's just an instantaneous optimization of the resource allocation, essentially. So there's whole papers on just this kind of a stuff, as well, of the control theory. But what I hope you see out of this is the Lyapunov stuff you're learning, it's very versatile. It can be applied to lots of different things. As we get to more and more complicated dynamics, it's always kind of the same methods, the things we've just went through in this class. It's just at some point, you apply your equations of motion. You maybe tweak this a little bit so you don't have so many matrix inverses floating around. You just put it out there up front and then you come up with the controls, the same stability. But with multiple systems, you start to raise new questions of how, if you have an infinity of answers, which one do we pick? And there's very practical answers and there's other more interesting ones, too, that gives other kind of benefits.