**3. Knowledge-based adaptive controller development for a path tracking system**

#### **3.1 Basic structure of trajectory tracking controller**

In this study, the adaptive controller was based on the previously developed controller from the previous publication by Amer et al. [14], namely, the modified Stanley (Mod St) controller. Equation (1) shows the original Stanley controller from Hoffmann et al. [3]. The same publication has extended the controller to include the yaw rate compensation as shown in Eq. (2). A modification has been carried out to these controllers to increase their sensitivity towards the disturbance input as proposed previously in [14]. The Mod St controller used in this work is shown in Eq. (3), where the main parameters are shown in **Figure 3**. Here, *e* is the lateral error of the vehicle (*m*), measured between the vehicle and the perpendicular point on path; *ϕ* is the heading error (*rad*), which is the difference between the vehicle's and the path's instantaneous directions; *v* is the vehicle speed (m/s); *ψ*\_ is the instantaneous yaw rate of the vehicle (rad/s); and *ψ*\_ *traj* is the trajectory yaw rate (rad/s). Meanwhile, *kϕ*, *k1*, *k*, and *k<sup>ψ</sup>* are the tuneable gains. In this study, the original Stanley controller from Eq. (1) is used as the benchmark, while the Mod St controller from Eq. (3) is used as the base controller for the adaptive control structure.

$$\delta = \phi + \tan^{-1}\left(\frac{ke\left(t\right)}{\nu\left(t\right)}\right) \tag{1}$$

$$\mathcal{S}\left(t\right) = \phi + \arctan\left(\frac{ke\left(t\right)}{1 + \nu\left(t\right)}\right) + k\_{\psi}\left(\dot{\nu} - \dot{\nu}\_{\text{ray}}\right) \tag{2}$$

$$\mathcal{S}\left(t\right) = k\_{\phi}\phi + k\_{1}\arctan\left(\frac{ke\left(t\right)}{1+\nu\left(t\right)}\right) + k\_{\psi}\left(\dot{\psi} - \dot{\psi}\_{\text{proj}}\right) \tag{3}$$

Six trajectories are chosen for this study in order to portray the different kinds of road courses, shown in **Figure 4**. Each was named based on the trajectory shape,

**Figure 3.** *Main parameters for the Stanley controller and its variants.*

**Figure 4.** *Road courses for controller testing.*

namely, "straight road", "multiple lane change", "double lane change", "curve", "S", and "hook". Each trajectory is defined as a set of points with *X-Y* coordinates. Therefore, lateral error is obtained based on the current *X* position for the vehicle, such that *e* ¼ *Ypath*ð*Xvehicle*Þ � *Yvehicle*ð*Xvehicle*Þ.

Further analysis on the application of controller on a heavy vehicle yields an important issue in tuning the parameters as discussed previously by Snider [6] and Shan et al. [17]. A perfectly tuned controller will work properly within a certain

#### *Knowledge-Based Controller Optimised with Particle Swarm Optimisation for Adaptive Path… DOI: http://dx.doi.org/10.5772/intechopen.92667*

range of vehicle speed, as well as a certain type of trajectory and road courses. Also, the more parameters included in the controller, the more sensitive it is to changes, which will make it less robust. These effects can be shown in **Figure 5** where all the three variants of the Stanley controller were simulated on the heavy vehicle model with different speeds on S road. Each of the controllers was properly tuned for 6 m/s speed on the particular trajectory using particle swarm optimisation (PSO) algorithm with the same approach as presented in [13–15]. **Table 1** shows the parameter values for each controller upon optimisations for each trajectory at 6 m/s speed, which was used throughout the testing for all speed values. From the figures, it can be seen that the properly tuned controller is valid only for a certain range of speed and the number of parameters is one of the main factors that affect the robustness of the controller. The controller with the least parameters showed better robustness and performance in varying speeds. However, significantly large error (0.4–0.8 m) can be noticed. This is agreeable to the finding by Wallace et al. [18], which concludes that it is a conflicting factor in tuning a geometric controller between stability and robustness. Therefore, this study proposes an adaptive controller with the ability to supervise the selection of an optimum set of controller parameters based on the speed and trajectory experienced by the vehicle. With this, the controller can be used regardless of the manoeuvring conditions without the need to be re-tuned.

With the original Stanley controller modified into the Mod St controller in Eq. (3) to increase its sensitivity, an adaptive algorithm is proposed to automatically tune the four parameters in Mod St, namely, *kϕ*, *k1*, *k*, and *kψ*. An adaptive algorithm using a three-dimensional control surface is used. Since it was known that the main factors affecting the validity of any set of controller parameters are both the vehicle speed and type of trajectory, two inputs are chosen for the algorithm, which are the heading error, *ϕ*, and vehicle speed, *v*. Each of the controller parameters is optimised for each input combination to form a knowledge database. With this, the adaptive algorithm is developed and converted into separate control surfaces for each parameter where the adaptive algorithm will be developed to automatically

#### **Figure 5.**

*Effect of varying speeds on the S road for the Mod St controller [Eq. (3)], Stanley controller [Eq. (1)], and Stanley controller with yaw compensation [Eq. (2)].*


**Table 1.**

*Controller parameters for St and Mod St controllers for each trajectory.*

**Figure 6.** *Procedure in developing an adaptive modified Stanley controller.*

choose parameter values from the surfaces. The overall procedure can be illustrated in **Figure 6**.
