But here, let's say you have the initial attitude. Your sounding rocket stands perfectly still on the pad. So initial attitude is zero real, zero roll, zero pitch. And you measure the rate gyro information so you have this. You have a whole time history. We've curve fitted it with a polynomial function or something. And now we integrate this. Are there any issues with this integration, Daniel. >> Have a singularity. >> Theta singularity, we have trouble potentially. There's a zero over zero ambiguity. Depending on your time step you may get closer to that zero singularity. And then the next time step you punch through it to the, you might get lucky. [LAUGH] But that's definitely an issue. Are there issues with the DCM. We talked about them being a constrained set of coordinates. And when you integrate that kind of constraint doesn't stay there it starts to get corrupted. Do we have such corruption issues when we deal with Euler angles. >> No it's not [INAUDIBLE]. >> That's a benefits of a minimal coordinate set is that at least you may have some integration errors where you're off by three seconds in your altitude, because whatever integration you use. What you ended up was still a perfectly valid description of pitch and roll. Everything is good. Versus with the DCM. If you don't do something about that error, it builds up and you end up with a DCM that's not at all orthogonal. And you map things, you have values that are bigger than one in there, and all craziness will happen. Then that's an extra step in how you have to reapply those constraints during an integration. We will see that again when we go to other sets that are redundant as well. This is a minimal set. With minimal sets, you don't have to worry about that, but you do have somewhere, always a singularity, as you pointed out. That's something to consider. I think the next homework, you're actually going to be integrating this. I'm actually giving you time history of a simple first order integrator. At this stage I'd really recommend writing your own integrator. Who here has never written their own integrator before. I'm going to show you some really simple way. because I know your first instinct is go to MathLab and type in OD four, OD f four five, whatever it's called, and integrate there. But down the road we're going to get to coordinates where you're going to have to do to particular coordinates within the integration. Very tricky to do in OD four, five. If you just, this is such a simple integration, this is a good one to practice. Let's just talk quickly about how to make a simple integrator. If you look up any integrator, they usually write everything into state space form. X start equals to F of X comma t. Something like that. They all look up like a or Euler method, or second type of runner. They're all in this form. X here is a state vector. Let's apply that to the yaw, pitch, roll problem. That's actually your next homework which you have to do. So, Nick, what is my state vector if you're integrating. So let me just kind of flesh out these equations, all right. Equal to this B matrix. Times this B frame representation of omega. And you have this given this time. That's a given quantity. What here would be my state vector. >> Your velocity. >> This one or this. >> Yes it would your Euler angle. >> Angles, the rates are their derivatives. >> Right. >> So x is just yaw, pitch, roll. That's it. When we get to the kinetic side we're actually going to find differential equations for this. Are you a dual spinner. Are you a single spacecraft. A spacecraft with three [INAUDIBLE]. It's all going to have different equations. And then you just plug it in differently. I really encourage you at this stage with this very simple integrator problem to write nice clean code that's modular. And you want to write it in this way where you just have a state vector and right now we just have three variables. If later on you have three or six, you just have to expand out. Okay now I have attitude and rates and something else, like reaction rules at the end of the class, that we can include. And you're ready to go. It'll save you lots of time. To write an integrator, there is nothing particularly tricky in this class that really requires a fourth order, time varying, self healing whiz bang magic of OD four, five that MathLab has. It's a very powerful integrator. But it's complete overkill for what we're doing in this class. I'm going to show you the simplest integrator you can possibly write which is a first order Euler integrator and that's the steps. If you want to get better, you can do a fixed time step fourth order. Just look on the Wiki it's like if you call this f function four times instead of once. And once you've written in this form, it's really easy to go from a first order to a fourth order. And you just you know do it four times and then blend in and then you're there. With any integration we always start out with X-naught the initial set of states. So if this is a sounding rocket, where am I. Right [COUGH] this is my initial attitude maybe it was tilted. Whoever mounted it was a little bit careless. It's five degrees off. You give it initial attitude that that's set. Then the next thing is you start your time loop. So you say time is equal to zero. T final. This is kind of pseudocode. We're just kind of fleshing out. Whatever language you're doing, you make your loop somehow to go over time. Then, with the Euler Method, basically this becomes my, let me write this the other way. That would make more sense. Here we go. X n is my current set of state of vectors. It is equal to the initial set. X n is always the current step of my integration. I'm going to go one forward one time step and XN is the next time step and then go forth. What I need to do here is, I have this, and the update. The digital updated equation for Euler's integration says, the next time step is equal to the current time step plus F times DT. Graphically it means if you have some state, here's time T. Here's your state XN. F is really the local slope. You're just doing a first order extrapolation. If that's the rate you're moving at and this is the current state, then one second later I am up here. That's a first order integrator. So here this would be T plus DT. And this would be your predicted X and plus one state. That's it. In here what you have to do is you have to compute this F function. I'm just going to write it. And I'm going to call this function and store the answer with my current time and my current state. This gives me my slope. And then if you want to be explicit, you can say, look, XN plus 1 is equal to current XN plus F times DT as a first order integrator. And then before you finish, you want to replace new with old. So you would say XN is equal to XN plus one. Now you're ready for the next time loop. When you go up to the next time, you've already got the new currently predicted states. And that's all you have to do. But the beauty is if you write it this way, then homework two does some of these integrators. Homework three will have integrators that might be slightly different with omegas. You get to reuse a lot of your code. And you just have to go well now, my F does something slightly differently. But I'm still sending it a generic state vector. Use at the four states, five states, whatever you're integrating. You can do this in OD four, five especially later. That's fine. But my recommendation is do this. This will be helping you a lot during this class and saving you some time. And later on you're not resting. When you get to MRPs I'm going to expect you to do switching within the integration. And you can set up events in MRPs. So in OD four, five but it gets a lot trickier to implement that. It's possible, but it's a lot, lot trickier. This, actually in research too, I typically write my own integrators so then I know precisely what's happening. And I'm doing and I can control what's happening within the integration very, very meticulously. So, simple process, Mary. >> Does the method matter. Are you going to indicate that in the homework, or whatever, or. >> Sorry. >> Does the method matter. >> No, just indicate so we know where the answer came from. And, hey, here's the plot, and like, well, [LAUGH]. So if you show quickly, yeah, I used this. And for this one, I was running a low in time. I used it only four, five, this is what I get my three lines but that I solved it with. Cool, full points. If you write one of these, great. Most students tend to write by the end. Because not only please me at the beginning it just says kind of I'm so busy, I don't have time to learn this. I will do this a little bit later. I just want to make everybody aware that this class has a series of programs that are going to be happening. And the earlier you spend putting them into a modular form the more you'll get to reuse them. And it will save you lots of time down the road as well. So just some suggestions. But yeah. No, good question, good. This is a review of differential kinematic equation. With these If you measure omega, you can do tons of useful stuff all ready. We're just assuming we can measure this stuff. Somewhere in this function, you'd have a, you would be specified this is what omega is, right now. Play with that. Some of you've done a lot of this, you'll be done in ten minutes. Some of you've never really written or integrated these systems too much. You will be spending an hour on this. But it's a hour well spent, because it will, all the math, that how does this apply. And the numerics is going to sink in way better.