Lateral Control Calibration and Testing in a Co-simulation Framework for Automated Vehicles

<jats:p>Lateral vehicle control is a high importance in automated vehicles as it directly influences the vehicle’s performance and safety during operation. The Linear Quadratic Regulator (LQR) controller stands out due to its high-performance characteristics and is used in the open source for self driving functions. However, a notable limitation of the current approach is the manual calibration of LQR controllers based on the experience and intuition of the designers, leading to empirical uncertainties. To address this issue and enhance the lateral control performance, this paper concentrates on refining the LQR by employing three optimization algorithms: Artificial Bee Colony Optimization (ABC), Genetic Algorithm (GA), and Particle Swarm Optimization (PSO). These algorithms aim to overcome the reliance on empirical methods and enable a data-driven approach to LQR calibration. By comparing the outcomes of these optimization algorithms to the manual LQR controller within an offline multibody simulation as testing platform, the study highlights the superiority of the best-performing optimization approach. Following this, the optimal algorithm is implemented on a real-time system for the full vehicle level, revealing the Model-in-the-Loop and the Hardware-in-the-Loop gap up to 78,89% with lateral velocity when we use Relative Error Criterion (REC) method to validate and 2.35m with lateral displacement when considering by maximum absolute value method.</jats:p>

section_content: The advancement of highly automated vehicles holds a critical position in the field of automotive engineering. The key advantages of highly automated driving include improving road safety, particularly by minimizing driver errors and making efficient use of commuters' travel time [1, 2]. Perception, trajectory planning, and control are three main parts in the structure of automated vehicles, where the control part allows the car to follow the trajectory, which has been determined in the trajectory planning parts. Because of the complex interconnections between the vehicle's lateral and longitudinal dynamics, designing a controller needs to be considered carefully [3] and it continues to remain a challenge. There are various control techniques that have been used for trajectory tracking in automated vehicles, such as: PID [4, 5], linear quadratic regulator (LQR) [6] [7] [8] [9], the sliding mode control (SMC) [10, 11], robust control [12], model predictive control (MPC) [8, [13] [14] [15] [16] and reinforcement learning [17, 18]. However, most of them are used to control longitudinal and lateral dynamics separately. Recently, controlling both longitudinal and lateral dynamics has been applied [4, [19] [20] [21] [22] [23]. Nada et al. [21] designed a multi-input-multi-output (MIMO) linear MPC with some constraints in the vehicle dynamics, in which the reference path is tracked based on the steering angle and angular velocity. In [4], Zhou et al. adopted the MPC and nonlinear model predictive control (NMPC) method to cope with the nonlinear MIMO problem for the vehicle's lateral stability. Although the MPC controller can use nonlinear dynamics to solve the constraints, MPC prevents having to conduct an experiment on a real-time system because of the increase in the model complexity and constraints as well as the huge amount of computation. The SMC technique is proposed to control by combining the lateral and longitudinal dynamic [22]. However, when applying the SMC technique, the chattering phenomenon often appears when acquiring robustness. To overcome this obstacle, in [23], the authors applied a new sliding mode that reduces chattering and makes state variables converge faster. However, rough road surfaces can lead to compromised path tracking accuracy and overall system stability. 

The LQR approach is popularly used in automated vehicle controllers because of algorithmic simplicity, high-precision performance, and satisfaction with dynamic constraints. Zhang [24] compared the robust controller with LQR and MPC in terms of performance as well as computation. In the parking scenario, the LQR controller has a better performance. Regarding computation, the LQR requires less in comparison with MPC while it has the same performance indicators in some cases. However, LQR methods usually do not consider disturbances which can contribute to system errors. To cope with this problem, Kapania et al. [25] designed a controller by combining feedback and feedforward steering. The aim is to keep the stability of the vehicle under hard maneuvering conditions as well as minimize path deviation. However, the steady-state path deviation drastically increases at high velocity. In [26], the authors also proposed an LQR controller using feedforward and predictive steering for lateral dynamics, which helps vehicle driving under complex conditions. Although LQR controllers were widely applied to automated vehicles, most LQRs choose weight factors based on empirical consideration. To dispose of empiricism, some studies added algorithms to optimize the LQR controller in order to improve performance. In [27] [28] [29], the authors used GA, fuzzy control, and PSO to choose the optimized weight factors for the LQR controller. The results showed the effectiveness of these algorithms regarding the tracking accuracy and the stability of the vehicle. Although promising results are shown in these studies, there is still potential for further improvement in the accuracy of the controller. 

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. Hye Young An [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. Taekgyu Lee 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 lowlevel 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 CarMaker 11. 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.
section_name: Introduction

section_content: 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-inthe-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.
section_name: •

section_content: Apollo is a widely recognized open source SAE Level 4 AD platform that was introduced by the Baidu company [37]. It includes a comprehensive suite of hardware and software solutions for various aspects of AD, including perception, planning, and control. In this model, we assume that the model is simplified as the lateral dynamic model with two degrees of freedom, and vertical movement is ignored since the vehicle drives in a single plane. α f, α r are steering angles in the front and rear wheels, respectively. The front and rear steering angles are small and noted by δ f and δ r, so the lateral force and side slip angle has a linear relationship, which is acceptable for tire slip angles of about 3 degrees. The lateral load transfer effects which occur due to lateral acceleration are neglected and the suspension system's effect is not considered.
section_name: Vehicle Dynamics and Control

section_content: O is the mass center point, a and b are the distances from O to the front and rear axles, ϕ is the yaw angle, and φ is yaw rate. C f and C r are the lateral stiffness of the tires in the front and rear wheels, F y f is the lateral force of the front wheel, and F yr is the lateral force of the rear wheel. v x, v y are vehicle's longitudinal and lateral velocity, respectively. 

The dynamic equations of this model are noted as [38] :

where m is the mass of the vehicle, I z is the rotation inertia of the vehicle around the vertical axis. All of these symbols are listed in the Nomenclature part. 

Because the front wheel steering angle is small, the lateral force and side slip angle have a linear relationship, and the dynamic Equations ( 1 ) and ( 2 ) are obtained as follows:

When the vehicle follows a reference path, a lateral error and heading angle error will occur. As illustrated in Figure 1, the lateral error, denoted by e d, represents the shortest distance between the point O and the projected point P on the reference path. Meanwhile, the heading angle error, referred to as e θ, is the difference between the actual heading angle of the vehicle θ and the reference heading angle θ r. For the sake of simplicity, the side slip angle is assumed to be β = 0 at the point O, and the heading angle error is calculated as e θ = θθ r. In practical control, the controller's task is to promptly eliminate these two errors in real-time to ensure that the vehicle stays on track with the planned path. With these errors in mind, it becomes possible to compute the first-order derivatives of the lateral error ėd and the heading angle error ė ϕ :

Equations ( 5 ) and ( 6 ) are substituted in Equation ( 4 ), which can obtain:

Equations ( 7 ) and ( 8 ) can be rewritten as:

Equations ( 9 ) can be rewritten in the state-space representations as:

with: X = [ ėd, ëd, ė ϕ, ëϕ ] is the state vector; U = [δ f ] is the control input.
section_name: Vehicle Model

section_content: In this study, the path planning process involves a series of reference points. This discretization of data is necessary for practical implementation. To control the vehicle along this discrete trajectory, a discrete linear-quadratic regulator (dLQR) controller is used. Equation ( 10 ) is discretized to design the dLQR controller, which governs the vehicle's dynamics. During this process, we neglect the effect of C θ r and apply the midpoint Euler and the forward Euler approach to clarify the model while preserving essential characteristics. As a result, we obtain the equation that describes the discrete tracking errors as:

Ẋk +1 = ĀX + BU (11) with:

Figure 2 shows the entire structure of the LQR controller for an automated vehicle, which includes four main parts: the perception, path planning, controller, and the vehicle model. In path planning, the EM planner [39] is used to generate the reference path and path tracking errors. As the path planning module is not the focus of our work, the exact algorithm can be referenced in the GitHub project [40]. 

The LQR controller is the main center of the second part. The aim of this study is to find the optimized matrix K for the LQR controller using three algorithm optimizations (ABC, GA, and PSO) as well as calculate δ f f in the feedforward control step to find the final signal control (steering angle δ f ). Then, the steering angle δ f is sent to the vehicle model to control a car. We use the BMW5 car model and IPG Carmaker 11 software as a simulation environment. After comparing the performances of the vehicle when using the three optimization algorithms, we find the best algorithm for the car. Finally, we use this algorithm to simulate the real-time system and compare the gap results between the MiL and HiL. The cost function of LQR controller is defined as:

where Q is the weighting matrices of the state error and R is weighting matrices of the control signal. q 1, q 2, q 3, q 4, q 5 are the weight factors of the lateral error, lateral error rate, heading error, heading error rate, and the steering angle in the front wheel, respectively. Substituting Equation ( 11 ) into ( 13 ), the Lagrange multiplier approach is employed to build the constraints as follows:

The Hamiltonian function is defined as:

From Equations ( 16 ) and ( 17 ), one can obtain:

The extreme value of Equation ( 18 ) is achieved:

where K can be calculated as:

P is solved by the Riccati equation:

Equation ( 19 ) can be rewritten as:

where

is the gain of the LQR controller. Substituting Equation ( 21 ) into Equation ( 10 ) obtains:

According to Equation (22), irrespective of the specific value assigned to gain K, the distance error and heading error of an automated vehicle cannot be zero during the control process, indicating the presence of a steady-state error in the system. Consequently, the influence of C k θ is removed and feedforward control δ f f is uses as follows:

Substitute Equation ( 23 ) into (10), so that when Ẋ = 0, the formula for the state variable without a steady-state error is as follows:

By solving and simplifying Equation ( 24 ), the following is obtained:

Following Equation (25), when e d = 0, the feedforward control is:

In Equation ( 6 ), we assume that the real heading error can be calculated as e ϕ = ϕθ r. Reducing the heading error to zero and ensuring that e ϕ = ϕθ r = -β are crucial when the vehicle reaches a stable state. Consequently, there is no need to devise a feedforward controller for eliminating the steady-state error in e ϕ. Additionally, Kapania et al. [25] demonstrated that achieving a steady-state equilibrium is still possible even when there are non-zero values for a lateral error as well as a heading angle error.
section_name: Lateral Controller

section_name: Calibration Optimization

section_content: Calibration solution in the state of the art Matrix K is the gain of the LQR controller and can be calculated from Equation (19). 

The key to the LQR controller lies in the choice of the weight factors of matrices Q and R in Equation ( 14 ) and ( 15 ). In the previous study [41], Li et al. chose these weight factors based on the empirical method. First, Q is optimized by setting an intermediate value (arbitrarily chosen to be in the order of 10 5 ) to R and Q is considered diagonal to simply tuning. Q is tested for a small value Q min (close to 0) and later for a large value of Q max (in the order of 10 6 ). The two results are compared, and then an intermediate value Q avg is tested and the process is repeated by considering the new "small" and "large" limits Q avg and the value between Q min and Q max that yielded the best result. 

The process is then repeated by choosing a new intermediate value between the two limits until an acceptable result is produced. For R optimization, the same approach is followed, setting Q to the optimized value just found.
section_name: •

section_content: The flowchart of the ABC algorithm [42] and the LQR controller is shown in Figure 3. 

The employed bees actively seek K values in the vicinity of their remembered food source, all the while communicating information about these K values to the onlooker bees. The onlooker bees are likely to select good K values from those based on the fitness function as well as evaluate K values using the cost function. A few employed bees translate into the scout bees and search for new food sources until the condition is satisfied.
section_name: • Artificial Bee Colony Algorithm

section_content: The GA [43, 44] draws inspiration from biological principles such as mutation, crossover, and selection. The GA commences by configuring the parameters of the BMW car, the initial K values, as well as randomly generated individuals, initiating the evolutionary journey. In each generation, the fitness of every individual is evaluated, typically by assessing the value of the fitness function. Stochastic selection is employed to favor fitter individuals from the current population. These selected individuals' genomes are then subject to modifications, such as recombination and possibly random mutations, to generate a new generation of candidate solutions. This cyclic process continues, with the newly formed generation becoming the basis for the subsequent iteration. 

The GA advances through iterations until it reaches a termination condition. The flowchart of GA-LQR is shown in Figure 4. • Particle swarm optimization Figure 5 illustrates the flowchart of the PSO algorithm [45] and LQR controller. The optimal weight factor is found by searching for the global in order to enhance the LQR controller performance. Firstly, the parameters of the BMW car model are configured. Then, we set the initial particles' positions and velocities as well as the initial values of LQR matrices. After that, the algorithm will calculate the fitness function value and find the global best solution. If the condition is satisfied, the algorithm is stopped, otherwise, the algorithm continues to run until satisfies the condition.
section_name: • Genetic algorithm

section_name: Simulation and Results

section_content: In this study, a BMW5 model is used for simulation. The model was calibrated with experiments performed at the Institute of Automotive Engineering laboratory and on a proving ground. Firstly, test the BMW 5 car on the real road to measure the parameters and save these in the datasheet. Then, a simple model with parameter adjustment from the datasheet is created. After that, the car was simulated on the test road, and the parameters were measured and the compared with the simulation. Finally, calibrate the steering model and stabilizer model for good fitting of the curves and choose the best tire model. The results of the model calibration refer to [46]. The BMW5 model is simulated in the CarMaker environment on a 50 m circular road, as depicted in Figure 6. The car drives in 48 s, with a maximum speed of 50 km/h and the speed step is 0. 01. Therefore, there are 5000 values of matrix K corresponding to each speed step, and the lateral errors are evaluated during driving.
section_name: Model-in-the-Loop Simulation

section_content: In previous works conducted by Li et al. [30, 31, 47], the co-simulation framework for the virtual vehicle test bench is introduced. CarMaker and Matlab/Simulink are used together to build a co-simulation software system. The multi-body simulation (MBS) environment is provided by the CarMaker software, including vehicle dynamics, sensor models, as well as the virtual environment. The CarMaker is implemented on a real-time processing unit called "Xpack4". Both CarMaker and Xpack 4 are from IPG Automotive GmbH [48]. Moreover, the whole vehicle test bench is controlled by the automation-system software Tornado 6 from KS Engineers The users have the capacity to configure virtual vehicle test bench using Tornado. In addition, ADAC (5 kHz) from KS Engineers [49], which is a real-time testing, controlling, and monitoring system which was developed for the virtual vehicle test bench in real-time. The EtherCAT topology protocol enables real-time synchronous simulation communication between Tornado, ADAC, and XPack4 real-time systems. In this study, the same framework is used, which comprises a virtual environment and a virtual vehicle test bench. This framework (RT-ADF) allows multiple software to be integrated and executed on real-time hardware platforms. This work demonstrates an offline virtual vehicle test bench. If the simulation model is successfully executed and validated offline, it can be transferred to the real test bench. Therefore, this is a good approach to improve the efficiency and optimize the work. Table 2 depicts the results of the vehicle model in a real-time system. In [50], a quantitative comparison method is the relative error criterion (REC) used to validate results as:

We calculate the maximum absolute value of the error as:

Error dL = max(|dL test -dL sim |) = 0. 28 (30)
section_name: Hardware-in-the-Loop Simulation

section_content: Figure 7 shows the steering angle of the vehicle in four cases using manual calibration, ABC, GA, and PSO algorithms. In the interval spanning from the 4th to the 10th second, alterations in the steering angle were observed for the manual calibration, GA, and ABC algorithms, registering an approximate variation of 1. 9 rad. Conversely, the steering angle adjustment remained negligible when employing the PSO algorithm. Moreover, at the 24th second, a sudden soar in the steering angle occurred within a span of 3 s, for the Manual calibration, GA, and ABC algorithms. This value then stabilized thereafter at approximately 11 rad. In contrast, the steering angle change generated by the PSO algorithm exhibited a gradual increment, culminating at 8 rad by the conclusion of the aforementioned timeframe. Therefore, the PSO algorithms can prevent the centrifugal acceleration experienced in the vehicle. Consequently, this incremental approach has the capacity to enhance both the precision of lateral displacement and the lateral velocity measurements. 

Table 1 compares the lateral error and lateral velocity using three algorithms as well as manual calibration. Regarding the root mean square values for lateral displacement, the PSO algorithm exhibits a value of 0. 2274 m, outperforming the manual calibration (1. 124 m), ABC (1. 5092 m), and GA (1. 0747 m). Moreover, the results across various values in the PSO algorithm consistently demonstrate a superior performance compared to the other algorithms under consideration. 

The lateral displacement and lateral velocity differences between the MiL and HiL are evident in Table 2. Notably, simulation values obtained from HiL are larger than those generated by the MiL. Similarly, there are errors between the results obtained from the MiL and the HiL, particularly up to 53. 23%, with lateral displacement and 78. 89% lateral velocity when we use the REC method to validate. Because the value of the lateral velocity is too small, this REC value is excessive. When we use the maximum absolute value method to validate the difference between the results obtained from the MiL and the HiL, the figures for lateral displacement and lateral velocity are 2. 35 m and 0. 28 m/s, respectively. This divergence can be caused by the cyclic delay existing between Xpack and ADAS and the computer.
section_name: Discussion

section_name: Conclusions

section_content: This study presents three optimization algorithms, ABC, GA, and PSO to fine-tune the LQR parameters based on open source software for automated vehicle Apollo frameworks. These algorithms aim to overcome the reliance on empirical methods and enable a datadriven approach to LQR calibration. This study highlights the superiority of the PSO algorithm by comparing the outcomes of this optimization algorithm to the manual, ABC, GA LQR controller within the MiL simulation. Finally, the PSO algorithm is simulated on a HiL, and the result shows the gap between the MiL and the HiL simulation. 

In the future, our works will continue to focus on optimizing and enhancing our system, especially focusing on the controllers and path planning, where MPC and reinforcement learning can be applied. Moreover, the more complex traffic scenarios will be used to test and validate the reality of Apollo on the test bench and real car. 

Acknowledgments: We extend our gratitude to Zhengguo Gu for their valuable internship support, which greatly contributed to the success of this project.
section_name: Conclusions

section_name: Data Availability Statement:

section_content: The data presented in this study are available in Master's Thesis "Aufbau von Validierten Fahrzeugmodellen", Graz University of Technology, Austria, 2023.
section_name: Data Availability Statement:

section_name: Institutional Review Board Statement: Not applicable.

section_content: Funding: Funding by the Graz University of Technology. This activity is part of the research project InVADE (FFG nr. 889349) and has received funding from the program Mobility of the Future, operated by the Austrian research funding agency FFG. Mobility of the Future is a mission-oriented research and development program to help Austria create a transport system designed to meet future mobility and social challenges. This paper is supported by TU Graz Open Access Publishing Fund.

section_content: Informed Consent Statement: Not applicable.
section_name: Institutional Review Board Statement: Not applicable.

section_content: The authors declare that the research was conducted in the absence of any commercial or financial relationships that could be construed as a potential conflict of interest. Additionally, the authors declare that this study received funding from the Austrian research funding agency FFG within the scope of the research project InVADE. The funder was not involved in the study design, collection, analysis, interpretation of data, the writing of this article, or the decision to submit it for publication.
section_name: Conflicts of Interest: