├── LICENSE ├── MPC_lane_following.m ├── MPC_path_following.slx ├── README.md └── our_model.mat /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Venkat Narayanan Balachandran 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MPC_lane_following.m: -------------------------------------------------------------------------------- 1 | % Parameters 2 | tau = 0.5 % time constant for acceleration tracking in seconds. 3 | m = 1575 % mass in kg 4 | Vx = 15 % longitudinal velocity of the car in m/s 5 | Iz = 2875 % yaw moment of inertia in mNs^2 6 | Lf = 1.2 % long.distance from center to front tires in meters 7 | Lr = 1.6 % long.distance from center to rear tires in meters 8 | Cf = 19000 % cornering stiffness of front tires in N/rad 9 | Cr = 33000 % cornering stiffness of rear tires in N/rad 10 | Ts = 0.1 % Sample time in seconds 11 | 12 | % Adaptive cruise control model 13 | A1 = [-1/tau 0; 14 | 1 0] 15 | B1 = [1/tau; 0] 16 | C1 = [0 1] 17 | D1 = 0 18 | 19 | % Lane-keeping predictive model 20 | A2 = [(-2*(Cf + Cr)/m / Vx) (-Vx-2*(Cf*Lf - Cr*Lr)/m /Vx); 21 | (-2*(Cf*Lf - Cr*Lr)/Iz/Vx) (-2*(Cf*Lf^2 + Cr*Lr^2)/Iz/Vx)] 22 | 23 | B2 = [1/m; Lf/Iz] .* 2*Cf 24 | C2 = [1 0; 25 | 0 1] 26 | D2 = [0;0] 27 | 28 | % Combined path-following predictive control model 29 | % The inputs are the longitudinal acceleration in m/s2 and 30 | % steering angle in radians. 31 | % The outputs are the longitudinal velocity in m/s,lateral velocity 32 | % in m/s, and yaw angle rate in rad/s. 33 | 34 | A = [A1 zeros(2); 35 | zeros(2) A2] 36 | B = [B1 zeros(2,1); 37 | zeros(2,1) B2] 38 | C = [C1 zeros(1,2); 39 | zeros(2) C2] 40 | D = [D1 0; 41 | zeros(2,1) D2] 42 | 43 | -------------------------------------------------------------------------------- /MPC_path_following.slx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VenkatNarayanan11/Autonomous_Lane_keeping_using_Model_predictive_control/0912f912d7595330061558bdefb344ea4432fc75/MPC_path_following.slx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Autonomous Lane Keeping using Model Predictive Control 2 | ![Autonomous_lane_keeping_model](https://user-images.githubusercontent.com/79725511/109578820-decc2980-7ac5-11eb-8a05-625c56feb1a8.jpg) 3 | > A quick snap of the System Model. In the above diagram, u1 and u2 are the inputs of the longitudinal acceleration and steering angle to the “ego vehicle model” block. The outputs y1, y2, and y3 are the longitudinal velocity, lateral velocity, and the yaw angle rate respectively. The error dynamics are referenced in the variables e1 and e2. These variables indicate the lateral deviation and the relative yaw angle respectively. 4 | 5 | --- 6 | 7 | ### Table of Contents 8 | 9 | - [Description](#description) 10 | - [Technologies](#technologies) 11 | - [Results](#results) 12 | - [Recommendations](#recommendations) 13 | - [License](#license) 14 | - [Author Info](#author-info) 15 | 16 | --- 17 | 18 | ## Description 19 | 20 | This study aims to establish a feasible lane-keeping controller for a simulated autonomous vehicle by employing model predictive control (MPC) methodologies. The lane-keeping controller will operate by tracking a reference trajectory when given a reference longitudinal velocity. The model used for this experiment is a combination of a lane-keeping model and an adaptive cruise control model, resulting in a system capable of controlling both the longitudinal acceleration and the steering angle of the ego vehicle. The vehicle dynamics were created using the kinematic bicycle model. The model and simulation were performed in MATLAB 2019b using Simulink, the Automated Driving toolbox, and the Model Predictive Control toolbox. The resulting MPC controller was proven to feasibly provide the lane-keeping capability to the simulated ego vehicle when driving upon a roadway containing arbitrary waypoints. 21 | 22 | #### Technologies 23 | 24 | - MATLAB 25 | - Simulink 26 | - Automated driving toolbox 27 | - Model predictive control toolbox 28 | 29 | [Back To The Top](#Autonomous-Lane-Keeping-using-Model-Predictive-Control) 30 | 31 | --- 32 | 33 | ## Results 34 | 35 | The final output will include: 36 | 37 | 1) Error Dynamics of the ego vehicle 38 | 39 | ![Error_dynamics_of_ego_vehicle](https://user-images.githubusercontent.com/79725511/109576550-f9040880-7ac1-11eb-9d5d-44593974eed8.png) 40 | 41 | 2) MPC outputs to the ego vehicle 42 | 43 | ![MPC_outputs_to_the_ego_vehicle](https://user-images.githubusercontent.com/79725511/109576551-f9040880-7ac1-11eb-87a6-9ce22278e61a.png) 44 | 45 | 3) Ego Vehicle outputs with repect to the MPC inputs. 46 | 47 | ![Ego_vehicle_ouputs](https://user-images.githubusercontent.com/79725511/109576548-f9040880-7ac1-11eb-87cd-f0b45491bd50.png) 48 | 49 | If you would like to know the complete technical details of the project. Here is the [link](https://drive.google.com/file/d/1w0jKBFIl24ucXa-i7lIMk-ROIe2WMoYo/view?usp=sharing) to the paper written by me and two other creators. 50 | 51 | ## Recommendations 52 | 53 | From the results of this study, several recommendations are proposed for future investigations surrounding autonomous vehicles and MPC controllers. The first area of opportunity is to investigate systems containing varying longitudinal velocities using adaptive MPC models. Another opportunity for study may involve prioritizing the minimization of a vehicle’s response time to non-zero differences between its current position and reference waypoints. In this paper’s study, the vehicle’s response time is approximately 5 seconds to correct itself the maximum lateral deviations from the reference line. Finally, it should be noted that other driving scenarios can be further investigated using MPC. These other scenarios could include traffic light interaction with vehicles, collision avoidance with other vehicles on roadways, and overtaking maneuvers on diverse road types (e.g two-lane roads, roundabouts, or crosswalks). 54 | 55 | [Back To The Top](#Autonomous-Lane-Keeping-using-Model-Predictive-Control) 56 | 57 | --- 58 | 59 | ## License 60 | 61 | MIT License 62 | 63 | Copyright (c) [2020] [Venkat Narayanan Balachandran] 64 | 65 | Permission is hereby granted, free of charge, to any person obtaining a copy 66 | of this software and associated documentation files (the "Software"), to deal 67 | in the Software without restriction, including without limitation the rights 68 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 69 | copies of the Software, and to permit persons to whom the Software is 70 | furnished to do so, subject to the following conditions: 71 | 72 | The above copyright notice and this permission notice shall be included in all 73 | copies or substantial portions of the Software. 74 | 75 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 76 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 77 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 78 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 79 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 80 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 81 | SOFTWARE. 82 | 83 | [Back To The Top](#Autonomous-Lane-Keeping-using-Model-Predictive-Control) 84 | 85 | --- 86 | 87 | ## Author Info 88 | 89 | - LinkedIn - [Venkat_Narayanan_Balachandran](https://www.linkedin.com/in/venkat-balachandran) 90 | 91 | [Back To The Top](#Autonomous-Lane-Keeping-using-Model-Predictive-Control) 92 | -------------------------------------------------------------------------------- /our_model.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VenkatNarayanan11/Autonomous_Lane_keeping_using_Model_predictive_control/0912f912d7595330061558bdefb344ea4432fc75/our_model.mat --------------------------------------------------------------------------------