## 3 Controller Design
### RBF Neural Network  
Equation (12) does not calculate and measure the disturbance. Disturbances generated during snake robot driving are irregular and difficult to measure; therefore, when a disturbance occurs, the control gain must be increased to compensate. In this case, large chattering may occur and adversely affect the system; therefore, in this paper, the disturbance is estimated and compensated by using the RBF network. A neural network consists of an input layer, a hidden layer, and an output layer. The hidden layer of a neural network consists of many nodes. In general, the larger the number of nodes in the hidden layer, the better the approximation, but it has the disadvantage of increasing the computational speed. The RBF neural network has one layer each, it is a simple structure. So, the RBF neural network has the advantage of approximating nonlinearity with a small number of nodes by using a Gaussian function-based activation function. In this paper, we use the RBF network structure to apply a neural network to a snake robot's head system, and implement the neural network with the minimum number of nodes for online learning. The structure of the RBF neural network is shown in Figure 3a. \[Y(Z)=W^{T}H(Z) \tag{13}\]  
\[h_{ij}=\exp(-\left\|x_{i}-c_{j}\right\|^{2}/2b_{j}{}^{2}) \tag{14}\]  
Equation (13) is RBF neural network output. \(Z=[e_{1}\,e_{2}]^{T}\) is the input vector, \(W=[w_{1}\,\dots\,w_{5}]^{T}\) is the weight vector, and \(H=[h_{1}\,\dots\,h_{5}]^{T}\) is the activation function vector. The activation function is expressed as a Gaussian function as follows in Equation (14). \(c_{j}\) represents the coordinate value of center point of Gaussian function, and \(b_{j}\) represents the width of Gaussian function. In this paper, according to the scope of the input value, we use \(c=0.5\times[-1,-0.5,\ 0,\ 0.5,\ 1]\), \(b=15\). The activation function according to the change in \(c_{j}\) is shown in Figure 3b. Next, to compensate for disturbances, we assume \(D\) as in Equation (15). \[D\cong d(\bullet)\cdot\Lambda \tag{15}\]  
The disturbance is approximated by the product of the nonlinear term \(d(\bullet)\), and the error function \(\Lambda=\varpi e+\dot{e}\). The nonlinear term \(d(\bullet)\) is approximated RBF neural network as in Equation (16). \[d^{*}(\bullet)=W^{*T}\cdot H(Z) \tag{16}\]  
Figure 3: (**a**) RBF neural network; (**b**) output of Gaussian function. where \(d^{*}(\bullet)\) is an optimal approximated nonlinear term, and \(W^{*}\) is an optimal weight vector. \[\hat{d}(\bullet)=\hat{W}^{T}\cdot H(Z) \tag{17}\]  
where \(\hat{d}(\bullet)\) is the neural network approximated nonlinear term, and \(\hat{W}\) is approximated weight vector. Substituting Equations (15) and (17) into the system input, we can obtain Equation (18). \[u=M\cdot(\ddot{x}_{d}+\alpha\dot{e}/\lambda\dot{e}^{\lambda-1}-\hat{d}(\bullet )\Lambda+k\cdot\text{sgn}(s))+(C+G) \tag{18}\]  
Next, to ensure system stability and design the RBF neural network update law, we consider the Lyapunov function candidate such as Equation (19). \[V_{2}=s^{2}/2+\hat{W}^{T}\hat{W}/2\gamma \tag{19}\]  
Its time derivative is  
\[\dot{V}_{2}=\dot{s}s+\widetilde{W}^{T}\dot{\hat{W}}/\gamma \tag{20}\]  
where \(\widetilde{W}=\hat{W}-W^{*}\), \(\gamma\) is the positive network update control gain. Equations (7) and (18) are substituted into Equation (20). We can obtain Equations (21) and (22). \[\dot{V}_{2}=s(-\lambda\dot{e}^{\lambda-1}\cdot k\cdot\text{sgn}(s)+\lambda \dot{e}^{\lambda-1}\cdot\Lambda\widetilde{W}^{T}H)+\widetilde{W}^{T}\dot{ \hat{W}}/\gamma \tag{21}\]  
\[h_{ij}=\exp(-\left\|x_{i}-c_{j}\right\|^{2}/2b_{j}{}^{2}) \tag{14}\]0  
where \(\lambda\dot{e}^{\lambda-1}\cdot k\cdot s\cdot\text{sgn}(s)\) is always positive. To realize asymptotic stability \(\dot{V}_{2}<0\), we can obtain RBF neural network update law Equation (23). \[h_{ij}=\exp(-\left\|x_{i}-c_{j}\right\|^{2}/2b_{j}{}^{2}) \tag{14}\]1  
where \(\sigma\) is positive momentum control gain.