{"id":7853,"date":"2022-05-23T08:48:54","date_gmt":"2022-05-23T12:48:54","guid":{"rendered":"https:\/\/blogs.mathworks.com\/student-lounge\/?p=7853"},"modified":"2026-03-09T08:16:11","modified_gmt":"2026-03-09T12:16:11","slug":"simulating-trajectory-tracking-controllers-for-driverless-cars","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/student-lounge\/2022\/05\/23\/simulating-trajectory-tracking-controllers-for-driverless-cars\/","title":{"rendered":"Simulating Trajectory Tracking Controllers for Driverless Cars"},"content":{"rendered":"<div class=\"rtcContent\">\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Hi, everyone! In this blog, we will see how trajectory tracking controllers can be implemented in MATLAB and Simulink to make the vehicle follow a pre-defined path. Before we get started, a big thank you to my amazing colleagues, <a href=\"https:\/\/www.linkedin.com\/in\/barnesdavidj\/\">David Barnes<\/a>, <a href=\"https:\/\/www.linkedin.com\/in\/munish-02\/\">Munish Raj<\/a>, and <a href=\"https:\/\/www.linkedin.com\/in\/roshan-hingnekar-77201412a\/\">Roshan Hingnekar<\/a> for their efforts to build the content of this blog.<\/div>\n<h2 style=\"margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Motivation<\/h2>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">As a part of the Student Programs team at MathWorks, we regularly interact with students. During a few of these interactions, students suggested that similar to other <a href=\"https:\/\/www.mathworks.com\/academia\/student-competitions\/tutorials-videos.html\">Racing Lounge videos<\/a>, we should build some content on how to simulate bicycle models for path tracking applications. They also mentioned that it can be further utilized for lap time simulation models in Simulink. So inspired by the students and two of our powerful toolboxes, <a href=\"https:\/\/www.mathworks.com\/products\/vehicle-dynamics.html\">Vehicle dynamics blockset<\/a>, and <a href=\"https:\/\/www.mathworks.com\/products\/automated-driving.html\">Automated Driving Toolbox<\/a>, we decided to come up with a series of videos to demonstrate the workflow that can be easily implemented.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">That was the motivation that students gave us. Now, let&#8217;s check out the technical motivation!<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Trajectory tracking is one of the essential parts of autonomous driving where the goal of the vehicle is to control the lateral and longitudinal motion to follow a pre-defined path. For example, in the Formula Student Driverless competitions, the vehicle needs to simultaneously plan and track the path in the first lap. Further, in the subsequent laps, the vehicle tracks the optimized path at a much higher speed. Hence, the tracking accuracy of the controllers needs to be high to avoid major deviation from the path.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Currently, there are multiple control strategies to address the trajectory tracking problem. However, in this blog, we will focus on the following three trajectory tracking controllers:<\/div>\n<ul style=\"margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;\">\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Pure pursuit controller<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Stanley controller<\/li>\n<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">Model predictive controller (MPC)<\/li>\n<\/ul>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">To summarize the upcoming sections, we will first generate a reference trajectory. Then, we will build a vehicle model. Finally, we will show how easily we can implement the above three control strategies to control the longitudinal and lateral motion of the vehicle.<\/div>\n<h2 style=\"margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Reference Trajectory<\/h2>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">You can skip this step if you already have recorded vehicle pose data. However, If you want to generate a reference trajectory, you can use the <a href=\"https:\/\/www.mathworks.com\/help\/driving\/ref\/drivingscenariodesigner-app.html\">Driving Scenario Designer<\/a> app. The app enables you to design synthetic driving scenarios for testing your autonomous driving systems. In this case, we have utilized a section of the US Highway scene present in the prebuilt scenarios. Then, we have specified a vehicle and its trajectory and have exported the trajectory data to a MAT-file.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 593px; height: 402px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2022\/05\/May23_1.png\" alt=\"\" width=\"593\" height=\"402\" \/><\/div>\n<h2 style=\"margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\"><\/h2>\n<h2 style=\"margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Vehicle Model<\/h2>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">The accuracy of the trajectory tracking problem depends upon the vehicle dynamics model. Based on the fidelity of the vehicle dynamics model, you can decide which controller is best suited for different driving conditions. <a href=\"https:\/\/www.mathworks.com\/products\/vehicle-dynamics.html\">Vehicle dynamics blockset<\/a> provides a range of vehicle body blocks to implement vehicle models to calculate vehicle motion. In the model, we have used the <a href=\"https:\/\/www.mathworks.com\/help\/vdynblks\/ref\/vehiclebody3dof.html\">vehicle body 3DOF dual track<\/a> block where the tire forces are obtained from the <a href=\"https:\/\/www.mathworks.com\/help\/\/vdynblks\/ref\/combinedslipwheel2dof.html\">combined slip wheel 2DOF<\/a> block. Further, vectorized tire subsystem accepts the inputs from a simplified powertrain subsystem.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 543px; height: 605px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2022\/05\/May23_2.png\" alt=\"\" width=\"543\" height=\"605\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Now, in the subsequent sections, we have used the same vehicle dynamics model for all the controller models and these controllers will aim to generate the required steering angle, acceleration, and deceleration commands.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">To start with a basic longitudinal and lateral vehicle dynamics model, please check out this video tutorial:<\/div>\n<p><iframe loading=\"lazy\" title=\"YouTube video player\" src=\"https:\/\/www.youtube.com\/embed\/WID-MBOIIt8\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<h2 style=\"margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Controllers<\/h2>\n<h3 style=\"margin: 15px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;\">Pure Pursuit Controller<\/h3>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">As the first choice for implementing control strategies, we went ahead with the pure pursuit controller. In simple terms, it&#8217;s a path tracking algorithm that calculates the trajectory curvature to move the vehicle from one point to another. As per the formulation, you can compute the vehicle wheel steering angle to follow the reference trajectory.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 500px; height: 225px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2022\/05\/May23_3.png\" alt=\"\" width=\"500\" height=\"225\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">As can be seen in the steering angle formulation, one of the variables is the lookahead distance. In general, it is how far along the path the vehicle should look from the current location to compute the angular velocity commands. It is one of the important tuning factors in ensuring the controller&#8217;s tracking accuracy. A small lookahead distance can lead to an oscillatory path and accurate tracking whereas large lookahead distance results in a less oscillatory path, however, it might result in poor tracking.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 415px; height: 128px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2022\/05\/May23_4.png\" alt=\"\" width=\"415\" height=\"128\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Now that we have provided a brief introduction to the pure pursuit controller, the image below shows its implementation in Simulink.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 721px; height: 390px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2022\/05\/May23_5.png\" alt=\"\" width=\"721\" height=\"390\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">For the implementation, we have used the <a href=\"https:\/\/www.mathworks.com\/help\/robotics\/ref\/purepursuit.html\">Pure Pursuit<\/a> block that calculates the target direction angle based on two input ports, the pose, and the reference trajectory. In the block, you can tune the controller by setting the lookahead distance. Further, based on the above formula, the required wheel steering angle is obtained allowing the vehicle to follow the trajectory as shown in the figure below.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 387px; height: 382px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2022\/05\/May23_6.png\" alt=\"\" width=\"387\" height=\"382\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Reference video tutorial:<br \/>\n<iframe loading=\"lazy\" title=\"YouTube video player\" src=\"https:\/\/www.youtube.com\/embed\/zMdoLO4kRKg\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/div>\n<h3 style=\"margin: 15px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;\">Stanley Controller<\/h3>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Moving to our next controller, the Stanley controller was implemented in the <a href=\"https:\/\/ieeexplore.ieee.org\/document\/4282788\">DARPA Grand Challenge by the Stanford Racing Team<\/a>. It is a nonlinear control law to minimize the cross-track error and the heading angle of the front wheel relative to the reference path. It computes the steering angle command that adjusts a vehicle&#8217;s current pose to match a reference pose.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 765px; height: 251px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2022\/05\/May23_7.png\" alt=\"\" width=\"765\" height=\"251\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">To model the controller in Simulink, we have used the <a href=\"https:\/\/www.mathworks.com\/help\/driving\/ref\/lateralcontrollerstanley.html\">Lateral Controller Stanley<\/a> block. The block computes the steering angle based on the above formula. What is interesting is that you can select the type of vehicle model using the controller settings. For example, for low-speed tracking such as parking lots you can use the kinematic bicycle model, and for high-speed tracking such as race cars it is preferable to use the dynamic bicycle model. Further, you can adjust the position, yaw rate, and steering gains to improve the accuracy of the controller.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 732px; height: 424px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2022\/05\/May23_8.png\" alt=\"\" width=\"732\" height=\"424\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Like the pure pursuit controller model, we have built the vehicle path tracking model using the Stanley controller. The vehicle model and the reference trajectory are kept the same. On simulating the model it is evident that in a higher-speed environment the vehicle is successfully tracking the desired trajectory achieving a maximum velocity of 30 m\/s.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 394px; height: 394px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2022\/05\/May23_9.png\" alt=\"\" width=\"394\" height=\"394\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Reference video tutorial:<br \/>\n<iframe loading=\"lazy\" title=\"YouTube video player\" src=\"https:\/\/www.youtube.com\/embed\/FHQFya0-JBs\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/div>\n<h3 style=\"margin: 15px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 17px; font-weight: bold; text-align: left;\">Model Predictive Controller (MPC)<\/h3>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Finally, let us check out the implementation of MPC for path tracking applications in Simulink. In short, MPC solves an online optimization algorithm to find the optimal control action that drives the predicted output to the reference. It can handle multi-input multi-output systems that may have interactions between their inputs and outputs. It can also handle input and output constraints. However, the downside is that it is computationally expensive.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 624px; height: 223px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2022\/05\/May23_10.png\" alt=\"\" width=\"624\" height=\"223\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Please note we won&#8217;t go much in detail in this section as we already have an amazing MATLAB Tech Talk video series titled, <a href=\"https:\/\/www.mathworks.com\/videos\/series\/understanding-model-predictive-control.html\">Understanding Model Predictive Control<\/a>. You can watch the videos to learn how MPC works and will also discover the benefits of this multivariable control technique.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">To implement the MPC controller, initially, we started with the generic <a href=\"https:\/\/www.mathworks.com\/help\/mpc\/ref\/mpccontroller.html\">MPC Controller<\/a> block. However, the <a href=\"https:\/\/www.mathworks.com\/help\/mpc\/ref\/pathfollowingcontrolsystem.html\">Path Following Control System<\/a> block is a better alternative for following a trajectory. In general, the block is meant to keep the ego vehicle traveling along the center of a straight or curved road while tracking a set velocity and maintaining a safe distance from a lead vehicle. However, we have implemented it to follow a trajectory by setting the set velocity to the reference velocity of the vehicle and by distance based curvature to the curvature port. Further, as the output of the block is longitudinal acceleration, we connected a pedal map to obtain the required acceleration and deceleration commands.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 676px; height: 476px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2022\/05\/May23_11.png\" alt=\"\" width=\"676\" height=\"476\" \/><\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Finally, after selecting the appropriate design parameters such as prediction horizon, control horizon, etc., we simulated the model and can see the vehicle tracking the path perfectly.<\/div>\n<h2 style=\"margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: center;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 374px; height: 376px;\" src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2022\/05\/May23_12.png\" alt=\"\" width=\"374\" height=\"376\" \/><\/h2>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Reference video tutorial:<br \/>\n<iframe loading=\"lazy\" title=\"YouTube video player\" src=\"https:\/\/www.youtube.com\/embed\/SzEg_C-XJ14\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/div>\n<h2 style=\"margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\">Time to build your own model<\/h2>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">The blog does not cover all the technical details of the above controllers but rather provides an overview of implementing these controllers in MATLAB and Simulink. We hope we provided enough background and resources to get you started with the trajectory tracking models. So now it is your turn to use these resources as a reference to drive a car on a more challenging track.<\/div>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Also, in case of any queries related to this blog please feel free to reach out to us at racinglounge@mathworks.com.<\/div>\n<h2 style=\"margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\"><\/h2>\n<h2 style=\"margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: bold; text-align: left;\"><\/h2>\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/student-lounge\/files\/2022\/05\/Picture1.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div>\n<p>\nHi, everyone! In this blog, we will see how trajectory tracking controllers can be implemented in MATLAB and Simulink to make the vehicle follow a pre-defined path. Before we get started, a big&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/student-lounge\/2022\/05\/23\/simulating-trajectory-tracking-controllers-for-driverless-cars\/\">read more >><\/a><\/p>\n","protected":false},"author":183,"featured_media":7862,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[4],"tags":[488,605,30,608],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/posts\/7853"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/users\/183"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/comments?post=7853"}],"version-history":[{"count":5,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/posts\/7853\/revisions"}],"predecessor-version":[{"id":11885,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/posts\/7853\/revisions\/11885"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/media\/7862"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/media?parent=7853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/categories?post=7853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/student-lounge\/wp-json\/wp\/v2\/tags?post=7853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}