# MPC and PSO Based Control Methodology for Path Tracking of 4 WS4 WD Vehicles
## 3 Control Methodology
### PSO-Based Method  
For the PSO-based method, an objective function including vehicle error states is proposed using the sliding surfaces. In Sliding Mode Control (SMC), the time-varying sliding surface is normally defined by the scalar equation \(s(\mathbf{x};t)=0\), in which \(s(\mathbf{x};t)\) is expressed by [27],  
\[s(\mathbf{x};t)=(\frac{d}{dt}+\lambda)^{n-1}\widetilde{\mathbf{x}}, \tag{53}\]  
where \(\lambda\) is a positive constant and \(\widetilde{\mathbf{x}}\) is the error state vector. According to the idea of SMC, the problem of maintaining \(\widetilde{\mathbf{x}}=0\) is transformed into keeping \(s=0\). In this work, the scalar quantities composed of vehicle error states are introduced into the definition of objective function. Instead of designing the switching control law in SMC, the optimization is used to maintain the scalar quantities on the sliding surface \(s=0\). The vehicle error state vectors including \(\widetilde{\mathbf{pos}}\), \(\widetilde{\mathbf{vel}}\) and \(\widetilde{\mathbf{acc}}\) are following the definitions in the offset model. Therefore, to track the trajectories of the RP, the vector \(\mathbf{s}=[s_{l},s_{r},s_{a}]\) needs to be defined correspondingly. Note that vector \(\mathbf{s}\) follows a different definition than that in SQP. It is defined to facilitate the notations in the local boundary part. For \(\widetilde{\mathbf{pos}}\) presented in Equation (17), its first component, which represents the position error in the longitudinal direction, is always zero. Therefore, according to Equation (53), the longitudinal scalar quantity \(s_{l}\) can be obtained as  
\[s_{l}=a_{lerr}+\lambda_{l}V_{lerr}, \tag{54}\]  
where \(a_{lerr}\) and \(V_{lerr}\) are the longitudinal components of \(\widetilde{\mathbf{acc}}\) and \(\widetilde{\mathbf{vel}}\), which are given in Equations (22) and (19), respectively. To maintain the vehicle on the RP geometrically, another first order scalar quantity \(s_{r}\) is designed as  
\[s_{r}=V_{rerr}+\lambda_{r}l_{os}, \tag{55}\]  
which aims to minimize the offset errors \(l_{os}\) and \(V_{rerr}\). The angular acceleration error \(\widetilde{\gamma}\) is included to consider the effects of forces and yaw movements of vehicle, and thus a second order scalar quantity is chosen as  
\[s_{a}=\gamma_{err}+2\lambda_{a}\Omega_{err}+{\lambda_{a}}^{2}\theta_{os}, \tag{56}\]  
where \(\theta_{os}\), \(\Omega_{err}\) and \(\gamma_{err}\) are given in Equations (17), (19) and (22), respectively. Then, the problem of following the trajectories of RP is transformed into maintaining s at 0. Using the linear scalarization, an objective function is defined as  
\[J_{\min}(F_{Sl},\delta)=C_{l}\left|s_{l}\right|+C_{r}\left|s_{r}\right|+C_{a} \left|s_{a}\right|, \tag{57}\]  
where \(C_{l}\), \(C_{r}\) and \(C_{a}\) are the weighting coefficients strictly positive and constrained by  
\[C_{l}+C_{r}+C_{a}=1. \tag{58}\]  
The variables of objective function in Equation (57) consist of the forces \(F_{Sli}\), steering angles \(\delta_{f}\) and \(\delta_{r}\), which can be written as a variable vector,  
\[\mathbf{v}_{obj}= \begin{bmatrix}\delta_{f}&\delta_{r}&F_{Sl1}&F_{Sl2}&F_{Sl3}&F_ {Sl4}.\end{bmatrix} ^{T} \tag{59}\]  
First invented by [PERSON] and [PERSON] (1995), PSO has been successfully applied to solve problems featuring nonlinearity, non-differentiable, and multiple optima. PSO is found to be capable of generating high quality solutions with more stable and faster convergence characteristics, and shorter calculation times than other stochastic methods [17]. For standard PSO at time \(t\), the updating velocity \(\mathbf{v}_{i}(t)\) and position \(\mathbf{x}_{i}(t)\) of the \(i\)-th particle are presented in the following equations:  
\[ \begin{split}\mathbf{v}_{i}(t+1)&=\zeta\mathbf{v}_{i}(t)+\phi_{ 1}\eta_{1}(\mathbf{p}_{b}-\mathbf{x}_{i}(t))+\phi_{2}\eta_{2}(\mathbf{g}_{b}-\mathbf{x}_{i}(t) ),\\ \mathbf{x}_{i}(t+1)&=\mathbf{x}_{i}(t)+\mathbf{v}_{i}(t+1),\end{split}