Tip:
Highlight text to annotate it
X
>> Hello, and welcome to glue lecture four.
The title of this module or lecture, is called Matrices and System Properties.
In today's glue lecture, I'm just going to kind of go through one extended example.
And I've broken it up into different sections, so that if you have questions
about it. You can kind of reference which example
you're talking about. But it kind of all connects together
today. And I'm going to kind of jump right into
the example. So that we have time to really do some of
the computations that you're going to need to do on quiz 4.
So, example 1. Let's imagine that we have a robot here.
And. We can think of our state as being the
angles, this theta 1 and theta 2, and their velocities, I've shown over here.
And now we can imagine this is the A matrix we're given, and From last week,
you might remember. Or, or you can kind of compute with s-,
with, with MatLab or another tool. But the eigenvalues of this matrix are all
zero. And so, the dynamics, x dot equals ax are
not going to be stable. So let's, let's introduce some control.
Right? So that we can try and overcome this
instability. And this is going to get us into this
concept of controllability that you talked about, during lectures this week.
So we can pick this control to be the acceleration of theta 1.
And that gives us this v matrix. Such that we have.
This X dot equals A X plus B U to be satisfied because remember that X dot is
going to be beta one dot, beta two one double dot, beta two dot and beta two
double dot. So we have this B matrix and so now we
want to check is the pair of A and B controllable.
So to do that we need to compute this matrix gamma.
And so for a 4 by 4 system, our matrix gamma is going to look like this.
So we need to, we have B and we need to compute and, and B.
So computing A and B is just a matter of multiplication.
Right? We take this long skinny column and
multiply it by this first row in A. And that gives us 1.
Then we multiply it by the second row in A and that gives us 0 and the next also
going to give us 0, and the last which all zeros also going to give us 0.
And now we need to worry about this A squared term.
So if we compute A squared, this is actually going to simplify a lot of our
work, because we have, let's see I'll write it out.
Here let me, compute a squared here. I'm just rewriting a twice.
So that you can kind of visualize. So there's a lot of zeros here.
So you should start to see that Maybe computing a squared isn't going to be such
a big deal, right? We have this row is all 0s, so everything
in the first, as I, take this row and multiply it by each of the, this column,
and multiply it by each of these rows, I'm going to get 0s.
This, the same with this, right? Because these 1s are never going to line
up when I multiply, so actually this whole matrix, and work it out for yourself, so
that you. Believe me, is zeroes.
So that means that this and this term are all zeroes.
So really computing b and ab is all we needed to do.
And so we can see that. So this is our b matrix, this is ab, and
now this is a squared, which determines this term and this term being all zeroes.
So now our gamma matrix Looks like this. And actually, we're going to have, write
rows and rows of zeros here at the end. But we can see that all we really need to
think about are these first two columns. And we can see now that the rank of this
matrix is not 4. In fact, it's less than 4, it's 2.
And, and if you're not familiar with computing rank.
Do, do, find some resources to do that. But it's basically just a matter of the
fact that these columns are linearly independent.
But, or, in fact, these 2 rows are linearly independent.
But these. 2 aren't.
And so it's just a matter of checking that we have 4 linearly independent rows.
So this, can also be achieved in MatLab, right?
I can put a and b into MatLab. And then I can compute gamma.
So this is the same as where we computed gamma.
Using this controllable function. And then I can find the rank of that
matrix using the rank function. But if you don't have MATLAB, you can also
compute ranks of matrices online. So for example, this WolframAlpha.com has
if you kind of use this notation, you compute the rank of your matrix that way
as well. But now let's, let's take another example
and see if we can find a pair of A and B matrices that makes our system
controllable. So now if instead of just theta1, we pick
theta, the acceleration of theta1, we pick the acceleration of theta1 and 2.
We'll get a B matrix that looks like this. It's a little bigger.
And maybe this system, now, will be controllable.
And again it's a matter of computing gamma.
And I can do that in MatLab and can I find that.
So this is our gamma, right, and I can find that now the rank of my matrix is 4.
So by adding this extra control input, buying a bigger B matrix if you like,
we've made our system completely controllable.
So I hope this example kind of demonstrates how the structures of A and
B, what entries are in A and B affect our system properties.
This is kind of the power of linear system theory is that by piling all of the
information about our system into A and B we can kind of take these nice quick
matrix tests to figure out is it controllable, and in our next example, is
it observable. Let's take this matrix to be our C matrix.
And I'm picking my output to be theta 1 and theta 2.
And a little bit analagous to how when our input was only theta 1 double dot, we
didn't have a controllable system, if we only had data 1 here, we wouldn't have an
observable system and work through that example to convince yourself of it.
But because there's no coupling in our dynamics.
Between theta 1 and theta 2. We need them both.
We need to have control over both of them. We need to be able to see both of them.
So this kind of makes sense as a choice for theta.
And, of course, in the example of the robot.
You know? It's not hard to imagine that we would be
able to recover theta 1 and theta 2. But, Just to kind of show you, how these
matrices are really affecting our system properties.
So let's assume that this C matrix, because we have, right, y equals cx, so
this is just a matter of figuring out where we need these 1s.
To make y theta1 and theta2. And now we can.
Try to figure out if this system is, this pair matrix A and C, if they're
observable. And that's done through computing this
observability matrix. Sometimes it's called omega.
Or sometimes it's called o m I'm not sure what Dr.
Eggerset/g called it in lecture. But, here we have That we need to compute
these four terms. And again from the previous example, we
remember that this is 0, right? This is a matrix of 0s, and so this is
going to be a matrix of 0s. And so it's really just a matter of
computing CA. Alright?
So, CA, this is just. Kind of have to be patient with this, but
this is a big example, and. You won't be quizzed on a 4 by 4 example.
But writing out the matrix is always a good way to make sure you get the right
answer. So now, we can take this column.
Multiply it by this row. We're going to get all zeroes, right.
So that entry is going to be a zero. And now we're going to get all zeroes
again. So that entry's going to be a zero.
This next column, we're going to get 1 times 1 plus 0, 0, 0.
So we're going to get a 1. This next one is going to be zero.
The next two will be 0 cause this column is all 0.
And then we'll get a 0 and a 1 out of this last piece since this guy looks like this
guy and these 1s will match up. And so now we have CA, we remember that A
squared is 0 so we can put together CA this first.
2 rows being c. And these next 2 rows being ca.
And then we remember that we have zeroes for the rest of the matrix.
And so now, we can see that we do have 4 linearly independent rows.
Or 4 linearly independent columns. This, either one of those can tell you the
rank of the matrix. And so we see that we do have full rank.
Our rank is 4, which is the size. So if A is 4 by 4 we need the rank of this
guy to be 4. And so we can find A and C are observable.
As we kind of expected, right. So now let's, let's think about so now we
know that this system is completely controllable.
Let's actually do an example of this using pole placement to stabilize our system and
I'm actually, instead of putting you through the pain of another four by four
example, let's take a smaller example. So I'm just considering a Just teta 1 in
this, in this case and now my input is teta 1 and double dot my output is teta1
and we can think about our system just in this shoulder, angle has the same problem
right the eigen value is of a or 0. 2, 2 eigenvalues then 0.
So, we need to use this control to stabilize our system.
And, try it out. Check and see that this is a completely
controllable, and observable system. But as far as poll placement goes, we're
choosing our input to be, or to be negative k x.
So, this is called full state feedback. So we write that, now our x dot, since
we're filling in u equals to negative kx, we get this.
Our dynamics kind of simplify into this, A minus bk times x.
So here we have A. We have B, and we have this matrix k which
is, is going to have 2 gains since our state is 2 dimensional.
And so now we can figure out that, okay, this is, you know, just to the subtraction
we can, we find that this matrix turns into negative k1 and negative k2 on the
bottom, or positive k1 and positive k2, so when I subtract it, I get these negative
signs. And so now we have these dynamics.
We need to figure out this characteristic equation.
Right? So if here's our x dot.
Now we need to find the determinant of this bad boy right here, which simplifies
to this matrix. So finding the determinant of this guy is
quite easy. We just multiply these 2 entries.
And subtract the multiplication of these 2 entries.
So we get negative lambda times negative k2 minus lambda.
Minus negative k1. And so that's going to simplify to.
Lambda squared plus k 2 lambda plus k 1, right.
And so now we need to pick what eigenvalues we want this closed loop
system to have. We can pick anything here.
I'm just going to pick negative 1 and negative 2.
So this is going to give me This characteristic equation, right.
I want the poles to be at negative 1 and negative 2 so I multiply this out and get
that this is the coefficient the characteristic equation I want.
Well I have this k1 and k2 so I can match these, right.
So I can consider, okay, lambda square doesn't give us much, right.
We just have that 1 equals 1. But this first pow, power, lambda to the
power 1, we need, we see that we need 3, to equal k 2.
So k 2 equals 3, and the same for the lambda to the 0 power, where we have just
a 2 on this one, and k 1 here. So we can pick k 1, equal to 2.
And so this gives us this stabilizing system because now write a control, now
our controller is u equal to negative am, 2, 3 times x and we know that when we plug
this guy. And up here, we're going to get a system
dynamics that are stable. 'Because we've moved the polls over to
that left half plane. So again, it's just a matter of matching
the coefficients for the desired characteristic equation.
So now, I want to take just a quick. Look at how me might think about
implementing this in code. You're going to have a similar example to
this on the quiz and so we want you to kind of think about or to kind of
understand what we mean by the quiz question but also to think about you know
I think some of you have asked some questions in the forms about where's the
code,where's the controller. Where's the, whats physical and whats And
whats in computer somewhere. Ok, so example four.
So lets imagine that we have kind of this system we just finished up with and lets
say we pick some dt or its given in the problem, and then we know our system
matrix is a,b and c and our gains K. And in this case, let's just assume that C
is some identity matrix and so we know that x is exactly equal to our output Y.
So in this case, all we need to think about in each iteration doing is reading
in our output value Y, which we know to be our state X.
And then, computing our control u. Which, which is this negative kx term,
right? So we have our game stored in some matrix
somewhere. And we can compute u by multiplying it
times our current state. And now we can send this control value, u.
Out into our actuators, right? So that our actuators do, implement this
control signal, in real life. But, what if we don't have full state
output, and we don't have this simplification of x equal to y?
In that case, you're going to have to use some kind of observer, to recreate.
And figure out what, x is from y. And then your going to have to simulate
the state in code, right? So you can compute that x is equal to x
times this dt our sample step times our x dot.
And in this case, right, in the last example at least, our x dot was just Ax
plus Bu. So knowing A and B, you can compute kind
of this estimate at each time step of what X should be, as long as you can recover
from our output. So hope that hint kind of helps you on
what you need to do for the quiz question where you really need to remember that in
order to kind of simultae this in code. We use this, this is called Euler's
approximation, which you probably saw in lecture as well.
And so this is kind of where Euler's approximation is going to fit into this
loop that needs to happen at each iteration.
So with that check the forums for more help and good luck, with quiz 4.