A Carsim-Simulink demonstration of Model Predictive Control (MPC) for autonomous vehicle trajectory tracking showcases the integration of CarSim and Simulink to achieve MPC-based circular trajectory tracking for self-driving cars.
Version: MATLAB R2020a, CarSim 2020.0 (install and link Simulink), Windows 11
Directory: root directory is D:\CarSim2020\Carsim_Files, include(MPCtest1.mdl, MY_MPCController3.m, my_quadprog.m),the root directory can be customized
Please refer to the detailed configuration process.
- Click 'Send to Simulink' in CarSim—Home, then automatically open Simulink. Click 'Run' in Simulink, wait for the completion of the simulation, and check the simulation results in Simulink
- If you need to modify parameters in CarSim, such as vehicle parameters or simulation conditions, you should first 'Run Now' and then 'Send to Simulink.' If you are modifying parameters in Simulink, you only need to 'Run' within Simulink
- Finally, in CarSim—Home—Analyze Results (Post Processing), click on 'Video+Plot' to view the CarSim simulation results.
Trajectory of the autonomous vehicle in Simulink:
The trajectory of the autonomous vehicle in CarSim:
Result_CarSim.mp4
Modify the reference trajectory in MY_MPCController3.m for reference.
Thanks to the book 'Model Predictive Control for Autonomous Vehicles' by Jianwei Gong for guidance.