Hello and welcome to Glue Lecture 6. Today's lecture should kind of walk you through a little bit of this idea of how robots are going to behave using the framework introduced in Module 6 this week in Dr Edgersett's lecture. So hopefully it'll help you with Quiz 6. So this week in lecture, Dr Edgersett introduced this kind of scary looking hybrid automaton that has lots of complicated guard conditions. And today we're just kind of going to break through those and sort of show you how we might move through this automaton as we try to navigate towards a goal. So we have these behaviors. Go to goal, this is actually a controller, you go to goal, follow wall, navigating around the obstacle counterclockwise. Avoid obstacle and follow the wall of the obstacle navigating in the clockwise direction. So, we're going to answer this question, what does this look like on a robot? So in our little set up we have some robot here. He has a heading, given by this black arrow. We have our obstacle in red. Around this obstacle I've drawn a, a line in grey that represents this delta distance away from the obstacle at which we need to switch to avoid obstacles when we get inside. And then here, the little orange star is our goal. So now, where does the robot wake up in terms of this high level description of the control? So this, this first arrow points right here into u, u go to goal, which means the go to goal controller will be running right when the robot wakes up. So this is the behavior we start with. So what does this look like in our scenario? We have this vector here drawn in red. It points to our goal. And this is the direction along which u go to goal will drive us. And remember that on the robot, kind of at that lower level, we're thinking of these controllers with these equations. Right? So our go to goal controller is going to cause us to drive our current state x to this goal using some gain given in k. Likewise with the, with the avoid obstacle controller. And then with follow wall, we're just rotating the direction that you AO, avoid obstacle controller takes us and we're rotating that by 90 degrees depending on whether we're going clockwise or counterclockwise which way the 90 degrees goes. And remember that's given by this rotation matrix here. So, if you see something like, you know where you have, say 0,1,1,0, notice that this could be a rotation matrix. You know, there might be some theta that satisfies what this matrix looks like that means that this matrix is causing a rotation of a vector. Anytime you see kind of, of a symmetrical structure like this in a, in a matrix, say on Quiz 6, keep that in mind. And remember that our robot is implementing this, this, controller up here U in terms of VNW and our actuator wheel commands. And we know how to go with, between VNW and the wheel commands back in Module 2, that's where we learned that. So, while we have this high level kind of controlling automaton, there are these other things going on kind of at the lower level on the robot. But for now we'll just think okay we know that the u go to goal is running, our robot is going to drive towards that star, directly towards it. So let's watch that as it happens, they're driving towards it and now . All of a sudden, we're at this point where, where within delta away from our obstacle. So let's go back to our automaton, and see if that changes anything. And indeed, two of the guard conditions are that, when we're inside of this radius delta, we might have the condition where we need to change. So let's look at the other half of both of those conditions, where. We're looking at this inner product between these vectors defined by this, these control laws, the, the go to goal controller and the follow wall controller, both clockwise and counterclockwise. And this is really going to determine, once we're inside this delta range, do we follow the obstacle clockwise or counterclockwise. And we were talking about vec-, vectors here in the Euclidean space. This, so we have our follow wall vector and our UA, avoid obstacle director this -- vector, this is the direction we would drive in if we were operating under this controller or this controller or this controller. So now, how do we kind of decode this condition of this inner product? So with these, with these vectors in Euclidean space our dot, our inner product is just a dot product. And so we can write it as the magnitudes of both of these vectors here, for example, with the clockwise follow wall controller. And then the angle between those two guys. So, this is really the important term, right? Because this is going to vary between 1 and negative 1, in the following way. So if the two vectors are, are collinear, then the angle between them is 0. The cosine of that is 1. So that would satisfy this condition, right? When they're perpendirect, you know, exact perpendicular to each other, the cosine of that is 0. So we did not satisfy this condition. And then of course, when they're completely open and the angle between them is pi, we get this negative 1 value. So we know that our vector is this cosine term is going to vary between these values and if it's 0 or negative 1, no matter what these magnitudes are, it's kind of irrelevant. So really, what we're worried about is when we're in between these two cases between 0 and 1 where this is going to be greater than 0. So you can kind of see now directly from the picture in this case, my angle between the clockwise and the avoid obstacle is a little bit smaller than between these two. Right? Because these are going to add up to 180. This one looks like a little bit less than 90. So that means we're going to follow that clockwise rotation that way. So we can see that these two conditions are satisfied now. And so we move from operating under the go to goal controller to now the clockwise follow wall. And at this point when this is true, we note the time detail because that's the important condition for whether we switch later given by this guy down here. So we note the, the detail what time it is or not, not what time it is but, how far away we are at the goal. Here at d tal, so we, we mark the distance from our goal at d tal. And now we follow wall. So we're going to follow this new kind of pink vector. The robot's going to keep moving forward. And now, we've actually gotten a little bit closer to the goal, right? So let's go back to that automaton. Let's look at the condition that might cause us here, we're in this state now. What might cause us to leave is if we get, within the distance delta. Well that's not going to happen, right? Because we're following the wall. Or if we get closer to the goal than we were at time detail or at time tell so the distance at time tell. And then again this other inner product that we need to consider. So lets look at those two vectors now so here we have follow wall, avoid obstacle, and go to goal. Now, we're interested in whether the cosine of the angle between these two vectors avoid obstacle and go to goal is between 90 and 0. And of course in this case we can see that that's more than ninety so we're going to stay with following wall because we don't satisfy both of the conditions to go back to go to goal. So we continue to follow wall Continue to follow wall and now, we're getting closer to that point where, now this angle here is less than 90. Our inner product between these two vectors is now greater than 0, and so we switch. These are our two conditions we needed to satisfy right, we switch back from follow wall to go to goal. We've made it all the way, and this is kind of where we're home free. Because we're not going to encounter any more obstacles. But, if we did, we'd kind of go through that whole process again. So you can see how this overall hybrid automaton switching our controllers. We get to these, to this what we did, right? This path around the obstacle. And it would make the goal. So I hope that this helps you with some of the kind of high-level behavior questions you are going to have on quiz six this week and check the forums for more help. And good luck.