03 3 Replace Euler with Quaternion

Channel: Droge - Autonomous Systems Published: 2023-01-09 1,346 words Source: auto_caption
Advanced Mathematics & Geometric Physics

Transcript

in this lecture we're going to replace our Euler angle representation using a quaternion so previous lectures we defined our equations of motion using our Euler angle representation so we can see all the trig functions here now we're going to take that Euler angle representation and replace it with the quaternions so let's go ahead and get started we want to First just review quaternion so we've seen most of the what we're going to talk about in this lecture before we want to make sure that we're really sharp on it so the our attitude we can represent any rotation in a variety of different ways we talked we've talked about rotation matrices we've talked about Euler angles and we have talked about quaternions as well so just as a reminder we have our quaternion defined as e and we do 0 through 3 or sometimes we'll write this as e naught then we'll do e x e y and e z attached okay so that's in in this book that's what we'll we'll call it uh be careful of of your notation though in um for example if you're going to be using Ross uh they're going to Define their quaternion and they're going to give it an X component a y component a z component and what they call the W component so be really careful with your notation make sure you know e sub X or E sub 1 what what that corresponds to so this is for example Ross but either way in any case we get four parameters this the top component e naught this is called our scalar component of the quaternion and we refer to the E sub 1 through 3 as the vector part of the quaternion now for your call from previous lecture that we described that any rotation can be described by a a single axis of rotation an amount of rotation we're doing about that axis so here's our our aggregate rotation parameters and we have our axis of rotation so um any rotation Matrix we can come bring it in and we have our rotation and our rotation vector and our angle of rotation well the reason why we have this nomenclature where e naught is the scalar part of the quaternion is because that the E naught does not depend on the vector so no vector dependence it solely depends on that magnitude of how much we're rotating about that axis the vector part we can Define as E1 through E3 is just going to be our Vector multiplied by the sine of that angle and that will give us our unit quaternion which is great so we have we have our quaternion unit quaternity we're going to ensure that the magnitude is equal to one okay so let's write that here so unit is then we'll take our e naught through E3 I keep writing a curly on one and all right and normalize it so we'll just divide by the the magnitude of of all those variables okay so if we're going to convert between our Euler angles and our quaternions we need to Define that the relationship and the relationship is really nicely defined there's a little bit more discussion about it in the book in one of the appendices but we can just take our our Phi Theta and PSI and we can define those directly in terms of uh are Arc tangents and our Arc Sines with the different components of the the Euler angles now our our atan II just note that that's a fairly that's our that's a fairly common um notation for writing our arc tangent where we have we have our Y and our X components so we have basically it's a it's the four quadrant tangent so that avoids any of the singularities that you get which has taken your A10 and having something and dividing by zero on on one of the bottoms uh then we have yeah so we have that relationship and we can also go the other way around right so in this one we're we're taking our e and we're obtaining our our Phi Theta and PSI um in this case we're taking our our attitude angles and we're obtaining our our um quaternion representation so we have this really nice nicely defined way to map back and forth between angles and quaternions uh similarly we can convert between quaternions and rotation matrices so we can we can take our rotation Matrix and we can Define that rotation Matrix in terms of of the individual elements of our quaternion so this is really nice so that we can take we can take our quaternion which goes from if we if it goes from B to I right we can immediately write our rotation Matrix from the body frame to the inertial frame so keep that in mind we're we're defining our quaternion as such right so we've we've defined our our angles our quaternion our rotation Matrix and in terms of our quaternion and we can even go back and forth um shown on a previous lecture we could there's a nice mapping to go from rotation Matrix to quaternions as well okay so the book goes in and and basically most of it's a lot of substitution for all of these these trig terms up here it's just nice to we can obtain the Euler angles from our quaternion and so we don't really need to we don't really need to change that at all but what we do have here is now we have a nice time derivative time derivative of our quaternion Okay so the the equations of motion the other benefit of it is that these equations of motions are are linear right so given our quaternion and we have this well it's really bilinear in terms of our state where we have just our the state our current rotational velocities and we multiply it by our our current quaternion so we have a lot we have a much simpler set of State equations at least in terms of the the time derivative of of our quaternion okay excellent so we can now take these equations and we can simulate forward in time we have one caveat as that is that we have to make sure that our um we have to make sure that the magnitude of our quaternion is equal to one and so we'll see that it's provided for you in code but here's just just some details for that as well so we just after we do our rk4 update we just need to make sure that we've normalized e uh the bottom so this is if you're so we'll divide into two if you're up in python or you're you're creating your own integrator you're going to just make sure that after every when you update e just make sure that you normalize it and down below you can use other techniques basically just to normalize it in the ode solver you make it really stiff to make sure that it it's always trying to converge to that unit magnitude but then you have to use a stiff solver and so you got to be make sure to be careful with that so if you're using Matlab and you're using this technique make sure you're using a stiff solver the reason you have to do this technique down below is if you have an Adaptive step size so you have to be careful with that adaptive Stepside step size um so this is just a technique to help normalize that that quaternity so equations of motion are simpler but right just be careful it needs to be a unit quaternion okay excellent so now we've defined our equations of motion in both Euler angles and quaternions and in the next lecture we'll then talk about how do we use these time derivatives to to simulate our system