# Lateral Control Calibration and Testing in a Co-Simulation Framework for Automated Vehicles
## 1 Introduction
On the other hand, because the requirement for automated vehicles level is higher, the scenarios for testing become complex. Consequently, novel challenges to the reliability of automated vehicles emerge in testing and validation. Additionally, the growing need for testing and validation in terms of advanced driver assistance systems (ADASs) as well as automated driving technologies arises because real-world road scenarios have covered more and more [30; 31]. Consequently, X-in-the-Loop (XiL) has emerged and become a predominant approach for the scenario-driven simulation testing of automated vehicles. The \"X\" expressed the various development focuses: model, software, processor, hardware, vehicle, and driver. [PERSON] [32] proposed a path planning algorithm and pure pursuit in real-time to control the vehicle by considering the detected lanes and some constraints. The authors only considered a single lane and the error is approximately 1.147 m when the car exits the roundabout. [PERSON] et al. [33] employed a DNN-based controller to control the car. This method reduces the computational load in comparison with the previous NMPC method. In [34; 35], the authors also used MPC and NMPC to control automated vehicles in the real-time system, and the results show the efficiency, robustness, as well as the feasibility of these methods. In [36], the authors used a low-level MPC to control the small-scale race cars. Based on the simulation and experimental findings, it appears that opting for a more cautious approximation with the discriminating kernel leads to a safer driving style. Most of the previous works did not compare the gap between office simulation and real-time system. This happened because of the differences in purpose, complexity, resources, and constraints. The key contributions of this study are:  
* Three optimization algorithms, namely artificial bee colony, particle swarm optimization, and genetic algorithm are implemented to find the best coefficient of the LQR controller. The primary objective is to eliminate the external disturbances arising from the desired trajectory. The algorithm optimizations are simulated on CarMaker11.1 and Matlab/Simulink software 2021b. The effectiveness of three algorithmic enhancements is compared to the LQR controller performance without using them. Afterward, the results obtained from three algorithm optimizations are compared together to choose the best algorithm for the model-in-the-loop (MiL) simulation. * The best algorithm for the MiL simulation is used to simulate a real-time system to assess the performance. The chosen algorithm is simulated on MiL and hardware-in-the-loop (HiL). The outcomes reveal the gap between the MiL simulation and HiL for the vehicle model under consideration. The remainder of this study is structured as follows: Section 2 contains the vehicle dynamic of the model, the framework of Apollo, as well as the optimization. In Section 3, the model and controllers are simulated in an office environment and the real-time system using the multibody software CarMarker. Section 4 discusses the results and the Section 5 summarizes the research.