## 3 Controller Design
### Neural Network Control  
According to the portrait phase of the sliding mode control presented in [PERSON] et al. [32] and [PERSON] [33], the first stage is when the state trajectory is outside the sliding surface and needs to be driven towards the sliding surface. Then the second phase occurs when the state trajectory movesalong towards the sliding surface. The term \(-\alpha\text{tanh}(s)-Ks\) in Equation (14) is to drive the state trajectory toward the sliding surface, whereas the slope \(\lambda\) of the sliding surface affects the convergence of state variables. The two-terms \(\lambda\) and robust term \(-\alpha\text{tanh}(s)-Ks\), in fact, depend on each other. The correlation between the two terms is depicted in Figure 3.  
Despite the robustness of the sliding mode control, the tracking performance is difficult to achieve with high precision with fixed robust gains in the presence of the external payload. Some articles have reported the algorithm for gains-tuning using the neural network method. In this part, the neural network based sliding mode control is designed to adapt with the parameter variation. The NNSMC architecture is described in Figure 4.  
As can be seen in Figure 4, instead of setting the fixed value for both the slope of the sliding surface and controller gains, in the NNSMC, the slope of the sliding surface and controller gains are considered as a weighting factor to be adjusted. Tracking error \(e\) and its change rate \(\dot{e}\) are considered as two nodal inputs of the neural network (NN). The first weights to be tuned are the gains for each \(e\) and \(\dot{e}\) that specify the slope of the sliding surface. The hidden layer is presented by using three nodes determined from the sliding surface that is an output of the input layer. Then the controller gains of the SMC are considered as the second weights to be tuned to adapt with the system dynamics. The output of the NN is a control signal. For simplicity, let \(e_{i}\) and \(\dot{e}_{i}\) be an element of \(e\) and \(\dot{e}\) (where \(i\) = 1,2,3). The input of the NN is the error and the rate of the error:  
\[x_{i1}=\left[ \begin{array}{cc}x_{i1}&x_{i2}\end{array} \right]^{T}=\left[ \begin{array}{cc}e_{i}&\dot{e}_{i}\end{array} \right]^{T}. \tag{18}\]  
The output of the first layer is:  
\[y_{i}=\lambda_{1}e_{i}+\lambda_{2}\dot{e}_{i}=\lambda_{i}x_{i1} \tag{19}\]  
where \(\lambda_{1}\) and \(\lambda_{2}\) are gains corresponding to \(e_{i}\) and \(\dot{e}_{i}\). Then, the sliding surface is modified as:  
\[s_{i}=f_{i1}(y_{i})=f_{i1}(\lambda_{i}x_{i1})=\lambda_{i}x_{i1} \tag{20}\]  
where \(f_{i1}(y_{i})\) is an activate function of the element \(i\)th. Figure 3: The motion of the state trajectory of the sliding mode control in which the two stages and the two terms affecting the convergence rate of the state error are considered. The sub-figure shows the correlation between the robust term K and \(\alpha\) with the slope of the sliding surface \(\lambda\). The input of the hidden layer is defined by:  
\[x_{i2}=\left[ \begin{array}{cc}x_{i21}&x_{i22}&x_{i23}\end{array} \right]^{T}= \left[ \begin{array}{cc}s_{i1}&s_{i2}&K_{io}\end{array} \right]^{T} \tag{21}\]  
where \(s_{i1}=s_{i},s_{i2}=\tanh(s_{i})\), and \(K_{io}\) is an offset signal to compensate the control input signal. The output of the hidden layer and the control input signal, respectively, are:  
\[u_{i}=-k_{i1}s_{i1}-k_{i2}s_{i2}-k_{i3}K_{o}(k_{ij\,(j=1,2,3)}\text{ is positive constant}) \tag{22}\]  
\[\tau_{robust\_i}=f_{i2}(u_{i})=u_{i}. \tag{23}\]  
The weighting vectors are automatically updated to minimize the cost function:  
\[E_{i}(t)=\frac{1}{2}(q_{id}(t)-q_{i}(t))^{2} \tag{24}\]  
where \(q_{id}(t)\) and \(q_{i}(t)\) represent the desired and actual trajectory, respectively, of the \(i\)th element. Let us define the cost function constant \(\varepsilon_{ei}\), \(\varepsilon_{si}\).