Transcripts
1. Promo Video: How much do you need to turn the front wheel of a car to make it follow a trajectory or move the elevator for plane to achieve the required bit Django, or applied power, two propellers to fly a drone. For movies ship as you want, or even regulate current in an electric motor to control a robotic arm. All of them are systems. And the might be different, but they can all be mathematically modeled and control using the same fundamental logic. My name is Mark. I'm an Aerospace and robotics engineer and I want to teach you how to do it. After this course, you will know how to model a system using state-space equations, then how to apply a PID and the model predictive controller, or Mpc to it, will first use PID to control a simple magnetic train that needs to catch objects that randomly fall from the sky. Then we'll use MVC to achieve a simple link changing maneuver with a car on a straight road. For each system, there is a stimulation in Python to create a bridge between intuition, mathematics, encoding, three skills that every engineer needs to have. The coast will be available for you to download and experiment with. And I will explain to you the MPC code in a special section. When I teach the My goal is to make you understand it. Fundamentally, if you memorize stuff, then you will forget it quickly. But if you understand it, it will stay with you for good. Only then you will be able to modify and apply this knowledge to other systems. I'll make sure that you will truly mastered the content before you by taking a look at some of my free videos. And if you like what you see enrolling in the course, and let's get started. Looking forward to seeing you there.
2. Guide: Welcome back in this video, I would like to give you some general recommendations on how you should study this course in order to make sure that you get the maximum value out of it. First of all, it is very important to start with the course from the very beginning and not skip anything in between. You don't have to be familiar with control engineering to study this course I've built it. Assuming that you aren't, however, new topics do relay on all the topics. Therefore, if you start from the beginning, you don't skip anything and watch lectures in the right order. Then you'll be fine. Secondly, I highly recommend watching the videos at 1.25 times speed. I think that that's the optimum speed for that. In the mathematical derivation part of the course, I actually recommend watching some of the videos at the speed of 1.5. However, I will mention it there separately. Thirdly, and this is very, very important. Throughout the course, I will be giving you thought, exercises and tasks to do in the videos. I will be asking you to pose the video and try them yourself before continuing with the course. I can't overstate it. Please pause the video and try those tasks yourself before watching my solutions. Even if you get it wrong, it doesn't matter. What matters is that you try it for some time because it will stimulate your thinking regarding the course content. And by the end of the day, you will massive the course much better. That's true learning. So you know you've paid for the course. Take the maximum out of it, try my tasks yourself, and then watch how I did it. You won't regret it, I promise you. And lastly, this course is divided into sections and in each section you have videos. The entire section is like a chapter, which means that sometimes when a video in the section ends, then the thought that I was trying to explain to you is not finished yet and you have to watch the next video to really understand my explanation. In most cases, I avoided that, and most videos are still divided in a quite standalone manner. However, in some cases when the video ends, then the next one will be like a continuation to that. The sections themselves, however, are stand alone. And so in the next video we will start with the first part. Thank you very much and else either.
3. PID VS Model Predictive Control (MPC) 1: Welcome back. In this video, I want to show you a vehicle that is driving on a straight road attempting to change lanes. This is the vehicle right here. These are the lanes, 12345. The blue line is the reference trajectory that the vehicle needs to follow. And then the red line is where the vehicle actually goes. This is the zoomed in version of the vehicle. This is the vehicles body, and this is its front wheel that creates a steering wheel angle that makes the vehicle turn. The goal here is to find the right front wheel steering angle so that the car would follow the trajectory as close as possible. This is the system that we are going to be using as we start our journey in model predictive control. I will treat the simulation in a more detailed way in the end of the course, where I will explain to you the code as well. Here I have the control input, the vehicles orientation, and the vertical position as a function of time. But now the question is, why should we learn model predictive control or MPC? I mean, can't digest apply a PID controller and that's it. The answer is yes and no. You can do it. However, it is trickier and a well tuned MPC controller with a good mathematical model gives you a better result than a well tuned PID controller. In fact, here, I have applied a PID controller to the vehicle. As you can see, the vehicle is following the trajectory, but it could be better. And note the oscillations here, the front wheel and the vehicle oscillates a bit. And now I'll show you the same simulation, but with an MPC controller. Much better write. Mpc is more advanced than PID and it is widely used in complex systems like airplanes, drone, complex water management systems, and others. So it is worth learning. In the end of the course, when you have mastered MPC, I will show you why it is superior to PID. We will compare them more. I wish you a great learning experience.
4. Intro to MPC: every now and then. Ah, very powerful technique appears in the engineering world that it's so universal and which can be applied to so many systems that it becomes unbelievably popular. One of these techniques is called moral predictive Control, or MPC, for sure, embassies heard by many engineers. But not so many truly understand it, because at first glance it seems complicated, very abstract and quite non intuitive. Nevertheless, I'm here to show you the exact opposite. NBC is not difficult at all. It fuses with real world applications beautifully, and it is quite intuitive as well. So if you truly want to be great in solving engineering problems, you have to have all of these three basic abilities. You have to understand your problem intuitively. You have to be able to quantify it mathematically because even though intuition is rate, it's definitely not enough. And finally, you have to be able to translate it all into a code, and with me you will learn all that
5. Getting started with modelling a car 1: So in this course, we're gonna apply our MPC controller to a simple autonomous car case. We're gonna make it their simple. We're gonna assume that our car has a constant forward velocity. So if I draw a car here, tough you right, then this car were will have a constant forward velocity. It's not gonna change. And we're gonna try to achieve a lane changing maneuver. So essentially what the control needs to do. It needs to make the car change the lane autonomously, and we're gonna use an MPC control for that. Now, how will it happen? The controller, We'll tell the car. So this is again a car and these air back wheels here, All right, And here I'm gonna draw the front wheels. And so, in order for the car to turn the front wheels, I need to turn right And these front wheels, they will make a certain angle with forward velocity. And this angle here will be delta or steering wheel angle. And so if you turn the front wheels, then you're gonna turn, and the embassy controller that we're going to design is going to decide autonomously without human help, which kind off Delta is best so that the car would then change the lane. So this is lane here, and we want the car to go toe another lane. The controller will decide how much it needs to turn the front wheels in order to achieve that. So the reason why we're keeping the forward velocity off the car constant in our course is because that will make the application off more predictive control tomorrow. Car Very easy. And that's very good, because that will allow you to fundamentally understand how this technique works, because that's my goal for this course would I want to achieve. I want to make sure that you guys understand MPC intuitively, but I also I want you to learn how to quantify it mathematically. And then, in the end, I will teach you how to code it, and it's good to do it on a simple system at the beginning. Then you won't get caught up with all the nuances and difficulties
6. Getting started with modelling a car 2: Also, our system is gonna be a three degree of freedom system. So in order to describe the position and the orientation for car, we're gonna need to have an x coordinate and why co ordinate and the your angle. So let me just draw according system here, Right? You have an X here. You have. Ah, why here? And let's say that your car is here and the center off mass of the cars here. And so you have the X coordinate. You have the y coordinate. So with these two variables, you determine the position of the car. But the car doesn't on Lee have a position. It also has an orientation, and you need to be able to measure that as well. And so we're gonna measure that with a your angle, all right. And we denote you with apps I and upside so X and why they are measured in meters. But sigh or your angle it is measured in radiance. So it's a three degree of freedom problem. That's what the degree of freedom means. That degree of freedom is the amount of variables you need to specify in order to no, the car's position and orientation in space. And in our case, it's X y and then the yaw angle sigh. Since our car doesn't drive up the hill nor down the hill, then we don't have to consider the Z axis because even though normally you have, ah, three d space, all right, you have X. Why and Z. However, in our case, our car will be essentially driving on an X Y plane. So in the next video, we're gonna talk about forces and moments, and we're gonna focus on their physical meaning. And we're gonna do the same for the masses and mass moments of inertial for an object. We're gonna look at their differences, their physical differences, how they affect the acceleration and rotation, often objects such as our car. And I think it's very important because then everything that I'm gonna tell you later on in the course will make much more sense. So thank you very much. And I'll see you in the next video
7. Fundamentals of forces and moments 1: physics is truly an amazing thing. It has given us so many useful tools with which we can describe our environment and also, to a certain extent, control it one of the most classical notions and physics, our forces and moments Without them, we wouldn't have been able to accurately drive, fly or send satellites to space. So let's now learn forces and moments, and let's try to understand them fundamentally. And let's try to understand what they do tow objects that they're applied to. Now, a good way to understand what a forces is to look at its units with the note force with a capital F right, and we measure force with a unit called Newton. And what's mutant mutant is equivalent to kilograms times meters per second squirt right? The kilogram is a unit of mass and meters per second squared is acceleration. So already from the unit, you see what a force really is. Force is accelerating some kind of mass, all right, and that's why you also have this famous formula. Force equals mass times acceleration. So if you have some kind of box and the massive that box is that say, two kilograms and you apply as six noon force to the box in that box will accelerate. How much? Three meters per second squared right, because acceleration equals if divided by em. And then if now we have another box and the mass of the other box is six kilograms, then was the acceleration. The acceleration would be one meters per second squared. So in a way from this formula you can see what the mass really is. Masses resistance to acceleration. If you apply the same amount of force toe a box, right, then a heavier box will accelerate will accelerate less. So mass really is a resistance to acceleration. And so what is a moment, then moment that would, you know, with a capital M or Torque Capital T And by the way, moments of talks there, same thing. They're used in different contacts, but their physical meaning is the same thing. They had the same units and their units are mutants times meters. Okay, so what you need to know is that forces, they make an object accelerate in space, but moments or torques, they make the object accelerate Rotational e. So, in the case of forces, we have this kind of acceleration where we have meters per second squared would be the units for the acceleration. But when we deal with moments than the result will be angular. Acceleration often object. So let's say alfa double dot Alfa is an angle and the double dot it would be the second rivet for that angle. So it will be d squared Alfa d T Square. All right. And the units here would be radiance per second squared, for example. Let me draw a rod here. This rod can rotate about this point that we call a and let's say that we have another point here be and we apply a certain force to that point. And now, if we want to calculate the moment that this force exerts on this road about this point a right, then what we have to do we have to decompose this force into the X and why component? So we have force. Why here and force X now, why do we decompose it? Because when you calculate the moment, first of all, you have to calculate the moment by taking this force and multiplied by this distance here from a to B right and So the moment about the point a right about this point here, the moment about the point A would be force in the Y direction, times, distance, and whatever answer you have there it will have the units, mutants, meters. And so the reason why we had to decompose this force vector here is because when you multiply your force times distance than the force has to be perpendicular to this distance . So there must be this 90 degree angle here and as a result, the moment will accelerate this rod rotational e. So this rod will starts to rotate about the point. A. So how do we now find the relation between the moment and the angular acceleration of this rot? Well, let's see, when we had our force right, and then our force equals mass times acceleration. Now we said that the mass was resistance to acceleration. So if you have the same amount of force but you have more mass than the acceleration of the body will be less right. So you could rewrite this formula like this, right? So for a bigger mass, assuming that the force is the same for a bigger mass, you would have less exploration, so masses resistance to acceleration. So when we talk about moments right, then you need to have something here, times the angular acceleration to double dot Alfa. So if here em was resistance to acceleration that here in this box you should have resistance to What do you think it is? Resistance to rotation, right? So moment equals resistance to rotation times, angular acceleration. And this resistance to rotation is called Moment of Inertia. All right, And again, if you rewrite this equation in this way that moment, a moment divided by the moment of inertia, then you will see that for the same amount of moment that you have. If you have Mawr moment of inertia, you will have less angular acceleration so your object will accelerate angle early. Less so. The moment of inertia. Here is resistance to rotation Now question to you. And you can pose the video for that If you want to. Can you? Without looking it up online? Can you figure out the units off moment of inertia? Just pose the video and then I will tell you the solution
8. Fundamentals of forces and moments 2: So one of the units off a moment, it's Newton meters right equals X, which which are the units of the mass moment of inertia I times radiance per second squared . Okay, so we can rewrite this part of the equation in the following way. Kilogram times meter divided by as squared, which is the Newton part times m, which is this M here equals X radiance as squared. So what you can do now You can just, uh, put this s here s court here and you can put radiance here. Okay, so you can cancel s squirt and s squared. And well, the radiance. It's the mention, Lis. Why's dimension Lis? Because radiance is calculated the circumference of a circle divided by the diameter of the circle. Right, So And when you calculated when you take the same conference of the circle and you're divided by the diameter of the circle, you get pi. But both of these quantities, our meters, right. The circumference of the circle is meters, and the diameter of the circle is meters. So you divide meters by meters and you get radiance. But radiance is meters by meters, which means that radiance is that dimension Lis unit. So here you can just make it disappear. All right? And there you go. They unit for your mass moment of inertia. IHS Kilograms meter squared. That's the unit off mass moment of inertia And it is the resistance to rotation. So the more off mass moment off inertia you have, the harder it is for the object to rotate or to accelerate. Rotational e The more moment you need to apply toe, accelerate rotational e some kind off object in order to get Mawr radiance per second squared. There is one more thing that I want to cover. Let's say that you have a cube here, okay? And this cube has an equal distribution of mass inside it, and then the center of Mass is in the center of the Cube, and then you have another cube like object that looks like a cube, but it's empty inside, so it's bigger, right? But it's empty inside, so the question to you is if they have the same amount of mass both this object and this object if their masses air equal, which one of them have a higher mass moment of inertia. In other words, which one of them have a higher resistance to rotation. You can post for a second, and then I'll let you know the answer. So the answer is that the second object, this bigger object, has a higher mass moment of inertia, even though they have the same mass. Why? Because one thing with mass moments of inertia is that if you have a center of mass somewhere, the more mass you have away from the center of mass, the higher your mass moment of inertia is even though they have the same amount of mass. In the first case, most of them masses clustered close to the center of Mass. But in the second case, all that mass, all of that mass is further away from the center of mass, right? So it's all further away. And therefore because of that reason, the mass moment of inertia is bigger for the second object
9. Fundamentals of forces and moments 3: So before we finish the force and moments section, I will not do a small, fundamental exercise that I think will really help you fundamentally understand forces and moments and their differences and what happens with the objects that they're apply to. All right, So I'm gonna ask you to participate in this exercise. I'm gonna be asking you several questions, and then I'm gonna ask you to pose the video. And, uh, once you think you know the answer, just on pause the video and I will tell you the answer. So let's get started. So I'm gonna use some colors. And let's assume that we're somewhere far, far away in the universe far away from the earth. So there is no force of gravity, right? You simply have a rod that is stilted at a 60 degree angle. And in the center of this rod, you have a center of mass. Okay, so right now there is no force applied to this road, so it just exist. They're just hovers there. So now what I'm gonna do, I'm going to apply a force to this rot. But in the location off the to the location of the center of Mass. So the question to you is what do you think is gonna happen with the road after sometime? Where will this road be? And at which angle This road will be so past for a second. So the answer is that you have to look at the center of Mass. The center of mass will only go in the X direction. All right. It will not go in the Y direction. It will only go in The X direction in the road will still be at an angle off 60 degrees. All right, so it it will still be at an angle of 60 reach. So if we apply this force again, then after some time again, the center of mass will only move in the X direction. But it won't move in the wind direction. So the Y direction would be up and the X direction would be to the right, so the roads would only move in the X direction and it would still be at an angle off 60 degrees. Okay, but how about if now I apply this force like this, what's gonna happen with the wrote boss? So the answer is that now the center of mass off this road will move up and also along the X direction. So your center of mass will be here. But the road will still be at an angle off 60 degrees, so the angle won't change. Okay, So, again, if I apply a force here, then you already know the answer for that. The center of mass will only move in the X direction and the angle won't change. So it will still be 60 degrees. All right. And now, if I apply a force like this, then I guess you already know what's gonna happen with the road. The center of mass will move down and the rods will still be at an angle off 60 degrees. So this kind of motion, it's called transnational motion. So the object is translated. The central mass of the object is translating. Is translating along some kind of path. Right? But it's not a rotational motion, As you can see the angle of the road then change. Why? Well, because there was no moment, right? Remember? What is it? What makes an object rotate? It's a moment, not force. You need to have a moment in order to change the angle off your object. And the moment in this case is zero. Because even though you have force But this force is applied directly to the center of mass . And so since moment equals force, times distance and then the distance is zero because the force is applied right at the center of Mass. So the distance is zero, and therefore moment is also 00 newton meters and therefore you only have this motion where the center of mass moves. But the orientation of the road doesn't change, right? So essentially you can have this kind off motion off off the road where the road moves along some kind of trajectory. But the orientation of the road doesn't change. It's at the same angle. Okay, but now let's do something more interesting. Suppose that I have another rod here, and initially, that road again isn't at an angle of 60 degrees and you have the center of mass here, and I'm going to apply a force. But this time I'm gonna play it here. So what do you think is gonna happen with this wrought in terms off the motion off the center of Mass and the rotation of the road. Don't worry about the specific angles. Just think about whether the angles will decrease or increase or stay the same, and whether the road will go up or down, or only in the X direction. So the answer is, Remember, the force on Lee makes the road accelerate, right? So this force is only applied in the X direction, which means the center of mass off this road will only move in the X direction. It will not move down. It will not move up. It will only move in the X direction. However, now pay attention that you have a distance here, right the distance which is perpendicular to this force and that creates a moment. Right? So you have You have force times distance, so you have some kind of moment. And what do moments do they make Body's rotate. So now this wrote, It's center of Mass will still be at the same height, but it will have a smaller angle, so instead of 60 degrees it will be 45 degrees. All right, let's take another one. I apply force, but now like this and now this force vector is perpendicular to the road. Right? So what's gonna happen with the road now, boss? So now if you look at the force Vector, it also points down eight points. It has a component in the X direction, but also in the Y direction. And so because of that, the center of mass will move down. Right? But now you also have a distance here. So because of that, you also have a moment. And since you have a moment, the the object will rotate as well. So because of that, this road will be even at the smaller angle. So let's say 30 degrees. And finally, finally, if we take two forces and we're gonna apply one here and one here only in the X direction And so the distance to one of the forces is D in the distance. Do the other forces also D. So actually, the distances here are equal. Okay, They don't look like equal, but they're equal. So what will happen with the road now? Poor's. The answer is that now the center of mass will move on Lee in the X direction because both forces are in the X direction and the rotation off the road does not change. It will still be 30 degrees. Why? Because even though you have one moment from this force, but another moment is caused by the other force in the other direction. So this moment here Will will try to make the road rotate in this direction. But the downward force will try to make the road rotate in this direction. And so because of that, both of these moments, they will compensate each other and the body will not wrote it. So you will end up being in this position where the center of mass on Lee goes in the X direction. But the road stays at 30 degrees. Okay, so I hope you've enjoyed the exercise. And now you understand the moments in the forces and started starting from the next video, we will not. We will start working on the car and building the model of the car. And after that, we're going to start building the controller. So thank you very much and see you in the next video.
10. Setting stage for the car's lateral control 1: welcome back. So starting from this lecture, we're really going to start working on the car now. So the first step is let's try to understand What? What is it, What we're trying to achieve? What is it that we want our controller to do? So what I'm gonna do, I'm gonna draw a road, a nice wide grows, and I'm gonna have ah, broken line here that will separate the two lanes. And so my car right now is in this lane, right? And this car at the moment? Well, in fact, not at the moment. Always, Because remember, our four of the last day was constant. Our forward velocity would be 20 meters per second, all right? And it is constant. It doesn't change. And so we want to perform a lane changing manure, right? And we have a trajectory, a common sense, nice trajectory that will allow us to change the lane in a smooth way. And maybe we have it as a pre planned trajectory. Or maybe we have some kind off camera on top of the car that looked at the road and decided that Okay, this is the best trajectory to follow. But the bomb line is that we have a reference trajectory. And so the controls job is to make the car follow this trajectory autonomous without human help. And let's say that we want to complete this maneuver in seven seconds. So at the beginning, it's gonna be t equals zero seconds. Then it's gonna be one, 23 456 and seven. So here time equals seven seconds. So this is what we want to achieve. And this is what our controller will need to achieve for this car by manipulating its forward wheels. So I'm just gonna create a box here and inside the box we're gonna have or open loop system , all right? And by an open loop system, I mean, we're gonna have a mathematical model that relates the input off our system to the outputs of our system. Now, in our case, the inputs off the car would be delta the rotation off the front wheels. So we have a car here, and we have the backwards wheels and our front wheels. They will be at an angle, and so this angle will be the steering wheel angle delta, which we measure in radiance. So this will be the input into our open loop system. And so are mathematical. Mo will produce our outputs, which will be X y and sigh all these three degrees of freedom values right In the real life , of course, you will have sensors that will measure these values x why and sigh. So once we have these values, we have to compare them to the reference values. So to the reference ex reference Weyand reference Sigh. So we're gonna have at some point, we're gonna have reference values. So x r. Why are and sigh are These are the values that tell us where we want to be, right? These are the values where we are and these are the values where we want to be. So we're gonna now, before mount an operation where we're gonna subtract the values that we have from the reference values something plus here and Linus here. And in the end, we're gonna have an error term for the X and error term for the y and an error term for the Cy right? And so these error terms will then enter into our controller, which in our case, will be the MPC controller but it doesn't have to be an embassy controller. It can be another controller as well. But that's the general picture of the situation. And so the MPC job will be to find the right Delta the right steering wheel angle so that the errors would go to zero. Because when the errors go to zero and that means that the values that we have here, that's where we are, where we really are, that means that these values match where we want to be. Because remember, the error is said. The error in the X direction is x r minus X. So that's gonna be the job off the controller.
11. Setting stage for the car's lateral control 2: now, luckily, we can make our schematics even easier. In our case, we can get rid off X. We can get rid off the air, Rex, and we can get rid off the reference ex. Let me show you why. So again, we have a road here. Imagine that We have a road here, and this is our trajectory that the car needs to follow. Now this entire world is measured in global X and Y reference frames. Right. So you have an X here, and you have the white dimension. So imagine now that your car is here and the center of mass of the car is here. No, in orderto control the car and make it to be where the reference line is. What you need is the distance from the center of mass. Do the reference line. Right, So we can draw it here. So this would be your Why ever write it would be this one. Why error? So if you manage to get that zero, then the center of massive your car will be here. In this point. However, you also need to consider the orientation of the car. So right now you can see that the euro angle off the car is different from the yo angle off the reference frame, so the your angle of the reference frame right now is something like this, right? But the euro angle of the car is bigger, so it's something like this. So you also have to control the your angle. So here this would be your your angle reference, right? It's this one. This is that your angle of the trajectory and this is the young angle off the car. And so the your angle ever would be the you angle of the trajectory minus the euro angle off the car. So if you manage to get that term to zero as well, then the trajectories you angle will equal the core issue angle and then what you will have you will have a car. Who's center of Mass is where the central line is right and also the orientation of the car will match urination of the reference line. And so, in our case, you truly need Onley two variables To control the car, you need the why they mentioned and you need the your dimension. And in our case, these air the valuables that we're gonna be working with. And by the way, the reason where we can make this simplification is because we have a constant for velocity . That was 20 meters per second, right? And the thing is that we don't have toe control this Ford with last year, right? We only control the steering wheel angle, but we don't have to control the forward we lost in our case. So we don't have to think about applying more gas to the car or applying the brakes to the car. So that's one reason why we can make this simplification. However, it's also because we have to consider that the U Angles here are actually pretty small. You might think that they're like maybe 45 degrees or something. But actually they're extremely small because if you think about it, this entire operation would happen in seven seconds, right? So T equals seven seconds. So if you travel 20 meters per second right then let's say that the distance here is maybe maximum. I don't know, maybe three or four meters. Let's say it's four meters right, But since you're Ford of the lost days 20 meters per second then and this entire think happens in seven seconds. Then that means that in the X direction you will approximately travel 140 meters. Right? So 20 meters per second time. Seven seconds. You would have 140 meters. So you will travel what, approximately 140 meters in the X direction. But at the same time, you will only travel four meters in the Y direction. So you can imagine that actually, the angles the Ewings that we're talking here about are gonna be very small. So essentially you don't have to worry about the X dimension because this ex I mentioned you pretty much know how is gonna be you pretty much know that in seven seconds you're gonna travel 140 meters because your velocity is constant, it doesn't change. So therefore, you don't have to worry about the X dimension because you approximately know where you're gonna be at at every second. And finally I want to highlight something that even though this course about the MPC controller, you really can have different kinds of controller there. For example, you can have a p i d controller there, but here's one new ones that I want to point out. So here we have two outputs, right? We have why and we have the your angle. And so that's why here we have the reference why and reference you angle. And here you will have the air, why and three year urinal. So of course, if you have your MPC control here than your control will give you the Delta so that the car would drive in such a way that next time the error, these errors would be zero. Now, if you want to use a p I d control for that than notice one thing in this system we have one input, but we have to outputs. But a PhD controller, it's ah single input single output system. It's called sizzle. So Cesar is single input single output. So it's a term used in in in control engineering. You also have something called memo, which is multi input multi output system. So in fact, in our case, it's it should be simple, even though I'm not sure if they're using this kind of term because we have single input and multi output system, right? So we have two outputs, one input but a P I D controller is only can only handle Caesar systems. So you're gonna have to have two p i d. Controllers here. So you're gonna have to have one p i d controller. Where? Where it takes in the error in the Y direction. So se error. Why? And then you have your P i d right? Be 81 and then you get one delta and then you will have another error the your error, and then you will have another p i d. And you will have Delta two and then you will add them up for maybe do something else with them. And then you will have this combined delta that will then enter into your open loop system . And remember, the P A. D had three constants that you had to tune the proportional integral and the derivative constant. And since you have to pee, I d controls here until you have six parameters to tune. And so it could be quite a challenge. The advantage off a model predictive control off MPC is that MPC can take in multiple outputs and multiple inputs. So MPC is scalable. P i d is not scalable, but MPC is scalable. So that's the great advantage of the MPC controller. It has other advantages, as as well. And I'm gonna share them with you when we start designing the MPC controller. But one of those advantages is that MPC is very suitable for memo systems.
12. PID VS Model Predictive Control (MPC) 2: Welcome back. Here. I want to get back to this simulator. Right now. I'm applying a PID controller. And in fact, I've done exactly what I explained to you in the previous lecture. Since PID is a SISO system, then I applied to PID controllers, one for controlling the row dimension in the other one for the big y-dimension. So I have six constants here with which I can tune my two controllers through trial and error. I decided to go with these values here. I get to Deltas, Delta for ya and delta for big Y. And then I add them together and then I apply them to the vehicle, like I mentioned, could be better. And again, one obvious advantage of MPC is that it naturally skills up to deal with MIMO systems, multi input, multi output systems. Csr was single-input-single-output. However, there are more advantages. I will cover them in the last section where I explained to you the simulator. Thank you.
13. Setting stage for the car's lateral control 3: So before we start mathematically modeling our open-loop system, the model that will connect the inputs and the outputs of the system. So in our case, the steering wheel angle and then the y and the yaw angle. Before we do that, we have to talk about the reference frames as well. Because in our case, we have two different reference frames. One reference frame, the Global Earth fixed reference frame, right? So I'm going to draw it here. So it's a global reference frame or earth reference frame. So this reference frame is fixed to the ground. It doesn't move, it's an inertial reference frame. However, you also have a car, and that car, you have a body frame. The body frame is attached where the center of masses. And this body frame is attached. In this way. You have a small x here and you have a small y here. So the x-direction is the longitudinal direction, alright? Lawn g to the y direction. And then the small y direction is the lateral direction. So when we talk about the constant for velocity, then it's also called longitudinal velocity. So our longitudinal velocity is constant and is 20 meters per second. Alright? But how about if the car travels in a circle? Doesn't mostly experienced longitudinal or lateral velocities or both. You can pause for a sec if you want. So the answer is that the car, in normal circumstances, the car mostly experiences longitudinal velocities and a negligible amount of lateral velocities. So let's say that in this case, if this car travels in a circle and let's say after some time, this car is here. Then remember the body frame always travels with the car. So wherever the cargos, that's where the body frame goes. So in this case, the longitudinal direction of the body frame would be in this direction. And then the lateral direction would be outwards like this. So this will be small x and this would be small y. And again, if the car is here. Then the lateral direction would be outwards, but the longitudinal direction would be forwards. And as you can see, as he's driving a circle, then you drive in the longitudinal direction. Now, of course, nothing in the world is perfect and maybe you slip a little bit, a couple of millimeters here and there, so sure. So I guess you have a little bit of lateral velocity, but you can neglect it. Now, of course, things are different. When you have sideway slipping. For example, if you're on the ice and you're driving along a road with very high curvature, right? Then your car is here and okay, you go, you go forward, you drive longitudinally. But because you're on the ice and it's very slippery, you also starts slipping in that direction. And in that case, you will have lateral velocity as well. Or also when you are in Tokyo Drift, then you also have lateral velocity. Now, since we have two reference frames, we have this inertial reference frame with capital X and capital Y. And then we also have this body reference frame, small x and small y. And if we take the change of x with respect to time, so x dot, then it's going to be the velocity in the longitudinal direction, which in our case again is constant, right? And then if you have some kind of slipping and you have velocity towards the lateral direction, then that would just be the change of small y with respect to time or y dot. Now, for control, it's important to be able to represent these velocities, the longitudinal and lateral velocities in the global reference frame. So essentially what we want, we want the capital X dot and the capital y dot. So the change of capital x with respect to time and the change of capital Y with respect to time. And why is this important? It's important because our trajectory, It's described in the global reference frame. So if I take a random point here, then this point is described by this capital X and capital Y. So it's gonna be like this, x r and y r. So if you want to compute an error in the y direction, then it's like this. Y r minus the position of the car in the y direction in the global reference frame. So it's going to be capital Y. Now, in order to compute this. You need to know how fast the car drives in the direction of the capital Y, right? In other words, you need to know the velocity in the direction of the capital Y. And that's why you need it. And also, if you had another system and you needed to calculate an error in the x direction, then it will be the same thing, XR minus capital X. And in order to compute capital X, you're going to need to know the velocity in the direction of capital X. But what you have, you have the longitudinal velocity. And if you have some slipping, then also lateral velocity. So you need to transform. You need to decompose these two vectors. And you need to transform the longitudinal and lateral velocity onto the global reference frame. And you do that like this. I'm going to show you, Let's say you have your longitudinal velocity here and your lateral velocity here, right? So we assume that it's pi over six radians. So it's 30 degrees. And I'm going to put the angle here is 30 degrees. Well, actually it's better if I don't put it here because I'm going to decompose this vector. So the x component of v x is this, the y component of V x is this. The x component of v, y is this. And the, the y component of v. Why is this? So, in order to compute capital X dot, right? What do we have to do? We take Vx, which is our constant longitudinal velocity, which was 20 meters per second. And we multiplied by cosine pi over six. Because then we get this component of the vector, right? And then we have to subtract v y times sine pi over six. Why do we subtract it? Because here, the velocity vector in the lateral direction produces a component in the x direction, in the negative direction, you see. So in the first case, you had a positive component in the case of Vx, but in the case of v y and negative component is produced and that's why you subtract. And now it's going to be an exercise for you. I would like you to pause now and try to find an equation for y dot.
14. Setting stage for the car's lateral control 4: hope you tried it yourself. So the answer here is the X, which is this vector here and now You need to get this vertical component, and you get that by multiplying Sign pi over six. And now do you need to subtract or hat? Well, in this case you need toe at, because now both of the components are upwards. Right? So you have tow ad V. Why? Times course, sign by over six. Right. And again. Now you add, because now this the Y vector produces an upward component. And there you have. That's how you go from the body frame to the global inertia frame. That's how you transform the velocities in the body frame to the lost this in the inertial frame. Okay, so this is it for now. And in the next video, we're going to start building the open loop mathematical model for our car. And then after that, once we have the small, we can start designing our MPC controller to control our car. So thank you very much and see you in the next video
15. The general control structure for the vehicle's lateral control: welcome back. So now that we finally have all our fundamentals in place, we can finally start deriving a mathematical mall for our car in the lateral direction. So remember, we only consider lateral motion in our case. So if we have a car here, this is the top few than the latter than direction would be in this direction. And the longitudinal direction would be like this. So the course longitude, you know, the lost their forward velocity would be in this direction. And then this is the lateral direction in our model is gonna describe motion in the lateral direction. Now this model is called plant or also open loop system. And we need that now in order to later on design our controller because our controller will be designed and tuned based on the model here. And that's why it's important that the model that we're gonna derive here will represent the reality as closeness possible, or at least as closely as necessary, because you can always go more specific and more precise. But then your models will also go more complicated. So sometimes you have to make a trade off between how complicated you want your mall to be versus how easy wanted to be and the precision. So sometimes, when you don't need that much precision, then your model could be simpler. When you need a lot of precision, you need a model that is more complicated and essentially what this model is trying to achieve. It's trying to relate the system input with the system outputs. Okay, so our system input, which is a steering wheel angle. If that goes into a model, when we get something out of our model, we should get our outputs out of the mall, right? So essentially we need to find a connection between our outputs. For example, are why, as a function off Delta in our your angle, also as a function of Delta.
16. Car model VS simplified bicycle model 1: very often when people designed controllers for their vehicles and when they build a mathematical model for the car. Very often they use a simplified version off the mall, which is a model for a bicycle, so they're using a bicycle model to design a controller for their car. The reason for that is because the bicycle mall makes designing the controller my simpler, but it turns out that the bicycle mall still represents the cars, dynamics well enough that it enables people to design their controllers reliably. So that's why, in many cases, when not too much precision is needed, people in order to design their controllers instead of, ah, often entire vehicle, they use a bicycle mall as their mathematical model to describe the inputs and the outputs off the car. So, in other words, instead of building a mathematical model for a car with four wheels, two in the back and two in the front instead of building a plant, more for that we're going to build a plan model for a bicycle. And in order to do that, we're going to take the two front wheels off the car and we're going toe, lump them into one big front wheel for the bicycle, and we're gonna do the same thing for the rear wheels we're going. We're going to take the two back wheels and we're going to lump them into one back wheel. And finally, we're going to add a center of mass here. And so no, this is a bicycle or a motorcycle. It's a two wheeled vehicle, and this is what we're going to build our mathematical model for, which will take in our input, which is the steering wheel angle. And then it will return us the Y coordinate and the euro angle and the steering wheel angle here would be, then, by turning the front wheel right. So if we turn the front wheel than the steering wheel angle would be this one. Nevertheless, I want to treat a couple off differences that a car model and a bicycle mole half, so I'm gonna do it on this side of the page. So let's assume that we have a normal car, right with four wheels, so two wheels in the back and two wheels in the front. So now if I want the car to turn right, then the very first cars that appeared against around 100 years ago. The way they turned, they turned the entire front axle rights of this entire front axle came like this. So these are the two front wheels. And so you had some kind of angle here. And so if you draw a line perpendicular early from the back wheels, right and it's perpendicular to the back wheel and then you draw another line from the front wheels also perpendicular early. Then at some point these two lines meet, right, so this is also perpendicular. And so we're gonna call this point are. And so this point where these two lines meet. That's the instantaneous center point around which the car is driving. And so if the angle off the front axle doesn't change than this instantaneous center of rotation this point are won't change either. So the car will simply be driving in circles around this point. OK, and this point doesn't change. And so the distances here won't change either, right? So let's call it are back. This is the distance and our front. So is the distance from our till the wheel. They won't change, However, if I now change the angle off the front axle and I make it, let's say smaller, right? Then if I draw a new line from the front wheels, then you will see that the center off rotation, this instantaneous center of rotation, will change. It will be further away. All right, So obviously, if that this is all instantaneous, if at time equals zero seconds, you're actually is like the red one, then you. Then you're turning his sharper, and your center for off rotation is closer to the car. But then, if at time, because one second you decrease the angle off your front axle, then your your center of rotation will be further away from the car, which means that you're turning will not be as sharp.
17. Car model VS simplified bicycle model 2: now, the problem is that making this entire axel turn is not mechanically very efficient. So another option would be to, for example, turn two wheel separately. So something like this, you have your back wheels here, and this is your front axle. And let's say that both off our front wheels, they are turned and the angle at which there turned are equal. So let's say this one is turned at angle Delta, and also this front wheel is turned at angle delta and they're equal so we could do it like this. It would be easier. But then look what happens if I draw a line here and then I draw a line from this wheel here, and then I draw a line from this wheel here. Then I'm gonna have to instantaneous center points. So what does it mean in real life? It means that when the car tries to turn than at least one wheel, if not, both will be slipping. And that's not good for the tires. That's not good for efficiency, so it's better to avoid that. So what would be the solution for that? How can you turn these two wheels without turning the entire axel in such a way so that you would only have one instantaneous center of rotation. What would be the solution for that? Post the video for a second and tried to think about the solution.
18. Car model VS simplified bicycle model 3: the solution for that is actually quite straightforward. So I'm gonna draw a car again, these air, the two back wheels and two front wheels. And so if I want to turn to the left, then if I turn my first front wheel, the inner front wheel. If I turn it at an angle delta and then I turn my outer front wheel. Also, it's some kind of angle, but that angle will be different and less okay, different and less. Then look what's gonna happen if I choose the right angle. And let's say it's an angle Alfa. If I now choose the right angle Alfa, there is one angle that is the right angle that will give you one center of rotation. So if we draw a line from here and then from here, and if this alfa angle is correct, it has to be smaller than the dealt angle. But if it it has the right magnitude, if you draw a line from here, then you will actually converge and you will have one single center off rotation, right? So that's how more modern cars drive nowadays and okay, in real life, it's not ideal in real life there are almost in the same place because nothing can be 100% a deal. But, uh, they're almost ideal. But that's the logic. So if your front, if your front wheel, you turn it by Delta, then if you turn your outer front wheel by a smaller angle. If you know the right angle, then you will have one center off rotation, and then you can avoid the inefficiencies, like tire slipping on the ground and center. So this is actually one of the things that the bicycle mull doesn't take into account right , because in the case of a bicycle model, you only have one front wheel. You only have one back wheel, so in the case of a bicycle, you have your back wheel and you have your front wheel, which is turned by an angle delta. And so if you have a car and you use a bicycle mull, then you're not taking into account this effect that the two front wheels they turn at different angles. However, the difference between these angles between Delta and Alfa they're usually so small that for many cases it doesn't matter. For many cases, you can neglect it and still use the bicycle model. But that's one of the differences that I wanted to to know
19. Ackerman Steering: But now let's say that you have found your delta using your bicycle mall using your NPC controller, and now the question is, how do you apply it to a four wheel car? How do you go from here to here? Will one way toe approximate ideal steering, which is having to steering wheel angles that are different, such that they form one instantaneous center flotation, and this is called ideal steering. One way to achieve that is to use Ackermann steering. It's a clever mechanism toe approximate ideal steering, and it looks like this. So you have three pictures here, and you can see this trip is a little shape here. So when the car starts turning, then this mechanism allows the inner wheel to the rotation to make the steering wheel angle larger and then automatically the outer wheel will have a smaller steering wheel angle, and it applies when you rotate to the left and when you wrote it to the right. So here you can see that Delta one is bigger than Delta two, and here Delta one is smaller than Delta two, and this mechanism approximate PSA deal steering. It's not ideal, but it approximates it. So the delta that you get from your MPC you can assign it either to the left wheel or to the right wheel, and then the other one will have a slightly bigger or smaller delta, depending on the turning direction.
20. Longitudinal & lateral velocities of the bicycle model 1: Now, if we want to make our bicycle mall rotate, then we have to do the following thing. I'm gonna draw bicycle here, and this is the back wheel here and the front wheel, and we're gonna make the front Will turn. Now, in order to find the instantaneous center of rotation, we followed the same logic. This is the center of mass. So we're gonna draw a line from the back wheel and also from the front wheel perpendicular early and wherever they meet, that's your center of rotation. All right, we're gonna call this point, are all right? So the bicycle rotates around this point for his longest. This front wheel is turned at an angle. Delta. All right, Now, do you remember when we had a car? Then we said that we have a body frame that would be attached on the top of a car. Right. So if I'm gonna draw a top few off the car and now I'm gonna put a body frame on top of it . Then we said that when the car drives and then makes a turn, then the car will mostly drive in the logic cardinal direction in the direction of the small X and not in the direction off small. Why? Unless they re slipping Now, this is true. If you have really simplified your situation, however, now we're gonna dig a little bit deeper. So I'm gonna show you something. If you look at this bicycle, right, I'm gonna show you that when you turn, there actually is a little bit off lateral velocity in the direction of the small. Why? First of all, let's define our body frame. Our body frame for the bicycle would be like this. This white line, the body off the bicycle. It would be the longitudinal direction. All right, so this would be our small X. So it goes along the white line so the lateral direction would be this one. Right? So this would be small. Why? So that's how we define our longitudinal and lateral direction For the bicycle, the longitudinal direction goes along the body of the bicycle and perpendicular to it. You have a lateral direction. Okay, but now this front wheel, it's the last e is in this direction, right? And the back? Well, its velocity goes along the longitudinal direction. All right, so if you know think about it then. If you go from the back wheel to the front wheel, then then whatever point you take on the bicycle, whatever molecule or atom you take on the bicycle, right? The motion off that molecule does not go directly along the longitudinal direction. It has to go something in between this direction where the back wheel goes in this direction where the front will goes, meaning that as you go from the back will to the front wheel the direction of the velocity off that point on this bicycle is something in between this the back wheel and the front wheel. So here, since you are closer to the back wheel here, the velocity of this point, it's not exactly in the direction of the longitudinal direction, but it's it's almost in that direction. So it does have a small angle right now. Here, you're much closer to the front wheel, the direction off your velocity. At this point match is more the direction of the front wheel. So it's gonna be maybe something like this. Okay, something like this. And no, When we are here at the center of Mass, then here also this point here. It's direction. It is something in between the back and front wheel. So this point here actually travels. Maybe something like this. And since it's the center of mass, this angle here has a special name. It's normally denoted with better, and it's called a slip angle off the vehicle.
21. Longitudinal & lateral velocities of the bicycle model 2: So when you create a model for this bicycle, you have to know that the center of mass of this bicycle not only travels in the longitudinal direction, but it also has a lateral component. So in the past we talked that this car of ours would travel longitudinal e at the constant velocity. And I think we said that it waas 20 meters per second. So this constant longitudinal velocity, it's this one is this component because we define our longitudinal direction along the body of the bicycle. However, when you build the model for your bicycle, then you will see that there will also be some kind of velocity in the lateral direction. All right, now, this velocity, even though it seems quite big here, this velocity will be very small compared to the longitudinal velocity. However, it will not be completely zero. Now, one more thing that I want to show you is this. Now, if you look at these red lines here, these red lines, they are perpendicular early to the wheels, right? So a good way to think about thes other points on the bicycle? Is that okay? If you want to know in which direction at a certain point on the bicycle travels right then , assuming that the front wheel will keep its steering wheel angle constant. Assuming that you're not going to change that angle, then obviously the bicycle would be travel in circles than in that case. You can draw a line from this instantaneous center of rotation right to that point that you're interested in. And it has to be perpendicular, right? And then you will know in which direction that particular point on the bicycle is traveling . So in this case, we could draw a line till here, so here you would have a 90 degree angle and we can also do the same thing with the center of mass. I'm gonna make it red. We can draw a line here to the center of Mass, and you guess it. It will also be perpendicular here. So when you have your center off rotation, right then each point on the bicycle it's velocities in the direction that is perpendicular to the line that leads you to the center of rotation. Also, what we can do, we can formulate the angles that the velocity vectors make with the bicycle. We can formulate them mathematically. So let's say that the angle between this lost a vector and the longitudinal axis is feta one, which is zero radiance. Then let's say that this angle here is Sita to this is beater. This is feta three and this is Delta. And so we don't have to worry about the exact values. But the logic is this Sita one is the smallest angle. Then you have Sita to then you have Peter. Then you have theater three, and finally you have dealt.
22. Equations of motion in the lateral direction: So now let's connect the car's input. The Delta steering wheel angle with its outputs, which are the y co ordinate and the cars your angle. So to create this mathematical mall were first gonna write down the equations of motion. What are the equations of motion, by the way? Well, I'm gonna explain to you this way the equations of motion our equations that connect all the forces that are applied toe on object to its acceleration and also all the moments that are applied to an object to its angular acceleration. All right, so essentially the equations of motion our equations where on one side off the equation sign you have the some awful the force is applied. And on the other side of the equation sign you have mass times acceleration, and then you have another equation where one side off the equation sign you have the some of the moments, right. And on the other side of the equation sign you have the mass moment of inertia times the anger acceleration off that object. Now, if you look at the bicycle here, then you can see that here the distance from CME center of Mass to the front wheel is LF and the distance from CME to the back wheel is LR and since we're dealing with the lateral control, then we're gonna consider the forces in the lateral direction. So when the front wheel turns at an angle delta, then due to friction with the ground, you will have to lateral forces one coming from the front wheel and one coming from the back wheel. So these are the two forces. And so what we're gonna do now we're gonna write an equation, an equation of motion for the lateral direction. The question of motion in the lateral direction would be then the some of the forces in the lateral direction equals mass times acceleration in the lateral direction. Now the equations of motion. They don't have to be Onley in the global X or global y direction. They can also be in the longitudinal or in the lateral direction. And since it's lateral control, we only considered the lateral direction. We don't consider the longitudinal direction, so it would be then f why are plus if why front equals mass times acceleration in the lateral direction. Now, this is not all because we also need to consider the moments right because this bicycle it doesn't only translate. It also rotates. So that must also be some moments involved. So oppose the video for a second and try to write down an equation off motion. But for the moments
23. lateral & centripetal acceleration: Okay, I hope you've tried it yourself. So for the moments, we also need some kind of convention. And the convention is that if something rotates counterclockwise, then it's positive. And if something rotates clockwise, then it's negative. So in this case, the moments in the karaoke clockwise direction would be positive, So the counterclockwise moment would be f Y f right times a left F Why f times LF all right , so that makes the bicycle rotate in the counter clockwise direction. However, there's another moment, which is f y r times and large. However, this component off the moment f Why are times l. R makes the bicycle wrote it in another direction clockwise. And that's why it's negative. So you have to subtract f why or times l R. And that equals the mass moment off inertia. And instead, off alfa double dot we can very simply right upside doubled up because here are young angle ISPs. I so upside That would be radiance per second, right? It would be the angular velocity. And so the angular acceleration would be side double dot which is radiance per second squared. All right, so there you have it. These air your equations off motion and from this from these equations, then you will continue working to find the relation between Delta and then the euro angle and the Y coordinate. Now let's talk a little bit about the acceleration in the lateral direction. A sub small. Why? Let's unpack it. So, in fact, the acceleration in the lateral direct direction has two components. It has to contributions. One contribution is small. Why double dot So it's ah, it's the change off the lateral velocity. So because off the slip angle right, you have some kind of velocity in the lateral direction, which is why dot and so if you take the derivative of why dot with respect time, you get why double dot right, so it's the change off lateral velocity. With respect to time. However, there is another component to it and this component is called the centripetal acceleration . And so the centripetal acceleration we can write it down like this ex dot times side that so the change off longitudinal the lost it with respect to time times the change off your angle with respect the time now Now you might ask that Wait a minute, didn't we say that the longitudinal of the last days constant. Yes, it is constant, but it's constant in the body frame, so it's always constant in the in terms of magnitude. However, remember the acceleration doesn't only appear when you're magnets. Changes also when you're direction changes. So if at some point in time your longitudinal velocity, which is, let's say, 20 meters per second. If at some point it's like this and then at another point in time it's like this, right? It's still 20 meters per second. But in this inertial frame right in this global frame, the direction off this vector has changed. Even though the magnitude is the same, the direction of this vector has changed and therefore you also have acceleration. And that's actually happens when when something is turning right. So when you have ah, roller coaster, right, and then you have some kind of train, some kind of role train then as this role, of course, that goes along that along the rails. Right? Then you have some kind off centripetal acceleration into the circle. And so this is this is the second component that you need to take into account in the lateral acceleration. And it makes sense because because your bicycle is turning right, it's the trajectory is something like this. So So since the bicycle is turning, you have to have the centripetal acceleration. And in fact, it's the centripetal acceleration that makes the bicycle rotate right, because the centripetal acceleration appears when you have forces in the direction off center of rotation, right? So in this case, you have the normal force from the track that is pushing the train to change his direction , right? It's magnitude might be the same, but its velocity vectors is changing because its direction is changing. So the force and therefore the acceleration is towards the centre off rotation. And here, in this case, you have the friction forces that do the same thing and make the bicycle rotate. So, without friction, right without friction, this bicycle wouldn't be ableto rotate it. Ah, it would just slip. I don't know. Maybe in this direction
24. centripetal acceleration intuition & mathematical derivation 1: Now, why is it that we can write down the centripetal acceleration like this in this four? Well, if you look at this bicycle here, then if you want to calculate the centripetal acceleration of the bicycle, So right now this is the center of mass, and this is the instantaneous center of rotation. And the distance between a the center of mass and this point is, are so it's like the radius of a circle. Right? So if you have some kind of circle of motion, right, then that would be your center of rotation. And this would be your are as your object travels in the circle. And so, if you want to calculate the centripetal acceleration, you would take this V here, right? Remember, you have the slip angle here, the slip angle off the vehicle. You take this V, you square it, and you're divided by R. And that's how you can calculate the centripetal acceleration off the vehicle in this point . Now, the thing is that in the lane changing problem, the turns air so small and therefore the slip angle, they're so small that we can simplify our problem and we can neglect it. and instead of V, we could just write are longitudinal the lost here so we could write it down like this Small ex dot squared, divided by are So it's a simplification because the slip angle is just so small that instead off using V, we can just take our constant longitudinal velocity. That doesn't change in magnitude but changes in direction. And we can approximate our centripetal acceleration like this when you have an object moving in a circle and this object has some kind of velocity, and this is the center of rotation and this is the distance. Then you can calculate the angular velocity off the object like this. The equals the angular velocity. Let's say that it's feta dot In this case, times are right and the theater dot is in radiance per second. And if you multiplied by the radios, then you get this velocity, which means that you can calculate theater dot like this the divided by R right. And in our case, we have side out right. Therefore, side dot equals small ex dot divided, but our so in that case, we we can also write that our small ex dot are longitudinal velocity is side dot times are right. And so now since here we have this small X does squared divided by r we can also write it down like this extort times x dot divided by are And so what we can do we can just substituted like this side ought times are times x dot Delighted by our so the ours cancel . And there you go you are left with this expression. So this is your centripetal acceleration. Well, it's to be more precise. It's an approximated centripetal acceleration because we forgot about this slip angle here . And so just to make clear why, why we could have this kind of relationship where the velocity equals their rotational velocity Times are it comes from this fact that when you have this circle here, right, and you have this angle sita, which is in radiance and then this is this part of the circumference at the entire some conference, but part of it, And so this distance D on this ark, you can calculate if this is our that this distance d you can calculate d equals r times theater, right? So when theatres in radiance and you multiplied by the radius of the circle. Then you get the length of the ark. No, If I now take the derivative off the then essentially it's this velocity, right? So it's the change of the with respect to time. And now you have this multiplication rule, right? So you first of all have r dot feta plus, yeah theater that it comes from calculus, the multiplication rule. And so since the race is constant, the radius doesn't change in time. So this term is zero. And that's why you're left with de dot or V equals Oh, are Times Theater that which is essentially in our bicycle example Side that your dot And so finally, when you know, look at this part of the equations off motion, right, that you can rewrite it like this f why f plus f Why are equals m? And instead of a y, we can rewrite it like this. Why double dots plus small ex dot side dot and then this equation in this equation is then , for the moments
25. Centripetal acceleration intuition & mathematical derivation 2: Welcome back here very quickly. I want to explain to you better why the lateral acceleration equals y double dot plus x dot times psi dot. So you have a vehicle that goes from configuration one to configuration two. You can work either in the inertia frame, which is fixed to the ground, or body frame which is fixed to the vehicle. And so when the vehicle rotates, then the body frame rotates with it. And due to the fact that the body frame rotates with the vehicle, we chose to work in the body frame because it simplifies our equations. If you go from configuration one to configuration two, and the magnitude of y dot stays the same. And by magnitude, you could think of it as the length of the arrow. If from this configuration, you go to this configuration and the length of the arrow Y dot stays the same, then that means that y double dot equals 0 meters per second squared. That is because even though the Y dot vector changes its direction in the inertia frame. In the inertial frame, it was first like this, and then it was like this, as you can see it here. So here you can see that the magnitude of y dot didn't change. And actually the vertical component of y dot didn't change that much either. But what changed was the horizontal component of the vector. And so you can see that in the inertia frame, the direction of y dot did change. But in the body frame, it hasn't changed its direction. In the body frame, the direction of y dot is still the same. And that is because x dot and y dot vector are attached to the body frame. So here you have your x dot, y dot, your x dot, and y dot. So the x dot and y dot, they rotate together with the body frame. So the term y double dot appears when in the body frame the magnitude of y dot changes. For example, if in the first configuration that was your y dot, and then in the second configuration, your y dot. Becomes bigger. That's when your y double-dot appears. But if the magnitude of y dot doesn't change, then y double dot will become 0. And that is because you're, again, you are working in the body frame. If you had worked in the inertia frame, then also the change of direction of y dot would matter. And then even if the magnitude of y dot had stayed the same, still, you would have had a change in this vector. But we worked in the body frame. And so the presence of Y.me per second indicates that there is a bit of slipping in the turn, which can be so small that you might not even see it. And y double-dot meters per second squared indicates that this slipping has gotten bigger or smaller. The other term, which is this one, which is the centripetal acceleration term, appears because the body frame is rotating with respect to the inertial frame. If the body frame didn't rotate, the second term would be 0 meters per second squared, because psi dot would have been 0 radiance per second. And so this term would have been 0 meters per second squared. So in conclusion, a sub y equals y double dot plus x dot times psi dot. This first term, y double dot, is the change of the y dot vector in the body frame. In other words, it is the lateral acceleration of the vehicle, assuming that the body frame is not rotating. But in reality, the body frame is rotating. So you have to add the centripetal acceleration to account for that rotation of the body frame with respect to the inertia frame. So this is like a correction factor. It accounts for the fact that your body frame is rotating with respect to the inertia frame. This first term assumes that you're not rotating. And the second term takes into account that you are rotating. And it makes sense because the centripetal acceleration makes objects rotate. And if you attach a body frame to the object, then that means that the centripetal acceleration makes the body frame rotate as well. That is why you have two terms here in this lateral acceleration. Again, if you had worked in the inertia frame, then even if the magnitude of y dot had remained constant, then y dot in the inertial frame would have still changed its direction towards like this. And now it's like this, and that's your change, let's say delta y dot. And then in the inertia frame, you would have had y double dot. And so that's why you also have acceleration when your velocity vector changes its direction, but does not change its magnitude. Because when your velocity vector changes its direction, then that means that there is some kind of change in the components of your velocity vector. And also, if we had worked in the inertia frame, then the second term would have been 0. But then you will have had to consider acceleration forces both in the inertial x and y direction. So in the inertia case, this would be your inertial reference frame. And then you would consider forces in the x direction and also in the y-direction. And so you will have had acceleration in the x-direction and also in the Y direction. But since we work in the body frame and we only deal with lateral control on a straight road in a lane changing maneuver, then we can only consider the lateral forces and accelerations. So that would be your net lateral force or the sum of the forces in the lateral direction and the acceleration in the lateral direction. However, since the body frame itself rotates with respect to the inertia frame, then you have two terms. You have one term which is d y dot over d t, which is essentially your y double dot. And that is the lateral acceleration assuming that the body frame is not rotating with respect to the inertia frame plus the centripetal acceleration that makes the object and therefore the body frame rotate. And that's why our lateral acceleration had these two terms. The second term accounts for the body frame rotation.
26. centripetal acceleration intuition & mathematical derivation 3: Finally, I want to show you why the centripetal acceleration is a sub c equals V squared over our. Have you ever wondered why it's like that when you travel in a circle of motion and let's say this is a circle and you're here and then your velocity is in this direction? Have you ever wondered why the centripetal acceleration that points towards the center of the circle? Why, this thing is v squared over r. I don't want you to take anything for granted. So I'm going to show you why it's like that using calculus. So let's say that this is your center or region here in the center of the circle. And then you have some kind of body, their travels at the fixed velocity, the and then when I say fixed velocity, I mean the magnitude. So of course, the direction of the velocity changes, but the magnitude off the velocity stays the same. Now, if this is the center off our cordant system 00 and our accordion systems here big X and big, why? And if we say that this is the origen so the excess zero and then the Y zero here as well Then week and 1/2. Ah, position vector from here, That goes until the body that travels in a circular motion. So this position vector here represents the position off this body with respect to this Origen and we're gonna call this position vector P arrow. We're gonna say that the magnitude off this position vector he's our and the magnet. It's off. Vectors are denoted with an absolute value. So if you take a vector and you put it inside an absolute value, then you say that it's the magnitude of that vector. So in this case, it's the length off this vector, and the length of this vector is our. We also said that the magnitude of the velocity vector is constant so we can write it like this. It means that this body here rotates at the fixed rate. It doesn't wrote it faster and it doesn't rotate slower. It rotates at a fixed rate at the fixed radiance per second. Now, if the magnitude of the velocity is constant, then you can also write it like this. De the absolute value off the lost E with respect to time equals zero. And this is a calico's way to say that something is constant because that means that the magnitude off the velocity vector doesn't change in time. The change of this magnitude is zero, and therefore the variable itself, which is the magnitude of the velocity vector. The variable doesn't change, but okay, let's decompose this position vector. Now this position vector in this coordinate frame has an X component and the y component. And let's say that you have an angle Sita here. That means that we can rewrite the position vector like this P arrow equals are which is the magnitude of the position vector times Cool sign, Sita. And that would be the X component off the position vector the y component off the position vector would be our times sign feta. And so now we've rewritten it, ineffective for And then you can also take are out of the vector and put it here as a constant so you can rewrite this thing like this. Now if you think about it, what is of the Los de vector of lost? The vector is the change off the position vector with respect to time and so you can write it like this. The arrow equals D P arrow with respect to time. So you take the derivative off the position vector, but not the magnitude, but actually the vector. So you take the derivative off each component off this vector. So let's do it to take the derivative off this vector, we're gonna use the product roof from calcalist. So first of all, it would be d r d t times this vector. Go sign feta. No, here you would have sign theater plus are times. And now you take the derivative of this part here. It would be minus sign seater. However, you also have to take the derivative off the theater with respect time. So you use the chain rule, there's gonna be times de cita d t. And then here it's gonna be Coulson feta Times defeat. Er DT. Now the magnitude off the position with two r, it's constant. So again you can write it like this de absolute value, P. D t. And what do you think you would have here? Well, if it's constant, then it must be zero. But the absolute value of P is our and therefore it's the same thing. And so since this thing here is zero, then this entire term is zero. So you're left with are and then I'm gonna take defeat a DTs here, and I'm gonna put them here the feta d t. And then you would have minus sign theater and then call sign feta. And that would be your velocity vector. But now we also want the acceleration vector. And what would be the acceleration vector? Well, the acceleration vector is the change of the velocity vector with respect to time. So it would be de the arrow over DT. So we would take the derivative off this part here and again, we're gonna use the product rule. We're going to say that it's d r d t times de cita The t times this vector minus sign feta and co sign Sita Plus, then we leave our alone. We're gonna say it's our times. Now we take the derivative off this term here, this is gonna be the double derivative off Sita with respect to time de Sita, D t. And then again, this vector minus sign Sita and call sign Feta. And then Plus, we're gonna leave these two elements alone or de cita d t And now we're gonna take the derivative off. This guy here, this is gonna be mine ish. Co sign feta de cita the team. And here it would be minus sign feta times di sita DT. Okay, again, our radius is constant. So it's fixed. It doesn't get longer, it doesn't get shorter. And therefore this part here is zero, and that makes this entire term zero. Now, what is D feta? The tea? Well, it's angular velocity, right? It's this radiance per second. It's how fast this object rotates in a circle. And we said that since the magnitude of the velocity is constant and that means that this object here it rotates at the fixed rate, it doesn't rotate faster and it doesn't rotate slower. It rotates at the fixed rate. So there is no angular acceleration. If d C Todd ET is radiance per second than the double derivative of theater, with respect to time would be angular acceleration, it would be radiance, birth, second squared, and so therefore, since the object doesn't accelerate nor decelerate, then this part here would be zero, and therefore this entire term would be zero as well and So your left with Onley this term here and we can rewrite it like this. We're gonna take these minus science. We're gonna put them in front than are then these defeat oddities. We're gonna put them as a scaler in front of the vector as well. So it's gonna be times. And now it's gonna be like this D Sita DT squared because first of all, you had it when you computed your lost director. And now, when you computed your acceleration, you have another d c the D t in each element that you can put it in front of your vector as ah scaler. And then you have call Sign Sita and sign theater. And in fact, you can rewrite it like this minus de seater d t squared times are and then co sign feta and then sign theater. And now, if you look at this part here, then what was this part? Well, this part was the original position vector, right? It was this guy. Therefore, your centripetal acceleration can be rewritten like this minus de cita d t squared times p vector now in our vehicle. Example di sita DT waas your dot right it was radiance per second. Now, right now we have this acceleration ineffective for so this minus here, it gives you a direction, right? However, if we take the magnitude of this exhilaration, then it would be like this the absolute value minus de cita d t squared times p vector And then you close your absolute value. So if you put things inside the absolute value signs, then you can get rid of your minus sign. And so what you're really left with is something like this de cita DT squared. And we're gonna have another absolute values sign here. Witches, The position vector which we put inside the absolute values. And so this guy here it's nothing but our And so you have the angler velocity squared times are And if you remember, then our velocity waas in the vehicle Example why dot times are so In this case, it would be de cita de tee times are that means that de cita DT equals the over our And so the magnitude of the acceleration vector which is the magnitude of the centripetal acceleration, would be like this. It would be v squared over r squared times are you cancel out the ours and you're left with these squared over R and there you have it. You have the form off the magnitude off the centripetal acceleration. You can also do it in this way. You can say that this vector is this minus or de cita day T squared times call sign Sita and minus or de cita d T squared times sign feta. So now you have it in a vector form. And if you want to take the magnitude off your acceleration vector, then what do you do? You simply rewrite this thing like this. You would have a square root, then minus are de cita t squared course sign feta in this entire term is squared. So essentially you're taking the staggering and theory plus minus or de feta d T squared Sign theater and then this entire term will be squared as well, and you will have square root that will cover everything. You can rewrite this thing like this. You can factor things out, and in the end you can have something like this minus R D Sita Day t squared and then this would also be squared. And then you would multiply it by co sign Sita, which is squared plus sign feta, which is also squared. And I'm gonna put square with here, Closed the bracket. And now what is this? Well, this is a trigger metric identity, right? So this entire thing here would be one. It comes from trigonometry. This is a chicken or metric identity. So you're left with square root minus are de cita DT squared, and then this entire thing will be squared. And the reason why I rewrote this thing like this, I was just, uh, pure mathematics. If you factor these terms out and use the rules off mathematics, then you will get it in this form. And so if you take the square root off these guys here, you will be left with are times de cita DT squared. And we have already seen how to rewrite this form in this form. And there you have it. That's how you can derive this centripetal acceleration off a object that travels in a circle and who's radius or the magnitude of the position? Vector is constant and whose magnitude off the tangential velocity is constant. But the good thing about this kind of deprivation. Is that What if your radius is not constant? What if it changes? Or what if the object rotates in a circle faster and faster and faster, then here, in this kind of deprivation, you can take all that into account. So if the radius is not constant than this term will not be zero. Okay, when you compute your the lost the vector and also when you compute your acceleration vector. Then again, this term would not be zero. And if the object rotates faster and faster, that means that when you compute your acceleration, then this term here would not be zero. And so you can take into account allow the possible combinations. You will just leave these terms there and you'll see what the mathematics shows you and so thank you very much. And I'll see you in the next video.
27. Modelling the front wheel of the vehicle 1: Okay, so these are our equations of motion now, before the assumption that we made was that when we have a bicycle, then the velocity each wheel the last if each wheel is in the direction off that wheel. Right. So that was our assumption that has bean our assumption so far. However, this assumption is true when you have low vehicle speeds. But when you have higher vehicle speeds than you have de formacion And so what happens when you have higher vehicle speeds is something like this that this is your back wheel. Then this is your front wheel, right? So this is your longitudinal access. This is the direction off your wheel. So the angle here is delta. But now, because of tired deformation, what really happens is that you will have a velocity vector that the velocity vector off this wheel will not be in its there in the direction of the wheel. It will be somewhere in between the longitudinal axis and the wheel. So it will be something like this. Okay, so that happens at higher vehicle speeds because off tired information and when you turn, then the same kind of thing happens here even though your back wheel doesn't turn still because of tired deformation, the velocity off this wheel will be a little bit tilted in this way. All right. And so now we're gonna define to a new angles. We're gonna define an angle here and here. So this angle here, we're gonna call it Sita. The F f stands for front and this angle here, we're gonna say that it's Alfa if and this angle here is feta, the are and so are is the rear rear angle. No, this angle here, Sita VF is the angle that that you have between the velocity vector off the front wheel and the longitudinal axis. And now this Alfa F. This is a slip angle off the tire. Alright, slip angle off the tire. Don't confuse it with a slip angle off the vehicle. The slip angle off the vehicle. This is the center of mass. Then the slip angle off the vehicle was here. The slip angle off the entire vehicle. But this is the slip angle off the front tire and it is defined in the following way. Alfa F equals the steering wheel angle. Delta minus theater. The F all right. And how about the slip angle off the back tire? Well, actually, it's the same formula, but in this case, Delta zero. So Alfa are equals zero minus feta. And now the are which you have here. So that slip and go off the back tire is minus theater. The are so these are the new angles that we need to care about when we drive at higher vehicle speeds because there is tired deformation.
28. Rewriting lateral forces in terms of front wheel angles: now the slip angles are important because it has been experimentally determined that the four small slip Bangles they are proportional to the lateral forces. So when you have small slip angles, when this angle alpha F and also Alfa are when these angles are small how far fnl far when these angles are small, then they're proportional to the lateral forces. Which means that if why f IHS proportional to Alfa F and F why are is proportional to Alfa are which means that there is some kind of proportionality constant there. And in fact you can write down these forces in the following way. If why f equals to see Alfa f times the slip angle off the front tire and also for the rear force if why are equals to see Alfa are times Alfa are which is the slip angle off the back tire? No. What is this? See Alfa F and C F o R. Well, they are cornering. Stiffness is this is the corner stiffness off the front tire and this is the corner cornering stiffness off the back tire. And the reason why we have this factor to here and here is because remember we went from from a car model toe a bicycle model. So we have lumped two back wheels into one and two front wheels into one. And that's why we have this to here and here and again. This is valley for small slip angles. So if I write down and access here and I'm going to say that this is force right and this is the slip angle here, Alfa, then it would be something like this. So you see, there is this region right where the relationship is linear. So you have force and then the slip angle right. And here in this region, where the slip angle is small, the relationship is proportional. If you take an individual tire than a C Alfa F, it would be like a slope, Okay? And so what do sing? What would be the units off the slope? You compose the video for a second. So the units off the corner neck stiffness would be mutants per radiance. Which makes sense, because if f equals c Alfa F times the angle right? Then it would essentially be Newton Radiance times, radiance They would cancel out and you would have mutants which is the unit off the force. So remember, this is valid. This relationship is valid for as long as you are in the region off small slip angles off the tire.
29. Modelling the front wheel of the vehicle 2: now that we have expressed our slip Bangles. If our tires in terms of delta and then feta, VF and Sita we are we can rewrite our forces in the following way f why f equals two times , see Alfa f and then parenthesis Delta minus seater VF and also the rear force if why are equals to see Alfa are multiplied by parenthesis minus feta. The are so that's good that we can rewrite our forces in this way because now you see Delta right in our equations of motion. One of the variables that we need it was the steering wheel angle because that would be the input into our system. This will be the value that will be provided by the controller that we will ultimately design. Now the thing is that we still need to we still need to rewrite this angle and this angle in terms of other variables other known variables And so what are the known variables? Well, we have the longitudinal velocity. We have the lateral of the lost e, we have ah and left, which is this distance here we have LR which is this distance here, and we also have the rate of change off the your angle, which is this? So this will be now you're exercise and I'm gonna show you the solutions in the next video and the explanation. Try to write these angles feta, VF and feta VR Try to write them as a function off the's variables. You might not use all of them, but try to do it and then I'll see you in the next video.
30. Modelling the front wheel of the vehicle 3: Okay. Welcome back. So let's try to rewrite the's angles in terms of known variables. Sita, the F and Sita VR. So how would we do it? So let's look at the front wheel. So we have a longitudinal axis, right? And I'm gonna draw the wheel, which you will be here. Okay. Now our velocity is in this direction. Right? And this is the angle that we're looking for. Feta, the f. No, this is our longitudinal axis. This is the white daughters line. And so you can see that we have two components here. We have one component which goes along the longitudinal axis. Right. And we have another components which goes along the lateral axis. Now, what is the component along the longitudinal axis? Well, this is our longitudinal velocity right, which in fact, thes in our example 20 meters per second. So we have one component now there is another component, which is let's call it the L. For now. Let's just call it VL. So if our velocity here is this one and we want to express this angle, then what we have to do? We have to use tangent, right? We could say that let's say Dan Jin's seat of the F equals VL divided by x dot. Right now, the trick is to find Rielle. What do what would be real? Well, let's think about it. First of all, when your bike is driving and then let's say turning to the left first, your bike is here, right? And it has its two wheels, the center of mass. And after some time, the bicycle is maybe somewhere here. And so you have your well here and you have your wheel here. And this is your center of mess. Now what has happens? The center of mass has moved to the left, right, So that's the distance off the center of mass. Okay, that means that there is some kind of lateral velocity, right? So we know that if I draw a bicycle here, we know that in the center of mass there is a lateral velocity because this is the slip angle off the vehicle here. Right? And so because of that you have this lateral velocity, which is small. Why dot So one component off the l would be this small white dot but isn't the only one. Well, let's look at this point here Right now You're in this point. And now you are in this point center of Mass has moved from here to here. But the bicycle has also turned right. So this point here is not where the center of masses this point is further away. So there must be another component, right? And so this other component comes from the fact that the bicycle has been turning and the bicycle turns at the rate off side dot So the change of your angle with respect to time if you imagine that your bicycle is first like this and this is your center of mass And then let's say that the bicycle doesn't move anywhere. At least the center of mass doesn't move anywhere. But the bicycle has turned like this. Then how would you find velocity in this place? At the beginning? You are like this. And now you are like this, right? So now what would be the velocity in this point? Well, if this is L f right and you know how fast you wrote a, then this would be like the rotation, the rotation off a circle. Remember when we had the circle and then we had a radius, right? And then you had some kind off Be here, right? And you knew the rotational velocity. When I say feta dot right, then you could calculate this v by multiplying theater dot by our right b equals theater dot by our and the same thing here. So you can say that this point here, assuming that the bicycle is not moving to the left itself, assuming that the center of mass is not moving to the left, that the bicycle is only rotating this point here due to the rotation on Lee has a velocity off a left times and the rotational speed right, the rotational speed off the vehicle. So l f times side dot So even if the center of mass doesn't move anywhere, right, or maybe it only moves forward. So you have a situation like this and then a little bit later, a little bit later, you are somewhere here, and your center of mass is still here. It has moved forward, but it hasn't moved to the left. But the bicycle has turned because you maybe you have some weird wheels there. And so because of that rotation, this point here does have some kind of velocity, and this velocity is a left times sigh dot All right? And therefore, this VL that we have here it has two components. It has small. Why dot Plus a left times, the angular velocity off the bicycle. All right. Now, if we, for example, neglect this term right, if we make it zero if it doesn't exist, if it's zero, If you only have this, then essentially what it means is that your bicycle? Yes. After being here after sometime, this bicycle will be here, but it hasn't rotated. So this kind of motion would have happened because of this term. But because you also have rotation, you also need to consider this term and left times signed out. And so now you can compute this entire thing, right? You can say that tangent Sita, the F equals. And now the L is small white dots, which is the lateral velocity, plus the velocity off the front tire due to the rotation off the bicycle. Right, So your bicycle rotates. And because of that, this speed at the front tire is actually higher than than the speed of the center of Mass. And so all that you divide by ex dot and there you have it. Now, what about their rare velocity?
31. Modelling the front wheel of the vehicle 4: Now, how about the rare velocity? How about the velocity in the back? So the beginning you have your bike like this, and then your bike is like this. So this is your center of mass and this is your center of mass. So you have moved to hear the center of Mass has moved here laterally right now. When we looked at the front wheel, then you saw that there was a boost in velocity due to rotation the bicycle, right, Because the bicycle rotated like this, which means that the back wheel rotates like this. But now, if you're lateral velocity in is in this direction and the bicycle as it turns, it causes the back wheel to turn in this way. So there must be some kind of velocity in this way as well. So, in fact, in the case off the back wheel there is Ah, there's an effect that slows the total velocity down. All right. And well, how would you calculate it again? If this is L R. And you know how fast the bicycle rotates? Then you can calculate this rotational velocity were simply by multiplying l r. Times. The change of the you owe angle with respect to time. But now the resulting velocity that you get is in this direction. Right? So you have this small. Why dot Well, small white dot that is in this direction. But then you have this velocity that is in another direction because as the bicycle turns, this point turns and moves this way. Now, if you look at the back wheel, then in the case of the back wheel, you also have this tired deformation. And it also has two components. One is this and the other one is lateral. So the longitudinal component again is just a small X not, and the lateral component V l Let's say back would be then again, small wide dot because of the motion off the center of mass. But now you have this slowing down effect due to the rotation of the bicycle. So you have to subtract gonna be minus l r times your angle dot side out. And so that means that you can rewrite the rare sita angle the engines feta, the are rear, which is why don't minus l are times side dot So that's the VL part and then you divide it with a small ex dot And so if you want toe get these angles, then you very simply picked the arc tangent off these values, so it would simply be Sita. VF equals are 10 geant. And so you would just put this thing inside here and the same thing for this angle. Now, the thing is that we don't really like Arc tensions here, and we don't like them because at some point it's gonna make our model very complicated, more complicated than needed, because at some point we need to separate. Why dot and decide that and when they're inside an Arc Tangent function than it's a lot harder to deal with it. But luckily, if you think about our case, then what are we trying to do? We're trying to change lanes on a straight road, right? So and we're driving at 20 meters per second. That means that as we change lanes, our steering wheel angles would be very small. Now, when are steering wheel angles will be very small, then our feet of E F and feet of ER will be very small as well, and so we can have a small angle approximation So you feel Look at the tangent function, right? If you look at that tension function so you have Ah, an angle here, right? And so this is your tension function. So if you think about it for small seat angles, we can say that Tangent feta Let's say VF is approximately theater VF right? And the same thing tagines, feta the are it's approximately feta VR. And it's because of this because, like, this is your angle. Peter, let's say CTV have and this is Dan Gin Sita VF here, and you see the for small angles for as long as you stay in this period here and here, the relationship is almost linear, right? And that's why you can make this kind of approximation. Now, this is very good, because now, since we can make this kind of approximation, we can very easily right Sita the F equals Why dot plus LF side out, X not, and Sita VR equals why dot minus l r side dot divided by small ex dot Right now this is a much more convenient form because now when we put this inside Ramo, it will be much easier to detach small. Why dot and side out, and this is actually what is done very often in engineering. This is typical thing that is done there. We simplify where we can we lose a bit of precision, but in turn it will be much easier for us to design our controller. Avoiding Arc Tangent demands less computations by the computer, but more importantly, we will be able to rewrite our equation where we can separate our small y dot from the rest of the variables. So this is called Trade Off. This is something that engineers do all the time, where they can they simplify. But of course, when you do this kind of tricks, then you have toe no when they're valley. So in this case, it's only valid when our steering wheel angle and also our theater, VF and feet appear when they're small. So obviously, if you're somewhere, if you're somewhat here, then it's not valid any more than you get wrong responses. And that means that your mole is wrong. That means that your controller won't work properly, so you have to, Let's say, honor your assumptions. If you already create your model with these kind of assumptions, where you just neglect the engine and you just write it feta. Then you have to know that this is on Lee Valley for situations where your steering wheel angles and your feet angles were there small, just like with the sleep angles where you had your force, right? And then here you had your slip angle. So Onley for small slip angles. You could have this relationship where f equals two times cornering, stiffness, times the slip angle off the tire, right. It was only valid for small slip angles. If you have big slip angles, then then you cannot make this kind of assumption. Then you have to do it the hard way.
32. From equations of motion to state-space equations 1: All right, So now we have our equations of motion, and we have our lateral forces that we have described in terms off Delta and then these two angles in these two angles, we have been able to describe them in terms of known variables as well. So now you have a big exercise, and I'm gonna provide you with the solutions in the next video. But essentially, what we want to do we wanna put these equations of motion in the vector matrix for so your exercise will be the following. If I have a vector here and I'm gonna put here, why double dot and sigh double dot And then I'm gonna have a matrix, and then here I'm gonna have another vector, and I'm gonna right here. Why dot and sigh dot Plus another vector and delta. So you're exercise now is to fill in this matrix and this vector. Can you do that strike to do that? And then in the next video, I will show you how to do it.
33. From equations of motion to state-space equations 2: welcome back. So let's try to soul for this exercise together. I hope you tried it yourself is well. And so I have written all these equations back up here and also our objective. And so, essentially, this exercise is about variable substitution. So we're going to start with our equations of motion. So first, what we're gonna do, we're gonna rewrite our forces in terms off these variables here. And let's do that. So I m why double dots plus sign, not ex dot equals. And now I'm just gonna rewrite the forces, which is to see Alfa F Delta minus Sita v R. Plus to see Alfa are miners feta, the are okay. Now we have that. Now let's ah, open up this equation. We can open up like this m times. Why double that plus m times side out. X not equals. Now to see Alfa f times delta and now minus to see Alfa F times feet up. He now this is actually f right? It should be f so I made a mistake here. So this is f and then minus two. See, Alfa are times Sita V or Okay, so we have done that No, what we have to do? We have to substitute these angles with these variables here. So what I'm gonna do, I'm gonna leave this term here on this side, but this term will go to the other side. Miners m side dot ex dot No. I'm gonna write this term here minus two. See, Alfa F. And now I'm gonna put this part here, which is why dot plus l f side dot divided by x dot and miners to see Alfa are. And now this part here, why don't minus ill are side dot divided by x dot There you go. Oh, and we also need to add this term here, put it in the back. The reason why I put it in the back is because I went out to here. So too see Alfa F Delta. Okay, so now what we have to do, we have to open up these parenthesis here. First of all, what we can do, we can get rid of em. And here And that means that here we have toe added, and here we have to add it. And also here we have to add it. So you see, I'm with Why double dot here and that's what I need here. So why double dot equals minus beside that Extort no minus to see Alfa f times. Why dot Divided Buy em ex dot minus two see Alfa f times l f upside dot and divided him ex dot Right and same thing here minus two. See, Alfa are times y dot divided by m extorts And now be careful here minus and minus. So you have plus plus to see l for our times l r side dot hem small ex dot Comes here plus to see Alfa f delighted by am And you have Delta here Now we need to do we need to factor out Why dots and beside us, right So we can rewrite this entire equation. Why, that will not equals now The first thing is I'm gonna write down this thing here miners to see Alfa F divided by m x not and also have another term with why dot says can be minus two c Alfa are remember these air different corner exits Stiffness is so this is the front wheel cornering stiffness. This is the back will cornering stiffness and we divide that with em, ex dot And so we close the parenthesis and we have Why dot Here. So we have factored out. Why dot And now we have to do the same with a side out. So what do we have here? We can put it down like this. Plus parenthesis. We have one term here, which would be minus x dot Then this one minus to see Alfa f times l f divided by m x dot And here I have plus to see Alfa are times l r divided by m x dot And so this one has this variable here. So I have factored it out from all these three terms plus C two Alfa f divided by em and dealt. So now you can already see that if you look at this one since it's gonna be a two by two matrix than since this is why dot Here then, this entire thing Let's call it a. This entire thing will go here, right? And now this entire thing here, let's call it be, will go here. And of course, we could have simplified it by having a common denominator. But that's just mathematical formality. And so No, we have this. And now we have to find tomb or terms here. Oh, and also this one. This one is E. That's called E, and he will be here. And so here we will have something else as well.
34. From equations of motion to state-space equations 3: welcome back. So let's finish this exercise now and find the remaining parts of the matrix, which will B, C, D and F. So again it will be a variable, a variable substitution exercise and a mistake avoiding exercise as well. So let's see. Now we're gonna work with this equation of motion, right? The one with the moments and, uh well, it's gonna be similar. So I upside double dots equals and left. And now, instead, off this force, we're gonna write down this one times to see Alfa. If Delta minus sita the f All right. And now minus l r. And to see Alfa are miners Sita the are No, we can no make this a plus. And so now what we have to do we have to substitute these angles here again with the's formulas. So let's do that. So I side that will not equals l f to see Alfa f. So and left was the sense between the center of mass in the front wheel and l are was the distance between the center of master and the back wheel. So Okay, we can I can rewrite it like this. Put delta minus l f to see Alfa F. And now instead of this angle, I'm gonna write this one. So why dot Plus l f side dot divided by ex dot Right? And then plus are to see Alfa are. And now this angle here, which will be why don't minus l r. So I don't divided small X. Not great. So we have this now what we can do? Well, we can get rid of this mass moment of inertia here. If we divided on the other side like this, then we can put it here and here. And so the next step would be just to rewrite the entire thing and open up thes Prentice's okay. And again, we have to now separate or factor out these variables y dot and side off. Okay. And there you have it. And so what we can do? We can say that this one is C This one is dif and this one is f so C D f so see will come here. Do You will come here and f will come here. So there you go. We have taken our equations of motion. We have figured out how to write the forces in terms off delta or steering wheel angle and other variables. And now we have rewritten our entire system in this form where we have a love constant terms here because if you look at them, these Airil constant terms, they don't change in time, Right? A, B, C and D. So here have a, B, C and D and also e and F they they're all constant. They don't change in time, and that's also because we have a constant longitudinal velocity.
35. From equations of motion to state-space equations 4: if our longitudinal velocity was not constant than thes terms here A, B, C and D, these majors elements they wouldn't be constant either. Right? Because you divide everything by the longitudinal velocity. So the fact that it's constant, it also makes this matrix constant. And that is good as we will see in the future, because that will make the design off our controller my simpler and so so Justo make it explicitly clear you can get this form that we have here if you just do matrix vector multiplication, right? So, essentially, if you write the system out in a non vector matrix form, then it would be why double that equals. So this double dot equals a times why dot plus be times signed out, right plus e times the steering wheel angle and no you have signed. I will not equals see times why dot plus de times side dot plus f times built. Now the equations here have become pretty long, and perhaps now you're beginning to lose the connection with with the physical explanation . Well, just remember that that for example, why dots it's just the lateral velocity and side dot is just the angular velocity off the bicycle and delta is just the steering wheel angle off the front wheel side double nut. It's the angular acceleration of the bicycle. And then why double? That is just the change of the lateral velocity with respect time and so A, B, C, D, E and F. They are composed off all the information that we had given to her bicycle, for example, and left and l are there dimensions C, C. Alfaro, R and C R five. Their corner ec stiffness is eyes mass, moment of inertia and small x dot is the constant launched student velocity. So in the next video, let's talk more about this form. Let's talk about why we put our equations of motion in this form and why is it so good to use them to design controllers? So see you in the next video. Thank you very much.
36. The meaning of states 1: welcome back. So let's first talk about this format here. This is a very important form. It actually this format is used in this open loop section. So now I'm gonna try to explain to you what is it? What actually happens here in this open looper box? What actually happens here is integration, right? You get your input, which is the steering wheel angle, and you get your outputs and the way you get those outputs you integrate. And in the open loop system, the equations are normally in this format. And now what is so special about this format? Well, this format here is called a state space Equations. What are states based equations? State space equations, Our first order differential equations. It means that you have something like this. X one dot equals that, say a times. And now these air Just random things. So eight times x one plus, let's say, See time's X two squared plus and let's say de times x three. Cute right? And now so you have three variables x one x two and x three and now you have X two dot equals, Let's say C square times x one plus sign. These are just random examples sine x two and let's say he also have x three here. X ray dot equals f times x one cubed an insider So an example like this So f c squared a see the these are old constants. Okay. And you can see that here you have some nonlinear Garrity's. And, uh so a nonlinear function is a function which is not like this right. Leaner function would go through zero, and it would be a straight line function. But we also have functions that are not ah, linear like, for example, this one sign and also ex too cute and extreme cooped. So these are state space equations and as you notice their first order differential equations, right, So you x one you have x one dot That depends on x one x two and x three and x two dot in extreme dot and these state space equations, they can also have inputs, right? Like in our case, we have delta and then they can have Let's say you won, plus you one plus year to these air like system inputs like I'm delta here. Now, you might ask yourself that is our system a state space equation? Is our system a first order differential equation? And you might think that no, you have. Ah, why double dot here and side double does. Well, that's true. But you have. Why double dot with respect to why dot and signed a bill that will respect toe side. That so you have. Why dot And then you have why doubled us, right? And so you have side that and side double does. And so this could be like X one and this x one dot right? And this could be like x two and x two dot So actually, it is a first order differential equation with respect to the variables that you have here , which are why docked and inside that and these variables here, since it's a state space equation, right then these variables here, Why that? And beside that, they're called states all right, states. And now you might ask yourself what our states
37. The meaning of states 2: so the meaning of states in control engineering is that states are the variables that we need to describe how our system behaves so again, they are the variables that we need to describe how our system behaves. In our case, our system is the car and for example, why dot inside that right the change of lateral velocity with respect, the time and the change of your angle with with respect to time. They describe the behaviour off the car. They tell us the lateral and angular velocity of the car, and you can have many states like, for example, you can have a state like, ah, a temperature on the body of the car. Right. But is this information relevant to achieve our control? Object? Do we need to know the temperature on the body of the car? Well, not really, so we don't choose it as a state. We try to keep the amount of states at its minimum to keep things simple. So usually the rule is as much as needed, but as little as possible. And we try to simplify where we can like the small angle approximation. Do you remember this small angle apps approximation like tangent and then Sita, the F And then we said that it's just theatre the F Well, that's valid when the state of E f is small and so we can make this kind off approximation for as long as we honor this condition that this angle is small, we can make this kind off approximation. No knowing what the States are, this will be your exercise. And I'm gonna tell you the solution in the next video. Do you think we have all the states we need to control our car? So we have why dot and we have signed up. There are two states. They're here, right? And this state space equation. When you multiply these constants by the states and also you add your inputs that you also multiplied by some constants. Right? Then you get the derivative off your state's rights. That's why it's called the states based equation dead. Here you have your states and also your inputs. And when you multiply them by some constants and add them together, then you have the change of your state's right. You have the derivative, the first order derivative off your states. So that's why It's the first order differential equation, which is stay space equation. This is your state, and this is your state. This is your input and what you get. He's the first order differentiation off your state's okay. Why double that inside doubled us. So it's a system of equations system off differential equations, and in this case, we have the most general state space equations, which are called nonlinear states based equations. But then, later on, we will see that there are also leaner states based equations and leaner time in various states based equations and linear time variant state space equations. So I'm gonna talk about it in the next videos as well. But now again, your exercise is this. Do you think that we have all our states, or do we need some more states to describe our system here to achieve our goal? Right. So we have a road, we have some kind of road, we have lanes and we want toe achieve the lane changing manure, which is following this trajectory. Do we have all the states? We need these two states to achieve that soon and next Video
38. Adding extra states to the system: welcome back. So in the previous video, the question was that Do we have enough states to control our system, which is our car? And the answer for that is no. We don't have enough states for that. Because remember, we also have our outputs global why? And sigh right? These are our outputs. We compare them against the reference values. Why are and sigh are right. So these air out outputs now normally the way it works is that the outputs are just the states that you choose. So let's say if my states are why dots and sigh dot and then also sigh and why? And I say that these air my outputs. So right now I have four states. But I say that okay, I need to outputs because I have to reference let's say data to reference variables that I need to compare it against. So I have global Why are and why are so I need to outputs why MP's I and I have four states and out of these four states I choose to states and I said that they're my outputs. Okay, But that means that we need more states right? Right now we only have why dot and beside that. But we need to sigh and why? So how do we incorporate these missing states into our existing state space equation? So a standard procedure is like this. You do it through variable exchange. All right, so or variable substitution. So let's say our first date is small. Why dot and let's call it X one right now. Our second state, Let it be side. This is what we need, right? We don't have it, but we want to incorporate it into our existing state space equation. So our second state ISPs I we say it's X to our third state is a side that and we say it's extremely and then our fourth state would be the global. Why and we say it's x four. So now our states are x one x two x three and x four. Now the states based equation is a set of equations or a set of differential equations. Where on their side, off the off the equation sign you have the first order derivative of your states. So now if I take my state x one and and I say that x one dot then what would be my ex one dot Well, it would be Why double dot right, because X one is why dot So x one dot is why double that? So x two dot would be signed out. What about X three dots? Well, it would be signed double that, and then x four dot would be big. Why dot OK, and so now what we can do, we can rewrite our states based equations in the following way, can do it here. So instead of these variables that we had before, we're gonna use our new variables. So x one dot And by the way, these exes, they're completely different fr