Leslie Kaelbling: 6.01 Lecture 04
PROFESSOR KAELBLING: OK, as people are coming in, we'll start by talking about the first exam. Oh, that gets people's attention. OK, so the first exam is going to be a week from tomorrow, 7:30 to 9:30 PM.
I've just made a room assignment here on paper, I'll send an email out to everybody. Please be sure that you join Piazza because that's what I use to send the email out to people. So just join that so that you get the email.
The exam will cover everything up to and including the design lab from this week, unlike previous terms. So don't listen to the people on your hall who tell you that the labs are not relevant to the exams because we're doing things differently this term. Last term and in many previous terms, we did oral interviews to test your understanding of the design labs. This term, we're going to experiment with putting questions on the exam that are directly about the design labs.
So you should study. You should be sure you understand what the design labs were about and why. You would probably do well to bring your design lab handouts and graphs and stuff with you to the exam. So that's going to be a departure from previous terms. Yep?
STUDENT: Where is this exam?
PROFESSOR KAELBLING: Where is the exam? So it's happening in three different room. As I said, I just worked out on my piece of paper which people need to go to which rooms. I'll post an announcement that says exactly where. We are too big to fit every other chair in any room on campus.
Let's see, so next week there will be a lecture on Monday. There will be no software lab on Monday or Tuesday. That's the thing that we're canceling in favor of the exam. There will be the exam on Tuesday evening.
If you can't attend the exam on Tuesday evening, there will be a makeup session on Wednesday morning at 8:00. You need to email me if you want to take the makeup exam. Does anybody have questions about the exam?
We will also post, probably tonight-- OK, good, I see your hand. We'll post some practice material also, so some former exams that you can look at. OK, now I saw a maroon arm, but I lost it.
STUDENT: Will we be coding on paper or is it more of a concepts exam?
PROFESSOR KAELBLING: There will be some coding problems and it will be on paper, but we will be very forgiving about detailed syntax errors, and indentations, and stuff like that. So if we ask you coding problems, it's going to be do you exhibit an understanding of what you're supposed to do and we won't kill you if you forget the occasional parenthesis or colon or something. Yeah. Other questions? Right, it will be on paper, not a [INAUDIBLE] thing.
OK, good, then we'll send out several more reminders. There will also be some review sessions this coming weekend on Saturday and Sunday, so if you want to go and get sort of brushed up on some concepts.
So what I wanted to do today was, think about last time, we talked about how systems responded to the unit sample signal. So what we're going to do is start out by thinking about how they respond to somewhat more complicated signals. And then we're going to think about how, if you're going to try to design a system, like get the robot to behave well in some circumstances, we understand now that there's usually some free parameters in our system, like maybe a gain in the controller, or maybe more than one gain eventually. And we're going to think about how it is that changing those values of gains can change the placement of the poles and therefore change how the system behaves.
OK, so just a reminder from last time. We remember that you can always take an LTI system and make an additive decomposition of it. So you can always think of the system as the sum of a bunch of systems each of which is describable as an individual mode, maybe plus some terms that have to do with just straight feed forward of the signal.
And we also recall that the response, the unit sample response, to a particular mode, so kind of one of these terms that gets added in, is a constant times an increasing exponentiation of the underlying pole. So if the pole, in polar representation, is R omega, then the response goes like this. So we have 1, we have re to the j omega delayed by 1, r squared e to the j 2 omega delayed by 2, and so on.
So we remember that the magnitude goes up exponentially as we go farther out in the sequence and that the angle of the response steps around, if it's complex. The dominant pole is the pole with the largest magnitude and the dominant pole is the thing that's going to govern the long-term behavior. All of those other poles might have something to do with what's going on in the beginning, but eventually, because of the way that exponentials work, eventually the one with the biggest pole will take over. The thing with the biggest magnitude pole, it will govern how the system works in the long term. So that's a bit of recap.
And what we talked about last time also was how the particular properties of the dominant pole affect the long-term behavior of the system. And there are sort of two sets of questions we could ask. One is, is it going to converge? And the other one is, how is it going to behave on its way to wherever it's going?
So whether it's going to converge, remember, depends on the magnitude of the dominant pole. If the magnitude of the dominant pole is less than 1, it'll converge. If it's equal to 1, the unit sample response will be constant, eventually. And if the magnitude of the dominant pole is greater than 1, then it will diverge. So this is for the unit sample response.
Now there's the still the question again of what is it going to do while it's converging or diverging. What is it going to look like? And for that, we need to look at, actually, oh, I'm sorry, I didn't write it on this slide again. Assuming that the p star is in the form a plus bj, so it's got a real and an imaginary component, then we can look at those two components, and those will tell us something about how the thing's going to behave.
So if B is 0, so if it's purely real, and the a is positive, then you can think of that as having a period of 2 pi or of 0, but you can think of it as going all the way around back to the real axis every time, if you want to think of it that way. And the signal, eventually there's going to be this point where it happens that either it's going to increase monotonically or decrease monotonically. Whether it increases or decreases is going to depend on the multiplier of that mode in the overall behavior. So if a is positive and b is zero, it's going to go monotonically.
If a is negative and b is 0, then it will alternate signs. And again, you can think of that as being periodic if you want to, periodic with a period of pi. It's as if we have a response over here on the positive real axis, and then a response on the negative real axis, and a response on the positive, response on the negative, so it goes back and forth like this.
And finally, if b is not 0, our hole is somewhere here, we have omega is the angle. This is a, this is b, and if b is not 0, then the signal will oscillate. And it will oscillate with a period which is 2 pi divided by omega. So the period is 2 pi divided by omega, and that's just how many times, how many steps it takes this thing to march around 2 pi. So that's going to be the period.
What are the units of the period? When we say the period is 2 pi over omega, what are the units? OK, so I heard mumble mumble seconds and I heard mumble mumble time steps. OK, it's mumble mumble time steps.
So we're making this discrete time model of how the system evolves. And when we talk about raising the pole to these powers, we are thinking about each time step we raise it to a higher power. So when we talk about the period, it's in units of time steps.
Now when you wrote out the dynamics, you were thinking about there's a t in there, which is how much actual time we have per time step. And you could use that to figure out the period in terms of time. But when we do the 2 pi over omega, it's in terms of steps in our model.
OK, so that's all a bit of reminder. So now I'd like you guys to do this problem. So I have a look at that, think about it. Which of the following things are true if you knew that that was the output of a system with some particular poles? What could you infer about those poles?
You can talk to your neighbor if you want to. And actually, I'm going to make it into a bunch of true false questions.
OK, so let's answer the first question here. Is b equal to 0? If the dominant pole has this form, is be equal to 0? How many people think b is equal to 0? Very good, almost nobody, some tentative people, but no. OK, good, b is not 0, we know b is not 0 because it's oscillating. So that means that there's some imaginary component. So B is not equal 0. So is B equals to 0? No.
OK, r, so do we think that r is somewhere between 0.5 and 1? How many people think so? Good, lots of people think so. Why?
Let's see, how do we know it's not bigger than 1? Because it's converging. OK, good, so that's how we know it's not bigger than 1. Why do we think it's not less than 0.5?
Good, if it were less than 05, it would be shrinking away very quickly. If it were less than 0.5, we would be able to draw an envelope that goes down like an exponential with base 0.5, and the thing would have to be oscillating within that envelope. You can kind of see that it's actually not dying out that quickly. So it's not less than 0.5.
OK, now what about omega? So first of all, what is the period of the signal, roughly? How can you find that?
STUDENT: Count.
PROFESSOR KAELBLING: Count. You could count from peak to peak, that's basically the period. So I've got like 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, sort of like 12. OK, so if the period is 12 and 2 pi is about 6 radians, then omega is about 0.5. OK, do you feel good about that?
There will, with very high probability, be a problem that's very much related to this one on the exam. So this is the thing you should be able to understand how to do. We're not going to ask you to calculate exactly the angle from something like this. But you ought to be able to get the qualitative idea of what the angle is, for instance, or the r.
So now, let's talk about what happens when the input signal is something more complicated than the unit sample signal. Because the unit sample, that's kind of a pretty lame little input signal if you think about it. It just has the one blip at 0 and then nothing else. So all this conversation so far in detail has been about the response to the unit sample signal. So what happens if we have a more complicated input?
So if we have a more complicated input, the beauty of LTI systems actually saves us from having to do very much work. So this is an excellent thing. And it's really yet another example of compositionality.
So the important thing to notice is this property here. So if you have my Y is H of X, so that's what we're interested in, how does my system H respond to some input signal X? But in fact, if X is the sum of two signals, and I'm going to actually go beyond this just a little bit more. Imagine that X is actually the sum and scaling of two signals so that it's H of C1 X1 plus C2 X2. We know about that, this makes sense to everybody from the signals lab, right?
I give you two signals, you can scale them and add them up. That's an operation we understand very well, that gives us another signal. So that could be, our X could be this.
And again, because of things that you really already understand about operator algebra and system functions, if we wrote out the system function for H, we would now feel free to do algebra with it in the way that we've been doing algebra with things before. And if we just worked it through, we would find out that this is C1 H X1 plus C2 H X2.
So if you want to know what this system H does to a complicated signal, you can figure out what H does to your particular individual input signals, and then just scale them and add them up. That's a good thing.
So that means that if our input signal is transient, at least in the easy case for now. A transient input signal, we talked about this before, is something that only has finitely many nonzero samples. So if you have a signal with only finitely many nonzero samples, you can always just describe it as the sum of a bunch of scaled delayed unit samples.
We also studied that. And you guys looked at poly R. So in poly R, what we did is we said, all right, I'm going to describe some signal with some peaks in it, maybe there's one here, and one over here, and those guys are 0, and there's something down here, and those are 0. You could take an signal with a finite number of nonzero samples and just describe it with a polynomial in R saying what kind of transmission we're going to do to the unit sample signal in order to get that.
OK, so just to cement this, let's do it. So imagine that this is 0. And so I want to take the unit sample signal. So this is my signal S, and I'd like to describe that using a polynomial in R operating on the unit sample signal. So how would I do that?
Let's see, how do I account for that spike? Let's imagine that this goes down to minus 1, and then minus 2, and plus 3. And this is step 0, 1, 2, 3, 4, 5, and 6. OK, so what is the polynomial in R that describes that signal, that transmission of the unit sample signal? What's the first term in it that's interesting?
Negative R squared, good. What's the next term? 3R cubed. And the next one? Minus 2R to the 6, good. So my signal S there is equal to this times the unit sample signal. Does that makes sense to everybody? Are you good with that? OK, good.
So we can just then understand the output as a bunch of piled up responses to the unit sample signal. And so that just means that, in fact, again, the long-term qualitative behavior is going to be the same as the long-term qualitative behavior of the system in response to the unit sample signal.
Because if we're going to add up a bunch of things that oscillate, it's going to oscillate. If we add up a bunch of things that are going to grow to infinity, it's going to grow to infinity. If we add up a bunch of things that are going to converge nicely to some value, it's going to converge nicely to some value.
So nothing really new and surprising happens when we make the maneuver in going between the unit sample signal and a transient input to a system.
Next thing, which is actually the case we've been doing in the labs without really talking too much about it out loud, is step response. So the step signal, again, as you know, so the step signal looks like this, 0. So at all previous time steps, it's 0, at 0, it's 0, at 1, it's 1, at 2, it's 1, at 3, it's 1, and this goes on forever. So that's a step signal.
So now you might think, well, stuff is really different here when I put in the step signal, maybe then when I put in the unit sample signal. Because the step signal doesn't just die away to 0 like the unit sample or like a transient signal, right? It's always got a nonzero value after a certain point. So things are going to be different.
So what are some ways of thinking about what happens with a step signal? So one way to think about it, which is kind of cool is to, first of all, think about how you might manufacture a step signal. So if you take the unit sample signal and just stuff it into a simple feedback like this, just threw in R, with no gain, so just feed in the unit sample signal here, what we get out is the step signal. Because we're adding up all the inputs, this little contraption here adds up all the inputs its ever gotten. The unit sample signal only ever gives an input of 1 and then it just stays there. It's like you put $1.00 in your bank account and then forget you ever had, so it stays at 1.
And then that input goes into the system R system. So if we have a system, describe a system function H, we could take the unit sample signal, run it through this thing, and then put it through H, and that's like just taking the step signal and using that as the input to H. So this tells us that, in some sense, the step signal isn't anything too surprising. The step response of H to something is just the unit sample response of this whole thing.
Another interesting thing to see, because if these systems are at rest they commute, that the step response, so the response of system H to a step signal, is the same as the accumulated sum of the responses of H to the unit sample signal. So we can put them accumulator on either side, it's OK. So that's one way to think about what's going on with a step signal.
Another way is to think about it algebraically. So another way to think about it is if you say, well, all right-- Oh, I goofed here. I changed horses in midstream, which is always a bad idea. So we were back here using U. I think this is standard notation, but I find it extraordinarily confusing, which is why I tried to change it and failed. Anyway, U here is standing for the step signal, not the unit sample signal. U is standing for the step signal.
So anyway, U here is standing for the step signal. I started to try to change it to S, but I obviously didn't complete the job. So just make a correction in your notes. Let these S's be U's and we'll be OK, where U stands for step. That's a mnemonic thing. Maybe in some language U stands for step, up. OK, good.
So anyway, you can also think of the step signal as being an infinite sum. If you think of a poly R, what poly R could we do to the unit sample signal in order to get to the step signal? Well, it's an infinite sum because now there's infinitely many nonzero outputs.
And so I could say, well, I get a copy of the step signal, and then I delay the unit sample signal, and then I delay it by 1 and add it in, and I delay it by 2 and add it in, and I delay it by 3 and it in, and so on. So you could think of the step signal as an infinite sum of these unit sample signals.
And then we can do our same sort of algebraic tricks that we already know how to do and say, well, OK, what happens if we apply system H to the step signal? So I can think of that as H composed with this poly R on the unit sample signal and then I can push the H through, again using our standard algebraic methods.
And so, if we now think about this, let's define Z. Let's have a new variable, which is H applied to the unit sample signal. So we're going to now think about, well, what is it that happens if we just put the unit sample signal through our system? Because we've been studying that a lot, we think we know what happens.
Then if we let Z be that thing, applying H to the unit sample signal, and we want to know, well, what's the output of our whole system? This is what we get by putting the step signal through H. Then the output at time n of the whole system is actually the sum up to time n of the unit sample responses.
So where it used to be for the unit sample response at time n, imagine now it's just a first order system with one pole, just to kind of get an intuition. It's a first order system with one pole, for the unit sample system, the response is just the signal, the response is just p to the k, or p to the n. If it's a step signal we put in as input, then the response at time n is the sum of p to the k from 0 to n. So we sum all the way up to n. So it's not just p to the n, it's the sum of all the terms up to p to the n.
But it turns out that, again, because of the exponential and the way that the exponential kind of takes things over, that roughly the convergence properties are the same. I say roughly because something different happens that 1. But if we have a system where the dominant pole is, let's actually look at the nice case first, the magnitude of the dominant pole is less than 1, then even the step response will converge. And we'll call the system stable.
If the magnitude of the dominant pole is greater than or equal to 1, then the step response will grow unboundedly. Because even if it's equal to 1, we're going to be adding in a new constant response for every time step and so it's going to grow. It might not grow as fast, but it's going to grow. So if the magnitude of the dominant pole is greater than or equal to 1, we're going to say that the system is unstable, it's going to grow, the response is going to grow unboundedly. If the magnitude of the dominant pole is less than 1, that should be a p star, then the output value will converge.
And this is actually not only true for step signals, but also true for signals where we have a bound in advance on the magnitude of the values in the signal. So if the values in the signal can't get too big, then the output will also remain stable, that is to n, and bounded, and we can promise that it won't get bigger than some certain value.
OK, so that's sort of what I wanted to say to you about how systems respond to different kinds of inputs. Do people have questions about that?
So then the last piece of this is to think about now that we know some analysis, we know how if somebody gives us a control system, and a plant, and so on, we can write down equations to model it. We understand how to combine them to get a system function. We know how to look at that system function in order to see what its poles are. And now we know how, by looking at the poles, we can predict the long-term behavior of the system in response to certain different kinds of inputs. OK, so that's a good.
So now the remaining thing is to be engineers. So what we typically do is not analysis but synthesis. I want to make a good controller for my robot.
So if I want to think about making a good controller for my robot, first of all, I have to think about what properties I want it to have. And then I have to think about how it is that I can arrange it so that this thing that I'm making will have those properties that I want. So that's what we're going to think about next, in that context of LTI systems.
So what we've seen is that when we are designing a system, even so far in the things that we've looked at, we have been able, for instance, to pick K. So that's been a free variable in our controller, so we can pick the K value any way we want to.
But we also have some more choices, which we haven't really given you in the designs that we've done so far. But you could imagine that if you're going to Radio Shack to buy a sensor, maybe you could spend more money to get one that reacts quickly. And you might want to ask the question, well, if I have a sensor that reacts more quickly, will that improve my control system or not? Should I spend my money buying a faster sensor? Maybe it doesn't matter.
Or it might be that you could buy a faster computer. If we had a faster computer, maybe instead of running our control loop 10 times a second, we could run it 100 times, or 1,000 times, or 100,000 times a second. And would that be worth the trouble?
So these are all things that we can think about when we're designing the overall system. So what we have to do is figure out how those kinds of things can affect the behavior.
So in Wall Finder, remember that's our name for the robot that's going up, trying to stop a fixed distance from the wall, we saw that picking different values for K gave us quite different kinds of behavior. And it's pretty clear that we don't want this behavior. And maybe we don't even want this one. What's a reason that you might not like that one?
It might crash into something, and it goes past where it's supposed to go, and maybe there's reasons why that's not a good idea. In some applications, maybe you don't care if it overshoots a little bit, in some other applications, you might really, really, really not want to have it overshoot. So those are the kinds of things that you want to think about in advance. What kind of behavior would you like to have happen?
There's also if we set K to be really small, and some of you tried this out, then we get this extraordinarily lazy robot. It just kind of makes its way up to the wall. Now it's not going to overshoot, or oscillate, or do anything too crazy, but it just kind of, eh, goes up there. And so maybe that's not what we want either.
So generally speaking, a criterion that we would often like to aim for is having it sort of converge as quickly as possible, but not oscillate or overshoot. So that could be a thing that we want. OK, so how can we pick, for instance, K to get the behavior that we want?
What we're going to do is look at two different versions of the Wall Finder system. So this one is different than the one that we looked at when we started out. But let's just kind of go through it quickly.
So we're going to have a proportional controller, that's what we did before, so that the velocity of the robot is K times the error, where the error is the desired distance minus this sense distance. So that's what we had before.
Locomotion, sort of the model of the plant is the same. That is to say, a positive velocity decreases the distance to the wall. And we multiply it by T, the time. So the length of the time step factors in here. If we changed how often our controller ran, we would change the value of T. And we'll see that that would change the behavior of the system also.
And for right now, let's assume that the sensor doesn't have any delay, so that the sense signal is exactly the same as the output signal. So that's a difference from the one that we did in lab two weeks ago.
OK, good, so we have these difference equations, we can turn them into operator equations, we can combine them and then get a description of the whole system. And looking at that, you say, huh, OK, good, there's a difference equation that seems to describe my system, but it doesn't really give you much insight into how t or K affects what's going on.
So what we can do, and you should all be now well-practiced at this, sometimes looking at it as a block diagram helps you understand what's going on in the system. We can gradually model different pieces of the block diagram with system functions. So we can say, well, this little piece of feedback here is a system function that looks like this. We can come up with a system function that describes the whole system, and that's this.
So here's a system function that describes the whole system. You guys know how to do that. OK, good, so now we have a system function that describes the whole system. Does that help us pick K? Well, hmm, maybe not yet, but we're getting closer.
Because what we can see now is that the poles, well, pole in this case, we know there's only one pole because the denominator just has one R in it. So it's a first order system, it's got one pole. And that pole depends on KT. So let's think about how that goes. So the pole depends on KT.
We can redraw our system, even though it looked like this when we started. This, again, assuming that things start at rest, this is an equivalent way to draw that system. And what we see is that the pole here, this p0, is the thing that's going to govern the way the system behaves in the long term.
And that pole, the p0, if we look at the form of this, it's 1 minus p0 R, when we're looking for a mode, when we're trying to find a pole, it's always 1 minus pole R, maybe there are several of those multiplied together. So in this case, the p0, the first pole, is 1 plus KT. So p0 is 1 plus KT.
And so that quantity, 1 plus KT, is the thing that's going to govern how the system behaves. That's going to pick whether it oscillates or not, it's going to pick whether it converges or not. So 1 plus KT is where all the action is. So if you pick KT to be minus 0.2, here's the unit sample response of the whole system.
So we are interested in the step response. Remember, the input signal that you think of giving the robot when we turn it on, you can imagine the robot has just been sitting there lazily, and the input signal has been 0, and we haven't been asking you to do anything, and then, wham, we say, please go here. And then we hold that constant. We see d, desired, is some thing, and we keep that d, desired, constant while the robot is running. So that's like having a step signal as the input.
So what we saw when we talked about the step signal before was that the response to the step signal is really just the sum of the accumulated responses to the unit sample signal. And what ends up meaning is that if the response to the unit sample signal is slow, if it's taking a long time to decay-- This is taking a long time to decay. Each one of these is a substantial percentage of the one before. So that means that the magnitude of the pole here is kind of pretty big. It looks like, I don't know, 0.8 or something.
Similarly, so if the unit sample response goes slowly, then the step response is also going to go slowly. So we would like to find systems where we want our robot to be like perky, and on the job, and doing what we tell it to do. We would like to find poles that are such that the unit sample response is quick.
So if we set KT to minus 0.8, that makes the pole 0.2. Because remember, the pole is 1 minus KT. So the pole is 0.2.
Now we see that the unit sample response goes very quickly. A pole of 0.2 means that this point is 0.2 of the previous one. So multiplying by 0.2 successively dies out very quickly. And that means that the step response goes very quickly to where it's trying to go. So that seems like better.
So the important point here is that the poles of the system function can help us pick KT. We can see how different choices of KT generate different kinds of poles. And we know how the poles affect the behavior.
If the pole is positive and magnitude less than 1, then it's going to be converging monotonically. This is just a recap, yet again, yet another recap. If the pole is negative, but magnitude less than 1, then it will converge, but oscillate. If the pole is out here or out here, it's going to diverge. Excuse me, I said oscillate, what it meant was alternate sign. That's a kind of oscillation, just a two-step one.
OK, so what would we like the value of the pole to be? That's a question. So it's clear that we can pick KT so that we get a variety of different kinds of poles. And the question is, well, what pole would we like to have? What pole would give us the best behavior of our system?
So here's the question. If we want the unit sample response to converge as fast as possible, first think about what you would like the value of the pole to be, and then what KT would give us that value. You can talk to your neighbor. We'll talk about it when we're done. Be sure to ask questions if it doesn't make sense.
OK, put up the number of fingers corresponding to your answer. And it it's 0, you can do this. OK, good, I see 4, I see 0, I see 2, I see 2, I see 2, I see 2, I see 4. OK, I see a variety of answers. I see something that could be 3, but it depends on whether thumbs count or not.
OK, so let's think about this. What happens if KT is minus 1? So let's think about this. If KT is minus 1, then we get 1 minus 0R, so the pole is at zero. So that means of the pole is at 0, what we have is that the denominator is 1. If the denominator is 1, what kind of system is that?
What kinds of systems have a denominator of 1? Feedforward, so that's like a system with no feedback. It's like a system that's just going to respond to the input that it gets and not linger on.
And what's the response going to be? Well, R. OK, what does that mean?
So what that means is that it's going on leap to where it needs to go in one step and be done. So let's look and see how that works out. So KT is minus 1 is the answer here.
And the way we want to think about that is, if KT is minus 1, that's like, in our case, where T was 1/10, then that means that K is minus 10. And if you plug that in, if you look at the equation for the plant, and you say, well all right, if K is minus 10, and imagine that the robot is 2 meters away from where it wants to be, and it really wants to be 1 meter away, so the current error is 1. This is just an example case, so that you could think about this.
So imagine that the current error is 1. The robot is 1 meter farther away from where it wants to be than it should be. So if the error is 1, then the velocity is going to be 10 meters per second. And it's going to get there in one step.
So if you think about the behavior of the robot over time, thing of its position over time, the robot starts here. And on the next step, if it goes at velocity 10, it's going to be right where it wants to be. And according to our model, which is admittedly somewhat naive, it would just stick there right.
So what are some things that are not so good about that model that we made that make this a little bit unrealistic as a strategy? Yeah?
STUDENT: There's no momentum.
PROFESSOR KAELBLING: There's no momentum, right. I mean our robot can't probably just like stop on a dime. So a more realistic physical model would have to take account of the fact that it wouldn't be able to stop instantly. So you might think about your controls being accelerations instead of velocities, for instance. What's another thing that maybe makes this a little bit unrealistic as a model?
Well you're not looking at the sonars carefully enough. What do you know about sonar readings? Are they always right? No, they're not always right. So this is, again, something that we're not modeling here, but it's, in fact, one of the reasons why we have control loops in the first place, it's that the sensors are not always exactly right and you might not always trust it completely. So it might not be a very wise thing to do to just totally leap to the place where you think you need to leap to. Maybe you want to be a little more careful in terms of reacting to your sensor readings.
OK, but if you had an instantaneous sensor and if the robot could stop in no time at all, then picking a K of minus 10 would make this thing just take in one leap and stick to where it's going. OK, that's a very simple system. And that's sort of an unrealistic set-up along a number of dimensions. Let's just make it realistic in one way.
So let's now go back, in fact, to the system that we actually built when we did this. When we thought about it, the sensor actually had a delay in it. So instead of the sensed value being the actual value, the sensed value is the actual value on the previous time step. That's the only difference.
Now let's think about what happens. So if we try to use that same gain, we end up in some trouble. So imagine the robot starts here and it decides to use that same K to leap forward to where it thinks it's supposed to be based on the sensed input. But, of course, the sensed input is old.
So even if the robot is standing here, it's sensed input is going to be that it's where it was before. So it's going to leap forward more. And then it's going to go, oh no, oh no. It's going to be standing here, but it's going to sense that it's right here. And it's going to say, oh cool, I'm just where I want to be.
And then now, it's sitting here, its sensed input is going to tell, oh no, I'm much too far away. I need to go backward. It goes backwards. Now it's again where it's supposed to be, but its sensed input tells it that it's actually still much too far away. So it goes running backwards, oh no. And now it's back to where it was. And that's just going to keep happening.
OK, so with the delay in there, what used to be right gain isn't the right gain anymore. That gain is now kind of really too hyperactive. It's acting as if it can correct the error all in one go. But in fact, it doesn't even know really what the error is because there's a delay in sensing.
So if we want to find the right gain for the system now that we've put a delay in the sensor, we have to go back, and do the math, and get the poles, and see how they depend on KT again. So let's do that.
So again, this is an exercise that we've kind of mostly been through. We write out the difference equations for the individual components, as we did before. Now this difference equation has a delay in it that it didn't used to have. We could convert those to operator equations, munge them together, convert back to a difference equation, then we would get this difference equation.
And we see that there's an n minus 2 over here. So now the output value at time n depends on the output value at time n minus 1, and also on the output value at time n minus 2.
So now what happens when we look at the diagram is that we see that there's another R in the feedback path. So there's two R's in the path as we go around. So that makes it really kind of a fundamentally different system.
If we write out the system function, we get this. So it's minus KTR on the top, that's as it was before. But now we have a quadratic in the denominator. So quadratic in the denominator, that's going to tell us that we're going to have two poles.
Remember, that the way to find the poles is not to find the roots of the denominator polynomial, not, not, not. The right thing to do is to go everywhere you see an R in the numerator and denominator, substitute a 1 over z. That's just a change of variables. Then we now can multiply through the top and the bottom by z squared and then we get something that's a ratio of polynomials in z. And now we can find the roots of the denominator polynomial in z. And we find that these are the roots.
OK, so that's an application of algebra. So here's the roots. And what do we see about the roots?
Well, they're a conjugate pair. Maybe they're both real or maybe they're both complex, it's going to be one or the other. And we see that the KT here inside the radical is actually going to govern. So depending on how we pick KT, we could decide to make the roots complex or real. So KT is going to have a big effect. It's going to affect the magnitude of the poles and it's going to affect whether they're real or not.
OK, so this is a circle that we're going to get comfortable drawing. Now think about what happens with this circle. So this is a picture of the complex plane. The real axis is here, the imaginary axis is here. We can plot complex numbers on this plane. We've been doing that already.
This circle is the circle of radius one. And so the first thing to think about is that if you plot a pole on this picture, if it's inside the circle, what's the system going to do here? Converge. Inside the circle, converge, outside the circle, diverge. So the unit circle in the complex plane is really important. It governs whether the system is going to converge or diverge.
So now let's just kind of mess around a little bit to see what happens with different values of KT. You see that KT, it's a unit here. And already that tells us an interesting thing. It tells us that we can trade off K and T.
If our computer responds much more quickly, so T is very much smaller, what could we do with K? You would get the same response, a bigger K would go with a smaller T. So if we changed the rate at which we're running our control loop, we would want to change K, probably, to get the same [INAUDIBLE].
OK, so K and T are kind of in it together. We're going to talk now really, again, about what do we do with KT. So they were in it together before, they're still in it together now even if we're in the quadratic situation.
OK, so let's just see what happens. So a good way to understand things is to try some extreme or interesting values for variables. So a favorite extreme or interesting value is 0. So what happens if KT is 0 or almost 0. Let's imagine if KT is just tiny.
If it's almost 0, then what we get here is the square root of 1/2 squared. So that's 1/2. So we get 1/2 plus and minus 1/2, which gives us basically 0 and 1. So that means we have a pole here either on 0. Or if KT is just a little bit, little bit of something positive, then we'll get a pole here just a little bit to the right of 0. And we'll get another pole here just a tiny bit to the left of 1.
So if we tried to run this system with KT equal to almost 0, KT equal to something tiny, how would the system behave? Would it go quickly to where it's supposed to go? How many people think quickly? How many people can read the bottom of the slide? How many people think slowly? OK, good. How many people are alive? Oh, there's one there who's definitely not.
So what happens? Well, we've got two poles. We saw before, pole near 0 is like excellent. It means that we can go right to where we need to go. But because this is a second order system, because the denominator is quadratic, we can refactor it and recompose it into the sum. So the response of the unit sample response of the system, we can think of it as the sum of the unit sample responses to two different first order systems.
One of those first order systems is most excellent and it dies away very quickly. But the other one is not so good. If the pole is 1, the output is going to be constant. So it's not going to change. That's not going to die away in the way that we need for it to go.
So this particular choice KT is not so good. Is everybody happy with that? So it's the magnitude of the dominant pole that really governs how well this thing is going to work out. And the answer is not so well.
So let's try some other interesting values of KT. So it seems like minus 1/4 is an interesting value of KT. If we put in minus 1/4 for KT, then we get 1/4 minus 1/4, which is 0, so all the stuff inside the square root goes away. And our poles are 1/2 and 1/2. So we have the same pole twice.
So that is sort of like we got two poles right there where I put my little hand. And let's see, what can we say about that? So we have two poles at 1/2. What's the unit sample response going to be like to a system with poles at 1/2?
Here's height 1 at time 0. What's the height going to be at time 1? Half, half, half, half. So it's going to die away pretty quickly. So that seems attractive. That might be a reasonably quick convergence.
Now we have drawn in this picture these little blue arrows going in to 1/2, 1/2. And what that's meant to do is help you think about if you were to smoothly change KT. Before we were thinking of KT as being near 0. If you were to smoothly change KT from 0 toward minus 1/4, so we're going to decrease KT from 0, then the poles would move from 0 and 1 in to 1/2. So you change KT and the poles are moving in, and in, and in like this.
And this seems like all good, right? Because as we're moving it this way, the magnitude of the dominant pole is decreasing. So KT equals 0, magnitude of the dominant pole is 1. As we make it more negative, we get to the situation where the magnitude of the dominant pole is 1/2.
OK, so we've improved things. We were able to find a KT that made a system that's going to behave more quickly. So the question is, can we make it any better? So what if we keep pushing KT in this same direction, what happens?
Well, if we keep pushing KT, let's again push it a little bit extremely and then we can think about what happens on the way. If we let KT be negative 1, then we get these poles, which are complex. One is here, one of the poles, remember they're in a conjugate pair. And let's see, and one's here and one's here.
Now it's obvious, it should be obvious, I think, that the real part is 1/2. Because they're all of the form 1/2 plus or minus square root of something. As soon as KT gets more negative than minus 1/4, as soon as KT gets more negative than that, then the stuff inside the radical goes negative. And now we have a nonzero imaginary part.
So what happens, in fact, is these poles, like this guy started out here, it comes in here, and then it's going to go one way or the other. I forgot which way each ones goes. But the two guys come in, they meet, and then they go like this. They start going up as we decrease KT.
Now what's happening to the magnitude? So as the pole goes up like this, is the magnitude of the pole getting bigger or smaller? Bigger, because the magnitude is the length, the distance to the center. So these guys are getting worse.
First of all, they're going to generate behavior that's oscillatory. And second of all, they're going to have bigger magnitudes, which means they're going to converge more slowly. So if we let KT go between minus 1/4 and minus 1, we'll get systems that converge and that oscillate. And the closer it gets to minus 1, the slower it's going to be to converge, because the closer KT gets to negative 1, the bigger the magnitude, and the slower to converge. And if KT goes past minus 1 in the negative direction, then we're going to start to get systems that diverge.
Is that cool? Does this picture make sense to everybody? OK, so it's this process of looking at pictures like this that can help us understand what's going to happen to our system as we mess around with the parameters in it.
OK, good, so imagine that we actually picked KT minus 1, so we got these poles here. What would the period of the oscillation be? Put your fingers up, not for the period, but for the number of the answer, not that it matters too much.
So what do you think the period is? 5, that is to say 6. Yes, good, you can put up 6 fingers. Period is 6, right? It's going to go, I don't know, yes, 6. I have the answer in here too many times. But anyway, it starts here, and then ping, ping, ping, ping, ping. It's just going to go around.
And KT equals 1, it's right smack on the unit circle. So it's not going to decay. So it's just going to go around with period 6.
OK, so what KT gives us the fastest response? So here's how to think about the fastest response now. If we wanted the fasted response as a design problem, we could look at these poles and we could compute the magnitude. And we could now set ourselves an optimization problem.
We could say, all right, here is an expression. Here's the pole. We could be interested in the magnitude. We could ask ourselves, for what value of KT do we have the smallest magnitude? And that's going to give us the system that responds as quickly as possible.
So KT is minus 1/4 gives us the smallest magnitude of the maximum magnitude pole. And so that's going to be the answer that we want.
So what did we see about what happened when we added a delay to our system? So in our first system, we saw that if we wanted to see what happened for different values of KT, that, in fact, all of this whole locus of red behaviors, of red poles, was available to us. And in particular, we could arrange it so that the dominant pole was at 0 and the thing would go immediately there.
Here, we found that, although we could arrange for our poles to be here in this sort of red locus of places, they came in pairs and that when we had somebody near 0, we had to have somebody else near 1. And so that wasn't so good. And that the best we could do in terms of minimizing the magnitude of the dominant pole was this point here, where they were both on top of each other.
So that meant that adding a delay in the sensor made our system harder order to control. It made the system just kind of more unwieldy. And that means that maybe if you went to Radio Shack and you were buying sensors that it would be worth paying more money to get a sensor that didn't have a delay, if you could arrange that. Because if you've got a center without delay, you could build your system so that it would go quite quickly or, ideally, immediately to the desired location.
I'm going to skip these because we're almost done. So you could keep going. So we could say, oh gosh, what if we really have no money at all, and we have to actually make our own sensor or something. We're not very good at making sensors, so it has a lot of delay, it has two-step delay. A sensor with two-step delay, we can do this same analysis.
A sensor with two-step delay is going to end up having a system function where the denominator polynomial is third order because there's going to be a delay in the upper loop and two delays in the lower part of the loop. So there's going to be three delays going around the loop. And so the denominator is going to be third order, that means there's going to be three poles.
And what happens is if we start out with KT 0, we're going to end up with two poles at 0 and one over here at 1. So there's two guys who are behaving well and one who's behaving badly, but it just takes one, that's all we need. So it's the worst pole, no matter how many good ones there are. So that's not very good.
And then, as we begin sort of making KT more negative, slowly, we find that all three poles line up. They're going to kind of hit each other here. And that the best that we can do, in terms of finding a pole when the maximum magnitude pole has the smallest possible magnitude, now is at 0.682. So that means it's not going to converge as quickly. The best situation is over here and it doesn't converge as quickly.
So adding more delay, first all, means that we have to reanalyze the system, we have to reunderstand the system function. And then we optimize our parameters, we're going to get different parameters. And when we look to see what the system behavior will be with those newly optimized parameters, it's not going to be as good. So you put more delay in the system, the best I can do, if I get to set all the gains, is still not going to be as good as I could do as if you gave me a system with fewer delays built into it. So the delay has a fundamental effect on how quickly you can drive the system to a stable point.
OK, so the summary here, system functions help us understand what the system is going to do. Long-term response is determined by the magnitude of the dominant pole, the pole with the largest magnitude. We say systems are stable if the magnitude of the dominant pole is less than 1, unstable if it's bigger than 1. Adding delays tends to decrease the stability.
I'm just going to let you think about this. I'm going to just recap and set you free. So this week, software lab is about optimization. It's writing some software that will help you pick good values of K in a system. Design lab, we're going to take that silly drunken robot we had last time that we couldn't stabilize and make go straight down the hallway and study some ways of making it straight using second order control systems.
And next week, there is a lecture on Monday, no software lab. Exam on Tuesday evening. If you can't come Tuesday evening, email me and you can come on Wednesday morning instead. And we will have review sessions and we'll announce the rooms tonight.