# Control Design and Assessment for a Reversing Tractor-Trailer System Using a Cascade Controller
## 3 Control Design
### Stability Analysis  
The stability of the proposed controller was tested by using the Lyapunov stability analysis. Recall from the third section of this paper that the objective of the controller is to minimize the lateral and the ordinate distance \((s_{FM},y_{FM})\) and also to minimize the term \((\theta_{e}-\delta_{\theta})\). Another set of objectives is to minimize the articulated angle \(\psi\). Using approaches similar to [26], the Lyapunov function is developed in Equation (24) and it satisfies the following:  
* \(\mathrm{V}(\theta_{e},\delta_{\theta},s_{FM},y_{FM},\psi)=0\) when \(\theta_{e}=0\), \(\delta_{\theta}=0\), \(s_{FM}=0\), \(y_{FM}=0\) and \(\psi=0\);
* \(\mathrm{V}(\theta_{e},\delta_{\theta},s_{FM},y_{FM},\psi)>0\) for any other value.  
To prove the system is stable one must prove that the derivative of the Lyapunov function is less than zero. Which will be shown further.  
\[V=\frac{1}{2}(\theta_{e}-\delta_{\theta})^{2}+\frac{1}{2}\Big{(}s_{FM}{}^{2}+y _{FM}{}^{2}+\psi^{2}\Big{)} \tag{24}\]  
The following assumptions are made on the candidate function:  
* The velocity \(v\) of the tractor and trailer is constant. As time goes to infinity, the velocity does not equal to zero;
* \(\delta_{\theta}(0)=0\). The derivative of the candidate function is computed in Equation (25). \[\dot{V}=(\theta_{e}-\delta_{\theta})(\dot{\theta}_{e}-\dot{\delta_{\theta}})+ s_{FM}\,\dot{s}_{FM}+y_{FM}\,\dot{y}_{FM}+\psi\dot{\psi}\] (25)  
By further simplification of Equation (25) and using Equations (15)-(23) and equating \(\dot{\theta}_{e}\) to be \(u_{\theta_{e}}\), Equation (25) becomes as shown in Equation (26).  
\[\dot{V}=-k_{3}(\theta_{e}-\delta_{\theta})^{2}+s_{FM}\,\dot{s}_{FM}+y_{FM}\, \dot{y}_{FM}+\psi\dot{\psi} \tag{26}\]  
The first term in Equation (26) is less than zero if the control gain \(k_{3}\) is greater than or equal to zero. The second and third terms in Equation (26) can be simplified to become what is shown in Equation (27).  
\[(s_{FM}\,\dot{s}_{FM}+y_{FM}\,\dot{y}_{FM})=y_{FM}(vsin(\theta_{s}-\theta_{1}) +\dot{\theta}_{1}l\,cos(\theta_{s}-\theta_{1})+\dot{\theta}_{2}L_{2}cos( \theta_{s}-\theta_{2})) \tag{27}\]  
The parameters in Equation (27) are always less than zero for the following reasons:  
* As the absolute value of \(y_{FM}\) grows (the system is moving away from the path) the angle difference \((\theta_{s}-\theta_{1})\) and \((\theta_{s}-\theta_{2})\) grows to an upper or lower bond of \(\pm\frac{\pi}{2}\) depending on the direction of \(y_{FM}\). This will cause the second and third terms of Equation (27) to be zero while the first term will have an opposite sign i.e., the result will be negative.
* As \(y_{FM}\) goes to zero, the \((\theta_{s}-\theta_{1})\) and \((\theta_{s}-\theta_{2})\) tends to zero which causes the first term to be zero. The second and third terms of Equation (27) will be zero because the rate of the \(\dot{\theta}_{1}\) and \(\dot{\theta}_{2}\) are close to zero in such a case.  
For the fourth term in Equation (26), it can be shown in Equation (28) that it is less than zero if the control command is greater than that of a determined value shown in Equation (29) where the gains \(K_{THC},K_{PC}\) and \(K_{PDC}\) are greater than zero.  
\[\dot{\psi}=-K_{THC}\dot{\psi}\,\dot{\theta}_{s}-\frac{1}{K_{PDC}K_{PC}}\,\, \varphi\dot{\psi}-\frac{1}{K_{PC}}\dot{\psi}^{2} \tag{28}\]  
\[\varphi\,\geq\,\dot{\theta}_{s}K_{THC}K_{PDC}K_{PC} \tag{29}\]  
The results of Equations (24)-(29) have proven that the derivative of the proposed Lyapunov function in Equation (24) is less than or equal to zero within the given limits and conditions. In turn this proves the stability of the proposed controller.