**3.2 Development of the adaptive controller**

An adaptive controller with the ability to supervise the selection of an optimum set of controller parameters depending on the heading error (*ϕ*) and vehicle speed

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

**Figure 7.** *Structure of the adaptive Stanley controller.*


#### **Table 2.**

*Interval for knowledge database for each input.*

(*v*) is proposed in this study. These two variables are chosen since they represent the vehicle's instantaneous speed and the state of trajectory heading with respect to vehicle's heading at a particular time. By choosing this as the input for the adaptive mechanism, and optimising the controller at different values of these two states, the controller will be able to react to variable speed and trajectory it operates on. The overall structure for the knowledge-based adaptive Stanley controller is shown in **Figure 7**.

#### *3.2.1 Building knowledge database using particle swarm optimisation*

In this study, a knowledge database is built to provide artificial insights for the controller to choose a suitable set of parameter values for the controller based on the vehicle's driving conditions, namely, speed (*v*) and heading error (*ϕ*). The database should have a complete set of parameters (*kϕ*, *k1*, *k*, and *kψ*) that correspond to each range of *v* and *ϕ*.

**Table 2** shows the interval values for input variables that were chosen for the knowledge database. In choosing the interval values, several sensitivity analyses were carried out to test the suitability of an optimised parameters set in varying speeds. It was found that each optimised parameters will yield satisfactory results within 5 m/s and 15 deg. Therefore, these intervals are chosen. A minimum of 1 m/s (≈ 3.6 km/h) and a maximum of 20 m/s (≈ 72 km/h) were chosen based on the common and safe operating speed for the vehicle. A minimum of 1 deg. and a

maximum of 75 deg. were chosen for *ϕ* values, which correspond to the minimum and maximum values of the cornering angle for the vehicle.

A metaheuristic optimisation algorithm, namely, PSO method, is used in building the knowledge database, as outlined in Amer et al. [13, 15] to optimise the four controller parameters for each of the *v* and *ϕ* combinations. Each of the four controller parameters is optimised for each of the *v* and *ϕ* combinations. PSO is one of the established optimisation algorithms based on a natural phenomenon. First introduced in 1995 [19], it is one of the many optimisation algorithms based on swarm intelligence available as research tools. A comprehensive study on PSO algorithm and other swarm intelligence algorithms with their associated optimisation performance can be found in [20]. The study has found that PSO has better performance in terms of solution consistencies and convergence than the other swarm algorithms. Zhang [21] has also stated that PSO has better convergence in achieving global optimum with better accuracy than conventional methods. Also, with a lesser number of algorithm parameters to tweak than genetic algorithm (GA), PSO is always preferable. Overall, it was found that PSO converged faster and the study concluded that PSO provides better accuracy with a fast convergence for a standard computing capability. The PSO performance has also been studied in various applications for controller parameter tuning such as [22]. Here, PSO was used to tune a model predictive controller, and the optimisation performance was compared against ant colony optimisation (ACO) and gravitational search algorithm (GSA). It was shown that PSO was more superior than the others with up to 90% quicker convergence than ACO and GSA. The PSO-optimised controller also performed better, showing that PSO managed to find better optimum points than its counterparts.

PSO algorithm simulates the behaviour of swarmed particles, which move within the swarm towards an intended position. Each particle will be assigned random positions within the swarm, and its next movement (position and velocity) will be determined based on its relative position to an optimum position. Optimum position will be the position of any particle with an optimum fitness value. Every particle will have its own fitness value and the memory of its own best position, *pbest*, as well as the overall swarm best position, *gbest*, based on the optimum fitness value. The particle's next position will be determined by considering these memories. This will guarantee that the particles will not be moving too quick towards the new position that can turn out to be another local optimum. In other words, any of the *ith* particle within the swarm will have position coordinates, *xid*, in each of the *dth* dimensions and move with velocity *vt* . Its next position, *xid (t + 1)*, will be determined based on its next velocity *v(t + 1)* shown in Eqs. (4) and (5), respectively. These processes will be iterated over several cycles, and finally, the swarm will converge to an optimum position:

$$\mathbf{x}\begin{pmatrix} t+1 \\ \end{pmatrix}\_{\dot{\mathbf{u}}\mathbf{f}} = \mathbf{x}\begin{pmatrix} t \\ \end{pmatrix}\_{\dot{\mathbf{u}}\mathbf{f}} + \mathbf{v}\begin{pmatrix} t+1 \\ \end{pmatrix} \tag{4}$$
 
$$\mathbf{x}^{(i)} = \mathbf{i}\mathbf{w} \times \mathbf{v}^{(i)} + \mathbf{c} \times rand(\mathbf{0}, \mathbf{I}) \times \left(\mathbf{p}\_{\text{best}}\,^{(t)} - \mathbf{x}^{(i)}\_{\; \dot{\mathbf{u}}}\right) + \mathbf{s} \times rand(\mathbf{0}, \mathbf{I}) \times \left(\mathbf{g}\_{\text{best}}\,^{(t)} - \mathbf{x}^{(i)}\_{\; \dot{\mathbf{u}}}\right)$$

ð5Þ

In this study, the optimisation process of Stanley controllers using PSO can be shown in **Figure 8**. Referring back to **Figure 6**, the upper part of the chart shows the optimisation process of each input combination using PSO, while **Table 3** tabulates the main parameters used in PSO algorithm. In addition, since lateral error is one of the most significant performance indices for a path tracking controller, fitness function for each particle will be evaluated by the lateral error between the vehicle

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

**Figure 8.** *Procedure for PSO.*


**Table 3.**

*PSO parameters used in building a knowledge database [13, 15].*

and trajectory (*e*), which resulted from the parameter values for each particle's position. Lateral error is quantified by the root mean square (RMS) value, as shown in Eq. (6):

$$\text{Fitness Function}, f(k\_f, k\_l, k, k\_r) = \sqrt{\frac{\sum \left[ e(t) \right]^2}{n}} \tag{6}$$

Upon completion, all sets of parameters are compiled and integrated into a knowledge database consisting all parameters for each combination of *ϕ* and *v*

**Figure 9.** *Wrapping an imaginary spline around data points (xi, ζi) with point forces (αi) acting at each point.*

values. The database is then used to form separate control surfaces for each corresponding parameter. For the proposed basic controller in Eq. (3), there are four parameters, which correspond to four separate control surfaces formed from the knowledge database. For the adaptive method, the controller parameters are adjusted by an algebraic algorithm that will interpolate a suitable set of parameter values based on the developed knowledge database. The interpolation will be on a set of control surfaces that map the optimum set of parameters according to its respective *ϕ* and *v* values.

#### *3.2.2 Generating control surface from the knowledge database*

In this study, the developed knowledge database in Section 3.2.1 is transformed into a set of control surfaces (*Φ<sup>k</sup>* ) that correspond to each of the four controller parameters *kϕ*, *k1*, *k*, and *kψ*. The transformation of the database to control surfaces was carried out using the concept named biharmonic spline [23], originally used to deduce geographical contour from a set of altitude data of the topography. It worked by assuming an imaginary spline across a one-dimensional data point and applying a point force (*αj*) to each of the data points with coordinates (*xj*, *ζj*). This can be shown in **Figure 9**.

Using the biharmonic spline method, the line in **Figure 9** satisfies a biharmonic partial differential equation (PDE) with *N* = 6 shown in Eq. (7). The solution of this PDE is satisfied with a point-force Green's function that is centred at each point as shown in Eq. (8). Solving for *α<sup>j</sup>* in Eq. (9) will yield the strength of each point force (*αj*):

$$\frac{d^4\mathcal{L}}{dx^4} = \sum\_{j=1}^N 6\alpha\_j \delta\left(x - x\_j\right) \tag{7}$$

$$\mathcal{L}\left(\mathbf{x}\right) = \sum\_{j=1}^{N} \alpha\_{j}^{\prime} \left| \mathbf{x} - \mathbf{x}\_{j} \right|^{3} \tag{8}$$

$$\mathcal{L}\left(\mathbf{x}\_i\right) = \sum\_{j=1}^{N} \alpha\_j \left| \mathbf{x}\_i - \mathbf{x}\_j \right|^3 \tag{9}$$

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

Extending this method to a three-dimensional space, one can assume spreading an imaginary surface over the points instead of a spline. In this study, the biharmonic interpolation concept is applied on the knowledge database, which consists of data that are scattered in a three-dimensional space. The control surface produced needs to pass through each of the data in the database using this concept

**Figure 10.** *Control surface for each controller parameter.*

#### *Automation and Control*

by wrapping an imaginary thin lamina around all the data points. The database is separated into four sets of data, which will generate four control surfaces, which corresponds to each controller parameter as shown in **Figure 10**. Each surface shows the interpolated surface relating to the control parameter values to its corresponding vehicle speed and heading error.

#### *3.2.3 Using the control surface to generate an optimum set of parameters*

Using the control surface generated previously, the interpolation algorithm will choose corresponding parameter values within the surface based on instantaneous heading error and vehicle's speed. This will adaptively tune the modified Stanley controller, adjusting it to various conditions during manoeuvring regardless of any path and vehicle speed. In cases where the *v* and *ϕ* values are outside of the database range from **Table 2** and surfaces from **Figure 10**, no extrapolation method will be used. Instead, parameter values at surface boundaries will be considered. This is to avoid the controller to enter an unstable controller region and ensure that the algorithm will continuously tune the parameters even when the *v* and *ϕ* values are outside of the range in the knowledge database. By denoting the *k*th control surface as *Φ <sup>k</sup> (v, ϕ)* where *k* = 1, 2, 3, 4 and *Kk* corresponds to the controller parameters *kϕ*, *k1*, *k*, and *kψ*, the adaptive algorithm to automatically tune the controller parameters has been developed as a set of controller commands as shown in Eq. (10):

$$K\_{\boldsymbol{\lambda}} = \begin{cases} \boldsymbol{\phi}^{\boldsymbol{k}} \left( \boldsymbol{\phi}, \boldsymbol{V} \right) & \text{if } \boldsymbol{\phi}\_{\text{min}} \le \boldsymbol{\phi} \le \boldsymbol{\phi}\_{\text{max}}, \text{ AND } \boldsymbol{\nu}\_{\text{min}} \le \boldsymbol{\nu} \le \boldsymbol{\nu}\_{\text{max}} \\ \boldsymbol{\phi}^{\boldsymbol{k}} \left( \boldsymbol{\phi}, \boldsymbol{V}\_{\text{min}\text{/max}} \right) & \text{if } \boldsymbol{\phi}\_{\text{min}} \le \boldsymbol{\phi} \le \boldsymbol{\phi}\_{\text{max}}, \text{ AND } \boldsymbol{\nu} \le \boldsymbol{\nu}\_{\text{min}} \text{ OR } \boldsymbol{\nu} \ge \boldsymbol{\nu}\_{\text{max}} \\ \boldsymbol{\phi}^{\boldsymbol{k}} \left( \boldsymbol{\phi}\_{\text{min}\text{/max}}, \boldsymbol{V} \right) & \text{if } \boldsymbol{\phi} \le \boldsymbol{\phi}\_{\text{min}} \text{ OR } \boldsymbol{\phi} \ge \boldsymbol{\phi}\_{\text{max}}, \text{ AND } \boldsymbol{\nu}\_{\text{min}} \le \boldsymbol{\nu} \le \boldsymbol{\nu}\_{\text{max}} \\ \boldsymbol{\phi}^{\boldsymbol{k}} \left( \boldsymbol{\phi}\_{\text{min}\text{/max}}, \boldsymbol{V}\_{\text{min}\text{/max}} \right) & \text{if } \boldsymbol{\phi} \le \boldsymbol{\phi}\_{\text{min}} \text{ OR } \boldsymbol{\phi} \ge \boldsymbol{\phi}\_{\text{max}}, \text{ AND } \boldsymbol{\nu} \le \boldsymbol{\nu}\_{\text{min}} \text{ OR } \boldsymbol{\nu} \ge \boldsymbol{\nu}\_{\text{max}} \end{cases} \tag{10}$$

#### **4. Simulation and experimental procedures**

The effectiveness of the developed controller is evaluated through simulations within the MATLAB/Simulink using ODE solver settings, namely, Heun ODE2 and a fixed-step size of 0.001 s. The controller is implemented on the validated vehicle model from Section 2 that was set to enter each of the trajectories in **Figure 4** with an initial velocity, zero brake, and throttle settings to keep the vehicle at a constant speed of 6 m/s. The adaptive controller is compared against the two of its predecessors, namely, the Mod St from Eq. (3) and the original Stanley controller as shown in Eq. (1). Each of these controllers has been optimised using PSO with similar procedures as described in Section 3.2.1 and simulated using the same simulation settings. In evaluating the controller's performance under varying input disturbances, a set of simulations were carried out using a different trajectory as shown in **Figure 4** as well as different speed settings. The vehicle was set to travel with different speed values that are chosen randomly within and outside of the range of the knowledge database.

#### **4.1 Experimental validation against the human driver**

The adaptive path tracking controller developed in this study is validated experimentally against the human-driven responses when navigating similar paths. For this, an instrumented heavy vehicle was driven, and the driver's steering input was recorded. The same manoeuvring was simulated using the developed controller,

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

and the resulted steering input from the controller was compared against the human's driving input, to observe the validity of the automatic steering input from the controller.

**Figure 11.**

*Road course used in the experiment: (a) single lane change and (b) double lane change.*

**Figure 12.** *Road course for simulations taken from real dimensions for (a) single lane change and (b) double lane change.*

*(a) Prototype of heavy vehicle and (b) sensor configuration in driver's cockpit.*

In the experiment, two types of manoeuvrings were conducted, namely, single and double lane changes. The dimensions of the desired road were set on a level, open space as shown in **Figure 11** for both single and double lane change manoeuvrings, based on ISO-3888 [24]. These dimensions were converted into a series of coordinate points for simulation stages as shown in **Figure 12**. As one can see, the dimensions are quite short due to the limited space available. For this, only 20 km/h speed was chosen to ensure good manoeuvrings.

The manoeuvring tests are carried out with an instrumented prototype of a heavy vehicle as shown in **Figure 13**. The prototype was installed with various sensors and actuators as shown. However, for this experiment, the main sensors used are the accelerometer, gyro sensor, and rotary encoder. The rotary encoder will record the driver's steering input from steering column rotation, and from this, the wheel angle data can be deduced. Meanwhile, position data is acquired by a built-in GPS sensor in IMC DAQ that is attached to the roof of the vehicle to ensure good data transmission. Should the GPS fail, one can use the recorded acceleration data from the accelerometer, as well as vehicle speed data from the speed sensor to calculate the vehicle position in local coordinates.

From this experiment, automated manoeuvrings from the controller will be compared against the actual driving inputs from the human driver. Two observations can be deduced due to the nature of the short trajectories. First, the controller's ability in mimicking human driver behaviour can be evaluated. Second, the path tracking performance of the controller in guiding the heavy vehicle along short roads and sharp cornering can be evaluated also. The findings will be detailed in the next section.
