# Adaptive Hierarchical Sliding Mode Control for Double-Pendulum Gantry Crane Based on Neural Network
## 3 Controller Design
### Design of a Hierarchical Sliding Mode Controller Based on RBF  
The crane's double-pendulum system is divided into the position tracking control part and the angle control part, and a hierarchical sliding mode design is implemented so that while the hoisting trolley moves to the target position, the swinging of the hook and load can be effectively suppressed. Ultimately, the control force for the hoisting trolley is derived. Define the desired displacement as \(x_{d}\), and the error between the desired displacement and the actual output displacement is \(e=x-x_{d}\). Design three sliding surfaces. The first is  
Figure 2: Controller system. the sliding surface for the hoisting trolley position tracking: \(s=\dot{e}+\lambda_{1}e\), where \(\lambda_{1}>0\), and the first derivative of the sliding surface \(s_{1}\) is \(\dot{s}_{1}=\tilde{e}+\lambda_{1}\tilde{e}=\tilde{x}-\tilde{x}_{d}+\lambda_{1}( \dot{x}-\dot{x}_{d})\). Next, the sliding surfaces for the hook angle and load angle are  
\[\left\{ \begin{array}{l}s_{2}=\dot{\theta}_{1}+\lambda_{2}\theta_{1}\\ s_{3}=\dot{\theta}_{2}+\lambda_{3}\theta_{2}\end{array} \right. \tag{9}\]  
The sliding surfaces \(s_{2}\) and \(s_{2}\) represent the stability surfaces for the hook swing angle and load swing angle, respectively. \(\lambda_{2}>0\) and \(\lambda_{3}>0\) are the first derivatives of the sliding surfaces \(s_{2}\) and \(s_{3}\):  
\[\left\{ \begin{array}{l}\dot{s}_{2}=\ddot{\theta}_{1}+\lambda_{2}\dot{\theta }_{1}\\ \dot{s}_{3}=\ddot{\theta}_{2}+\lambda_{3}\dot{\theta}_{2}\end{array} \right. \tag{10}\]  
From Equation (1), the system's acceleration term \(\ddot{q}\) is  
\[\ddot{q}=M(q)^{-1}(F-C-G) \tag{11}\]  
That is,  
\[\left[\ddot{x},\ddot{\theta}_{1},\ddot{\theta}_{2}\right]^{T}=M(q)^{-1}([u,0,0 ]^{T}-C-G) \tag{12}\]  
Define a new sliding surface as  
\[S=s_{1}+\beta_{1}s_{2}+\beta_{2}s_{3} \tag{13}\]  
where \(\beta_{1}>0\), \(\beta_{2}>0\), and the derivative of the sliding surface are taken. Substituting Equation (10) and \(\dot{s}_{1}=\ddot{x}-\ddot{x}_{d}+\lambda_{1}(\dot{x}-\dot{x}_{d})\) into Equation (13) and simplifying gives  
\[ \begin{array}{l}\dot{s}=\dot{s}_{1}+\beta_{1}\dot{s}_{2}+\beta_{2}\dot{s}_{3 }\\ =\ddot{x}-\ddot{x}_{d}+\lambda_{1}(\dot{x}-\dot{x}_{d})+\beta_{1}(\ddot{\theta }_{1}+\lambda_{2}\dot{\theta}_{1})+\beta_{2}(\ddot{\theta}_{2}+\lambda_{3} \dot{\theta}_{2})\\ =M(q)^{-1}(u-C-G)-\ddot{x}_{d}+\lambda_{1}\dot{e}+\beta_{1}(\ddot{\theta}_{1} +\lambda_{2}\dot{\theta}_{1})+\beta_{2}(\ddot{\theta}_{2}+\lambda_{3}\dot{ \theta}_{2})\end{array}  \tag{14}\]  
where \(\lambda_{1}\) determines the convergence of the position and tracking displacement, and \(\lambda_{2}\) and \(\lambda_{3}\) determine the convergence speed of the swing angles. The total control law is expressed as  
\[u=u_{eq}+u_{sw}+u_{pd}+u_{a} \tag{15}\]  
where the equivalent control term is set as  
\[u_{eq}=M\ddot{x}_{d}-f(z) \tag{16}\]  
Here, \(f(z)\) represents the unknown dynamic term, which is specifically expressed as  
\[f(z)=M_{12}\ddot{\theta}_{1}+M_{13}\ddot{\theta}_{2}+C_{1}+G_{1} \tag{17}\]  
The switching control term is  
\[u_{sw}=-\eta sat(s) \tag{18}\]  
where, in the switching control term, the selected smooth saturation function is the approaching function:  
\[sat(s)=\left\{ \begin{array}{l}1,(s>\Delta)\\ ks_{s},(|s|>\Delta),k=\frac{1}{\Delta}\\ -1,(s<\Delta)\end{array} \right. \tag{19}\]Simplifying the smooth saturation function gives  
\[sat(s)=\frac{s}{|s|+\Delta} \tag{20}\]  
where \(\Delta\) is the boundary layer, \(\Delta>0\), and using the smooth saturation function helps to better resist uncertainties and disturbances. The PD control term is  
\[u_{pd}=-k_{p}e-k_{d}\dot{e} \tag{21}\]  
Both \(k_{p}\) and \(k_{d}\) are constants greater than zero. This term is used to improve the transient response and tracking accuracy. The angle compensation term is  
\[u_{a}=-k_{a}(\theta_{1}+\theta_{2}) \tag{22}\]  
where \(k_{a}\) is the angle control gain. Thus, the total control law can be expressed as  
\[