4.1.2. Lateral Model

Regarding the lateral model, the single track vehicle model shown in Figure 5 was used, considering the lateral and yaw dynamic balance given by [19], as follows:

$$\psi = -\frac{(\mathbb{C}\_{yf} + \mathbb{C}\_{yr})}{mu}v + (-u + \frac{\mathbb{C}\_{yf}a - \mathbb{C}\_{yr}b}{mu})r + \frac{\mathbb{C}\_{yf}}{m}\delta\_f \tag{17}$$

$$\dot{r} = -\frac{(\mathbb{C}\_{yf}a - \mathbb{C}\_{yr}b)}{\|u\|}v + \frac{(\mathbb{C}\_{yf}a^2 + \mathbb{C}\_{yr}b^2)}{\|u\|}r + \frac{\mathbb{C}\_{yf}a}{\|}\delta\_f\tag{18}$$

where *v* and *r* are, respectively, the lateral speed component and yaw rate; *Cy f* and *Cyr* are the cornering stiffness tire parameters; *u* is the longitudinal speed component; *a* and *b* are, respectively, the front and rear wheelbase of the vehicle; *m*, *J* and *R* are the mass, vertical moment of inertia and wheel radius of the car.

#### *4.2. LQR*

Considering the longitudinal and lateral vehicle dynamics shown in the previous subsection, a LQR can be implemented by tracking the longitudinal and lateral vehicle speed and position found by the trajectory planning. In fact, the optimized longitudinal vehicle speed can be considered as the target speed that the vehicle has to have and subtracted from the actual longitudinal vehicle speed obtaining:

$$
\dot{\epsilon}\_{\chi} = \dot{\mathfrak{x}} - \mathfrak{x}\_{t} = \frac{d\epsilon\_{\chi}}{dt} \tag{19}
$$

$$
\vec{\epsilon}\_x = \vec{x} - \vec{x}\_t = \frac{(\mathbb{C} - \mathbb{C}\_t)F\_{\text{max}}}{m} \tag{20}
$$

where *Fmax* and *m* are constant variable and (*C* − *Ct*) is the throttle pedal percentage if the speed error, *e*˙*x*, is positive and the brake pedal percentage if it is negative, saturated from 0 to 100%.

Instead, to follow the lateral dynamics suggested by the path planning, the yaw and lateral vehicle position and speed are tracked, considering the errors between the actual vehicle values and the reference values exiting the trajectory planning. Thus, replacing the Equations (17) and (18) in (21) and considering the longitudinal vehicle speed, *u*, as a constant variable, the following was obtained:

$$\dot{e}\_{\mathcal{Y}} = \dot{\mathcal{Y}} - \dot{\mathcal{Y}}\_{l} = \upsilon + \mu\psi - \upsilon\_{l} - \mu\psi\_{l} \qquad \qquad \dot{e}\_{\mathcal{Y}} = (\dot{\upsilon} - \dot{\upsilon}\_{l}) + \mu(r - r\_{l}) \tag{21}$$

$$\mathcal{E}\_{\mathcal{Y}} = -\frac{(\mathbb{C}\_{\mathcal{Y}f} + \mathbb{C}\_{\mathcal{Y}r})}{mu}\mathcal{E}\_{\mathcal{Y}} + \frac{(\mathbb{C}\_{\mathcal{Y}f} + \mathbb{C}\_{\mathcal{Y}r})}{m}\mathcal{E}\_{\emptyset} + \frac{(\mathbb{C}\_{\mathcal{Y}f}a - \mathbb{C}\_{\mathcal{Y}r}b)}{mu}\mathcal{E}\_{\emptyset} + \frac{\mathbb{C}\_{\mathcal{Y}f}}{m}(\delta\_f - \delta\_{ft}) \tag{22}$$

$$
\xi\_{\psi} = \psi - \psi\_t = r - r\_t \tag{23}
$$

$$\mathcal{E}\_{\Psi} = -\frac{(\mathbb{C}\_{yf}a - \mathbb{C}\_{yr}b)}{f\mu}\dot{\varepsilon}\_{y} + \frac{(\mathbb{C}\_{yf}a - \mathbb{C}\_{yr}b)}{f}\varepsilon\_{\Psi} + \frac{(\mathbb{C}\_{yf}a^{2} + \mathbb{C}\_{yr}b^{2})}{f\mu}\dot{\varepsilon}\_{\Psi} + \frac{\mathbb{C}\_{yf}a}{f}(\delta\_{f} - \delta\_{ft}) \tag{24}$$

Therefore, the dynamic state space has the following representation:

*e*˙

$$\begin{Bmatrix} \boldsymbol{\epsilon}\_{\boldsymbol{x}}^{\boldsymbol{\epsilon}} \\ \boldsymbol{\epsilon}\_{\boldsymbol{x}}^{\boldsymbol{\epsilon}} \\ \boldsymbol{\epsilon}\_{\boldsymbol{y}}^{\boldsymbol{\epsilon}} \\ \boldsymbol{\epsilon}\_{\boldsymbol{\Psi}}^{\boldsymbol{\epsilon}} \\ \boldsymbol{\epsilon}\_{\boldsymbol{\Psi}}^{\boldsymbol{\epsilon}} \end{Bmatrix} = A \begin{Bmatrix} \boldsymbol{\epsilon}\_{\boldsymbol{x}} \\ \boldsymbol{\epsilon}\_{\boldsymbol{y}}^{\boldsymbol{\epsilon}} \\ \boldsymbol{\epsilon}\_{\boldsymbol{y}}^{\boldsymbol{\epsilon}} \\ \boldsymbol{\epsilon}\_{\boldsymbol{\Psi}}^{\boldsymbol{\epsilon}} \\ \boldsymbol{\epsilon}\_{\boldsymbol{\Psi}}^{\boldsymbol{\epsilon}} \end{Bmatrix} + B \begin{bmatrix} (\mathbb{C} - \mathbb{C}\_{t}) \\ (\mathbb{S}\_{f} - \mathbb{S}\_{f} \boldsymbol{t}) \\ \end{bmatrix} \tag{25}$$

where the errors of longitudinal, lateral and yaw position and rate are the LQR states, *X* = [*ex*;*e*˙*x*;*ey*;*e*˙*y*;*eψ*;*e*˙*ψ*], which must be minimized by defining the car input *U* = [(*C* − *Ct*);(*δ<sup>f</sup>* − *δf t*)] as follows:

$$
\mathcal{U} = -KX \tag{26}
$$

Here, *K* is the gains matrix calculated by solving the following offline optimization :

$$
\hat{\omega} \text{minimize} \sum X^T Q X + \mathcal{U}^T R \mathcal{U} \tag{27}
$$

where the state and the input vectors are appropriately weighted by the matrices *Q* and *R*.

However, the state space formulation shown in Equation (25) does not ensure that the tracking errors converge to zero, even though the matrix (*Ax* − *BK*) is asymptotically stable [25]. This is due to the omission of the term steady state:

*B*2*ψ*˙*ss* (28)

To ensure zero steady state errors, a feed-forward term is added to the state feedback assuming that the steering controller is obtained by state feed-back plus a feedforward term:

$$
\delta = -\mathbf{K}\mathbf{x} + \delta\_{ff} \tag{29}
$$

where *δf f* is:

$$\delta\_{ff} = \frac{mu^2}{RL} [\frac{b}{C\_{yf}} - \frac{a}{C\_{yr}} + \frac{a}{C\_{yr}}k\_3] + \frac{L}{R} - \frac{b}{R}k\_3 \tag{30}$$

where *m*, *L*, *a*, *b* are, respectively, the mass, the total wheelbase, the front and rear wheelbase of the car; *R*, *Cy f* , *Cyr* are the radius, the front and rear stiffness of the wheel; and *k*<sup>3</sup> is the third component of the matrix gain *K* calculated with Equation (27).

In addition, to compensate for the delay that the feed-back control produces in the actuation of the longitudinal input, a feed-forward term is added to the longitudinal feed-back state defining the acceleration and brake pedal control as:

$$\mathbf{C} = -\mathbf{K}\mathbf{x} + \mathbf{K}\_{ff}A\_{\mathbf{x}t} \tag{31}$$

where *Kf f* is the feed-forward gain found by a tuning process, and *Axt* is the longitudinal acceleration target output from the path planning layer.

#### **5. Experimental Results and Discussion**

Two sessions of tests were carried out to validate the architecture proposed:


The first test session involved the comparison of the developed autonomous control architecture with an offline optimization algorithm developed by VI-Grade CRT. The intention of this comparison was to validate the optimization algorithm developed with a state-of-the- art algorithm and to show how having an online optimization of the trajectory could improve the performance. The test is composed of two phase: the first one involved co-simulation between the trajectory tracking developed in Matlab-Simulink and the car model of the dynamic simulation software CRT; and the second one involved the minimum curvature optimization of Calabogie racetrack and the execution of the max-performance event explained in more detail in the next subsection.

The simulations were carried out using a laptop PC with the characteristics, Hardware 1, given in Table 2 by setting the optimization as in Table 3.

The second test session had the intent of showing the real-time functionality of the entire structure by exploiting the static simulator shown in Figure 6a and located at Meccanica 42 s.r.l. In this way, the model developed in the Matlab-Simulink environment needed to be compiled in C in the simulator's hardware provided by VI-Grade, and a test model has to be built where the systems communication is simulated as would be in the car. The results obtained are then compared with the performance of a driver obtained at the same simulator to verify that the model-simplified but constraint-enhancing representation of dynamics achieves performance comparable to that of a professional driver, as per the intention of the paper.

(**a**) Car simulator.

(**b**) Calabogie racetrack.

**Figure 6.** Tests set-up.

The hardware characteristics and computational performance of the simulator are shown in Table 2 under the name Hardware 2.

In Table 2, it can be seen that the path planning computational time that resulted for both the hardware implementations is below the required specification of 0.1 s.


**Table 3.** Optimization algorithm settings.


### *5.1. Comparison with Offline Motion Planning*

These tests have involved the comparison of the architecture proposed with the maxperformance event simulation of CRT suite. The max-performance simulation is used to define the dynamic speed limit profile on a given racetrack [26]. This offline simulation uses an iterative process where a specific static solver computes a velocity profile and then a dynamic solver verifies if the computed speed profile is feasible. Basically, the vehicle model used for static prediction has no suspensions and inherits all properties from the full CRT model. The effect of aero forces is considered and the effect of suspension jounce is taken into account by the presence of ride height maps, which link the dependency of ride heights to the vehicle velocity. The trajectory chosen to perform the max-performance event is that of minimum curvature of the Calabogie racetrack shown in Figure 6b. In the literature, this trajectory is often used as a reference, and it has been found that it is a trajectory that allows getting very close to the minimum lap time on a racetrack. For these tests, the simulation road is considered flat, neglecting the dynamics effects that the racetrack slopes and banks have on the performance.

In Figure 7, the car's longitudinal and lateral accelerations as a function of speed, GG-V, achieved by the car model controlled by the algorithm proposed and by the maxperformance event are shown. In the same figures, the GG-V constraints implemented in the path planning are shown. By Figure 7b, it is possible to see that the constraints assumed in the trajectory tracking are representative of the car, and by Figure 7a, it is possible to see that the car controlled by the algorithm developed is able to keep the car inside the constraints imposed, even if with respect to the max-performance results, it goes through the transients more instead of staying within the limits of grip. This may be due to the inputs given to the vehicle being noisier than those of the offline control, as shown in Figure 8. Here, the engine torque, the chamber brake pressures and the steering wheel angle are almost similar in quantities with differences due to the different trajectory made, even if there is a visible difference in the amplitude and timing between the two configurations, i.e., the algorithm performed higher and delayed brake pressures with respect to the max-performance event. This is reflected in the speeds achieved by the car, which are almost similar, but the algorithm's one brakes later, maintaining the high speed for more time than the max-performance speed, resulting in a reduction of lap time, as shown in Table 4.

(**a**) Algorithm GG-V.

(**b**) Max-performance GG-V.

**Figure 7.** Acceleration performance comparison.

**Figure 8.** Comparison of the input given to the vehicle and the output longitudinal speed between the algorithm proposed and the max-performance event.

#### *5.2. Comparison with Driver*

This second session of tests involved the comparison of the performance achieved by a professional driver and the trajectory tracking proposed. To perform these tests, the algorithm was compiled for use in the real-time simulator environment, and the road used is no longer flat but includes the actual lateral banks and longitudinal slopes of the road. For this reason, the longitudinal and lateral acceleration components due to the pitch and roll body movements and road inclination were added in the acceleration constraints of the path planning knowing the inclination of the road while the car is moving on the track and the pitch and roll of the car due to the brake, acceleration and steering states calculated as proportional to the difference between the front/right and rear/left normal wheel forces.

Looking at Figure 9, where the GGs obtained by the vehicle driven by the driver and by the algorithm are shown, it can be seen that the algorithm is able to respect the acceleration constraints imposed, by guaranteeing the limits of the engine and the tires and replicating the results obtained by the driver.

In terms of performance, the results show that the algorithm developed is able to match the ones of the professional driver, although simplifications have been made to the vehicle model to keep the computational cost down, in fact, speed and input curves have the same trend and peak values, as shown in Figure 10. The lap times shown in Table 4 confirm that the trajectory tracking developed is able to replace the results of a human driver, and that the system integration performs well.

(**a**) Algorithm GG-V.

(**b**) Driver GG-V.

**Figure 9.** Accelerations performance comparison.



**Figure 10.** Comparison of the input given to the vehicle and the output longitudinal speed between the algorithm proposed and the driver.

### *5.3. Trajectory Comparison*

In Figure 11, the trajectories made by the algorithm developed, max-performance event and driver are compared, highlighting the curves where the different strategies are more visible and impact the performance. In zoom 1, it is possible to see that the trajectory of least curvature achieved by the offline optimization exits the curve keeping the car on the outer side of the track, whereas the proposed path planning drives the car to the inner side of the track to anticipate and prepare the car for the following curve, as the driver does, too. In this track section, the max normal distance between the trajectory made by the algorithm with respect to the one made by the max-performance event is 5.86 m; whereas, the one made by the driver can be considered equal to the algorithm one. In zoom 2, the different approaches are more visible and impact more on the performance: the trajectory of least curvature maintains the inner side, whereas the algorithm developed goes to the outer side, achieving a max normal distance of 8.00 m; this behavior was proved by driver tests, which improves the performance of the car and reduces the lap time, even if the driver made a trajectory 3.20 m closer than the algorithm. However, in zoom 3, if at the beginning of the curves, the max-performance optimization maintains the car on the outer side, and the driver and online algorithm choose the narrowest trajectory, achieving a max normal distance of 5.60 m, and at the end of the curves, the algorithm follows the max-performance, enlarging the trajectory later of almost 6.00 m with respect to the driver losing longitudinal speed.

**Figure 11.** Comparison of the trajectory made by the algorithm proposed and the driver.

#### **6. Conclusions**

In this paper, we developed an autonomous racing car trajectory tracker that was able to update the optimized trajectory online to reduce the time lap as well as control the car, and we validated this by comparing it with the performance of offline path planning and a human driver.

The intention of the paper was to ensure the online functionality of an autonomous controller to match the decisions of a human driver instead of optimizing the trajectory offline considering a possible development for an urban area.

This aim was achieved by dividing the path planning algorithm from the trajectory control one and building a hierarchical control architecture, where the vehicle model complexity increased and the sample time decreased, i.e., the path planning uses a point mass vehicle model with a sample time of 0.1 s, and the path tracking uses a singletrack vehicle model with a sample time of 0.001 s. To ensure a correct communication between the two systems and the car, the computational time of the trajectory optimization was chosen to be below 0.1 s: the division between the path planning and path tracking and the implementation of LP instead of QP ensured the respect of these constraints, as shown in Table 2. Furthermore, to increase the path planning representation of the vehicle dynamic, the GG-V constraints were implemented as a quadratic ellipse, and the weights and the constraints of the optimization could be changed as a function of the track sections, adapting the car to the characteristics and conditions of the track. The comparisons made with a state-of-the-art offline path-planner validated the optimizer developed and the better performance achieved in terms of lap time, reducing it by almost a second.

The comparison made with a professional driver can prove that even if the autonomous architecture developed uses a simplified vehicle model to reduce the computational cost, the car is able to replicate its performance, matching the lap time.

In the future the Anti-Lock Brake System developed and published in [27] will be added to the control architecture to ensure an improvement in stability performance.

**Author Contributions:** Conceptualization and methodology, M.M. and L.R.; validation and data curation, M.M. and L.R.; writing—original draft preparation, M.M.; writing—review and editing, R.C. and C.A.; project administration, R.C. and C.A. All authors have read and agreed to the published version of the manuscript.

**Funding:** This research received no external funding.

**Institutional Review Board Statement:** Not applicable.

**Informed Consent Statement:** Not applicable

**Conflicts of Interest:** The authors declare no conflict of interest.

### **Abbreviations**

The following abbreviations are used in this manuscript:


#### **References**

