## 3 Controller Design
### Path Tracking Control Layer  
Equation (22) can be rewritten as:  
\[\left\{ \begin{array}{l}\dot{X}=v_{x}\cos\varphi\\ \dot{Y}=v_{x}\sin\varphi\\ \dot{\varphi}=u\end{array} \right. \tag{24}\]  
where \(u\) is the input of the control model [29]. The Path tracking problem can be expressed as: For any given geometric path \(f\Big{(}X_{def},Y_{def}\Big{)}=0\), find \(u=\dot{\varphi}\), to make the system move along the desired path. That is to say, for any given \(\varepsilon>0\), exist \(T>0\) while \(t>T\), \(f(X,Y)<0\). Define the function \(z=f(X,Y)\), the vehicle speed is \(v_{x}\). The first and second derivatives of function \(z\) can be written as follows:  
\[ \begin{array}{l}\dot{z}=f_{X}\cdot\dot{X}+f_{Y}\cdot\dot{Y}\\ =f_{X}\cdot v_{x}\cos\varphi+f_{Y}\cdot v_{x}\sin\varphi\end{array}  \tag{25}\]  
\[ \begin{array}{l}\ddot{z}=(f_{X,X}\cos^{2}\varphi+f_{Y,Y}\sin^{2}\varphi+2f_{ X,Y}\sin\varphi\cos\varphi)\cdot v_{x}{}^{2}+...\\ (f_{X}\cos\varphi+f_{Y}\sin\varphi)v_{x}{}^{\prime}+(-f_{X}\sin\varphi+f_{Y} \cos\varphi)v_{x}\dot{\varphi}\end{array}  \tag{26}\]  
where \(f_{X}=\frac{\partial f}{\partial X}\), \(f_{Y}=\frac{\partial f}{\partial Y}\), \(f_{X,Y}=\frac{\partial^{2}f}{\partial X\partial Y}\), \(f_{X,X}=\frac{\partial^{2}f}{\partial X\partial X}\), \(f_{Y,Y}=\frac{\partial^{2}f}{\partial Y\partial Y}\) setting \(\ddot{z}=\lambda\), where \(\lambda\) is the new control input. The controller is designed to make \(\lim\limits_{l\to\infty}z=0\), \(\lim\limits_{l\to\infty}\dot{z}=0\). While \(\dot{z}=0\), Equation (25) can be written as:  
\[f_{X}\cdot v_{x}\cos\varphi+f_{Y}\cdot v_{x}\sin\varphi=0 \tag{27}\]  
\[\tan\varphi=-\frac{f_{X}}{f_{Y}} \tag{28}\]  
where \(\frac{f_{X}}{f_{Y}}\) is the tangential direction of the curve \(z=f(X,Y)\) at point \((X,Y)\). The yaw rate \(\dot{\varphi}\) is controlled, while \(z\to 0\) and \(\dot{z}\to 0\), the direction of the vehicle is always the tangent of the desired path. The control algorithm can be written as follows:  
\[\dot{\varphi}=\frac{\xi}{\psi} \tag{29}\]  
\[ \begin{array}{l}\ddot{\xi}=-{v_{x}}^{2}(f_{X,X}\cos^{2}\varphi+f_{Y,Y}\sin^{ 2}\varphi+2f_{X,Y}\sin\varphi\cos\varphi)\\ -{v_{x}}^{\prime}(f_{X}\cos\varphi+f_{Y}\sin\varphi)+\lambda\end{array}  \tag{30}\]  
\[\psi=[f_{Y}\cos\varphi-f_{X}\sin\varphi]\cdot v_{x} \tag{31}\]  
Figure 3: Control block diagram. In order to facilitate the design of path planning layer, the cubic function is selected as the desired path. \[Y_{def}=a_{0}{X_{def}}^{3}+a_{1}{X_{def}}^{2}+a_{2}{X_{def}} \tag{32}\]  
Equation (32) can be written as  
\[z=f(X,Y)=a_{0}X^{3}+a_{1}X^{2}+a_{2}X-Y \tag{33}\]  
In Equations (29)-(31), \(f_{x}=\frac{\partial f}{\partial X}=3a_{0}X^{2}+2a_{1}X,f_{Y}=\frac{\partial f }{\partial Y}=-1\), \(f_{X,X}=\frac{\partial^{2}f}{\partial X\partial X}=6a_{0}X+2a_{1}\), \(f_{Y,Y}=\frac{\partial^{2}f}{\partial Y\partial Y}=0\), \(f_{X,Y}=\frac{\partial^{2}f}{\partial X\partial Y}=0\). Path tracking of autonomous vehicles is a non-linear control problem, and it will be disturbed by the change of vehicle speed and external environment. To improve the anti-jamming performance, robust performance and tracking performance of the system, a NNPID controller is designed to solve the above control problems. The neural network has the ability of self-adaptation and self-learning, hence the NNPID controller can effectively improve the unstable control effect caused by the change of the system structure and parameters [30]. It also has a wide range of applications and fast computing speed. The structure of the PID control system based on the BP (Back Propagation) network is shown in Figure 4. The controller consists of two parts:  
* A classic PID controller. The controlled object is directly controlled by closed-loop control, and the three parameters \(k_{p}\), \(k_{i}\), \(k_{d}\) are adjusted online. * A BP neural network. According to the operating state of the system, the parameters of the PID controller are adjusted so as to achieve the optimization of a certain performance index.