0:35

Looks actually pretty compact.

All you see is quaternions, there's no fractions of quaternions,

there's no ratios.

Ratios are always tricky because the denominator could go to zero

potentially right.

We don't even have a ratio here.

It's just quaternions squares and some the differenced in different ways.

There's clear patterns there.

So it's really nice and easy to program.

In the Book Two, I show you other compact vector

notations instead of matrix component notations of this.

And in your current homework actually, I'm asking you to derive this stuff.

1:17

You will have to use these identities that the sum squared of quaternion

is equal to 1.

because sometimes you get a form and like, well that looks close but not quite right.

But if B1 squared and B2 and B3 and B naught squared all equal to 1.

Wel, l then beta null squared is one minus the other three, right?

And sometimes you can substitute that and manipulate it,

now you're applying these constraints.

So those are the tricks you have to kind of do to get there.

So very easy mapping, no singularities, no issues with these numbers.

Now, how do we get the inverse?

This is going to look very similar in the mathematics here

to how we went from the DCM to the principle rotation parameters.

1:57

To get the angle, we end up taking the trace of the matrix and

there was an inverse cosine somewhere to get all this stuff worked out, but

it was a trace of the matrix that was the key.

Remember beta naught actually only depends on the cosine of Phi over 2.

So also it depends on a principle rotation angle.

So we still use the trace of the matrix.

If you take this term, this term, and this term and add them up, you add 1 to it,

take the square root and then 1 over 2.

You will end up with beta naught.

2:32

And I'm going to let you validate the algebra.

You guys know how to do algebra, but validate for this.

You'll see this pattern as you work through these things with the homework.

But that's it.

So if this by itself gives me, for beta naught squared is trace + 1,

taking the square root I have to get two possible answers, right?

This is what we expect.

If you know there's two possible sets for an attitude and you go from a DCM and

get these coordinants and there's only one set of coordinants, something went wrong.

Somewhere we have to have four possible, sorry, in this case two possible sets, and

this is where it appears.

So either you pick a beta naught that's positive or negative.

So Kyle, right?

No Cody, sorry.

You were Kyle. [LAUGH]

>> Casey.

3:33

Let's be honest, when you're programming what are you going to pick?

Yeah, we're all lazy.

Why add that extra negative sign.

That's an extra keystroke, really.

That's just really pushing it.

Now, so when we're programming we do, hey this is the square root of this,

human nature's going to go [SOUND] just pick the plus version.

Turns out human nature for once is right.

That's actually typically the most convenient

answer because beta naught being positive.

Sorry, what was your name again?

Yes, right there.

>> Lucas. >> Lucas.

Is that a short or the long rotation if beta naught is positive?

That's the short rotation, right?

If I have zero rotation, beta naught is 1.

If I have 180 degrees, the beta naught reduces to 0.

And if I have more than 180 degrees it goes below 0 down to -1.

Like the DCNs though beta naught, betas can never exceed one in value

otherwise you're going to violate the unit norm constraint.

4:22

So good, so people tend to just pick the plus one but if for some reason you needed

the long rotation and there are actually cases where this could be happening.

So it does depend on situations, one of them could be you're doing a maneuver and

you have to avoid the sun, I want to rotate from here to here without my

sensor ever looking straight at you guys.

You guys are just too bright.

You're going to blind the sensor and burn out pixels.

So instead of doing the short way around, we might go,

the short way gets me too close.

If it's a single avoidance cone and the sun exclusion region you can just go,

you know what, for the control just do it all the way around this way and

that's when I'm going to drive back.

It's a simple example where you might choose to do the long rotation.

That's where you control it, right here, with the minus sign.

Once you've picked a minus sign, the rest of the math, if you look here.

And again, this is trivial.

You can see one of them, if I subtract one of these off diagonal elements,

these parts are always symmetric.

And they're just going to cancel.

Leaving you with these other parts, in this case beta threes.

I know beta naught and then I can just divide through it and then I get it.

Now don't flip signs anymore.

You've just get to flip the sign once.

That's for beta naught, everything else is completely determined, and

this will give you all the four betas.

Yes.

>> Is it possible the beta not be zero?

Is it possible for it not to be zero?

>> It is possible for it to be zero.

>> Yes, what orientation would that be?

When is beta not zero?

6:15

So, this formula is very convenient, but do not program this on the flight system,

because otherwise, you're going to introduce singularities just because of

your method of how you pulled quaternions from this system, all right.

And when it is zero could you use the ultimate set?

Well mine is zero, it's still zero.

So short and long doesn't really mean anything when you're at one eighty.

This method just has issues with this, so

there's an ultimate method that I'm about to discuss.

And that's the one I really would recommend the singular of that,

the Shepherd's method.

6:53

Lets talk this through, this is a slightly modified version of that.

The first one I showed you is easy to see,

because you can just look at the patterns and it's almost like the PRV stuff.

You can see trace, you can see delph diagonal differences and

quickly you find the formulas but

we there, the fundamentally what we did is we found beta naught first and

then we find the other three by dividing by the one we found first.

And the one we found could go to zero.

That's a very real thing especially if you're in a tumbling situation.

So is there a better way a more robust way to extract these coordinants?

So this is Shepherds method, and instead of just finding beta naught squared

first and then doing the square root and deciding + -, we actually found

beta naught squares beta 1 squared, beta 2 squared and beta 3 squared.

And so looking at these formulas I will let you look at this yourself.

This is the trace, this is what we had earlier in the slide.

But using the trace and

these other elements, you can quickly just double check the algebra,

got yup, these formulas do give you beta one squared, beta two, beta three squared.

So we can compute all of these.

So could we just stop here take the square root of each one of those, and I'm done.

Matt, what do you think?

8:10

The answer is obviously no, otherwise I wouldn't continue with this stuff, right?

But the real question is why, why don't I just stop here?

>> [INAUDIBLE] >> Exactly, that's it.

because there's two sets we said.

And one's just a minus of the other.

However, you have to be consistent.

You don't just change the sign on one of the betas.

If you're changing the sign, it has to be on all four simultaneously.

Otherwise, you're not looking at two points that are anti-points

along this unit sphere.

But you've just flipped one to the other quadrant, and

that's a whole different orientation.

So with this formula,

we do know the magnitude squared of every beta, I just don't know the right sign.

So this is why we can't stop here.

It puts you on the wrong quadrant on this

four dimensional space that we're dealing with.

So we have to go further.

So before we just had three formulas taking differences

of the off diagonal terms and that's how we found beta one,two,three.

Here,this is a slightly modified version,you can see three differences

and three additions of diagonals,so you end up with six possible equations.

10:20

What must it's, if I have B naught, B1, B2 and B3, what equation must they satisfy?

[INAUDIBLE] >> Exactly, right?

They have to reside on this unit surface.

It's just a hyper surface because it's in four dimensional space.

But they have to reside on the surface.

There's no way you can go from, if you think of the Earth's globe,

let's pretend it's a three dimensional surface, right?

We have to move on the surface of the Earth, I wouldn't all

of a sudden have a position that just tricks me to the center of the Earth.

That would give me 0-0-0 coordinates.

I cannot have 0-0-0-0,

four zero's here because I have to reside by the units sphere.

That would violate the unit [corturnium?] condition.

So by definition, it's not possible that all four of them are zero.

12:00

>> So, right now, we know we're going to have to divide by whichever one we pick.

So, I'm picking, the first step is pick the largest square of a quaternian and

then I'm going to have to here, if I pick beta 2,

I'm going to divide by beta 2 here.

So I have to find out what is beta 2?

Not beta 2 squared.

I take the square root of this term and

square roots have two possible answers, plus and minus.

Do you pick plus or do you pick minus?

13:07

that would give you a minus beta 2, but you're still doing a short rotation.

It's the quaternion that responds to the scalar part, which is, here, beta not.

That was always [INAUDIBLE] So here, if we want the short one,

we would pick the positive one.

Yes, Casey?

>> [INAUDIBLE] >> No, not really.

The reason I picked the positive one is because I just don't know and

the lack of knowledge.

So, in this case these I don't know if I pick a positive or negative,

I'm not going to be guaranteed a short or long.

Without looking at this one as a result of that choice I can't make

that determination.

So for this modified one don't spend a lot of time

dreading over positive and negative.

Just encoding people to pick the positive one, right it's a valid description.

And we're not going to finish this method and at the end I can look at my beta and

not the scale one and see if I picked the long or short, if it is long, I flip them.

To give back the short rotation.

At this stage you don't have enough information to really determine that.

So I'm glad you guys made that distinction.

Don't pick beta 1, 2 and 3 to do long or short.

You can't pull that information from there.

So let's say beta 2 was the largest.

You do the math, do the square root.

And pick the positive one.

Just Because I don't know, so I'll make it easy, pick the positive one.

Here, you have to pick the three equations that have beta two,

which is this one, this one, and this one.

So, you divide this right hand side by beta two to get beta naught, all right.

You divide this equation by beta two and you end up with beta one.

And you divide this equation by beta two and you get beta three.

So in your code you end up with these if statements.

If this is the largest then I use these three,

if this is the largest I use this, this and this.

If beta one is the largest I would use this one and these two, and so forth.

Right.

Yes.

>> Do we pick the largest for numerical reasons?

>> Yes. >> Okay.

>> Yeah, because you have finite degree.

And especially if you're dealing with old five computers that only had

eight bits and other stuff, then you can start to really make a difference.

With 16 bits if you picked 0.4 or 0.6, it doesn't make much difference.

So just again people just go with the biggest.

Which one of those is the biggest?

I found the good big one, off I go.

That's it.

So, this is the step.

So, instead of just having one set of the trace, and

then taking three of these formulas, we end up kind of, the first step is find

the biggest quaternion squared, take the square root, just keep it positive.

Use the right three formulas to get the other three and now as a final step we can

check that we have the short rotation, if you want that.

If you don't care, the you either quarternion is correct.

That makes sense?

So this is Shepard's Method, this is typically what we use.

And that's whats coded up typically because now you're completely singularity

free, but it takes some logic thinking there to see get good conditioning,

and pick the right numbers and the right formulas to extract it.

These quaternions always exist.