## 3 Results and Discussions
### The Course Keeping Simulation Based on S Surface Controller  
#### 3.3.1 Description of S Surface Controller  
The sigmoid surface functional controller (S surface controller) is a well-proven control algorithm with good effects. At present, it is widely used in various complex motion control of underwater vehicles [32; 33; 34]. The Sigmoid surface function is a nonlinear fitting to the output of the conventional fuzzy controller. When designing fuzzy controller, the control is usually loose on both two sides and dense in the middle, i.e., the control is relatively rough when the deviation is large, while the control is relatively fine when the deviation is small, which is consistent with the trend of sigmoid function. Therefore, the sigmoid function embodies the idea of fuzzy control [34]. In this paper, the model of the S plane controller for rudder steering is expressed as Equation (12):  
\[\left\{ \begin{array}{l}e\ =\ \psi-\psi_{d}\\ \dot{e}\ =\ (\psi-\psi_{d})/\Delta t_{i}\\ o=\frac{2}{1+e^{-k_{e}-k_{e}-k_{e}}}-1\\ \delta_{ri}\ =\ \delta_{r\max}\cdot o\\ \omega_{ri}\ =\ \delta_{ri}-\delta_{ri-1}/\Delta t_{i}\end{array} \right. \tag{12}\]In Equation (12), \(\psi\) and \(\psi_{d}\) are the current yaw angle and desired yaw angle. \(e\) and \(\dot{e}\) are the normalized yaw deviation and the rate of yaw deviation respectively. \(k_{e}\) and \(k_{v}\) are the control parameters corresponding to the deviation and the rate of deviation, which reflect the weight of the yaw angle deviation and the rate of yaw angle in the control. Both of them are parameters that need to adjust for the rudder angle controller. \(o\) is the normalized output value of control system, i.e., normalized rudder angle, \(\delta_{\text{max}}\) is the maximum allowable output rudder angle, \(\delta_{ri}\) is the actual desired rudder angle, \(\omega_{ri}\) is the rate of rudder steering acquired according to time differentiation of rudder angle in every time step. In numerical calculations, the rudder rotates to the target rudder angle according to the angular rate. From the formula of the control model (12), the S surface controller combines the idea of fuzzy control with the structure of PD control, which not only simplifies the design of the controller, but also guarantee the control effect. There are only two control parameters in S surface controller model, i.e., \(k_{v}\), \(k_{v}\). These two parameters can be adjusted with referring to the concept of a proportional-differential (PD) controller. The parameters are manually adjusted so that the angular velocity of the rudder can meet the requirements of control system. Eventually, the yaw angle deviation can be limited within a small range to achieve good course keeping ability. \(k_{e}\) and \(k_{v}\) are larger, the response sensitivity to small deviations is higher, certainly, it is prone to causing the system oscillation as well. If the overshoot is large, it can be appropriate to reduce \(k_{e}\) and increase \(k_{v}\). Conversely, if the convergence is slow, it can be increased \(k_{e}\) and decreased \(k_{v}\) appropriately. In this paper, \(k_{e}\) and \(k_{v}\) are set to \(k_{e}=1\), \(k_{v}=0.5\) respectively. Furthermore, in order to simulate the rudder steering characteristics of an actual submarine as truly as possible, an S surface controller based on conditional decision mechanism is proposed to steer the rudder. Specifically, when the deviation between the actual response rudder angle and the desired rudder angle is lower than \(0.05^{\circ}\), the steering gear is not actuated, thereby avoiding the frequent manipulation of rudder in each time step. This ensures that the numerical simulation of rudder steering characteristics is more similar to the manipulation law of an actual submarine. The pseudo-code of decision mechanism is summarized as the framework shown in Figure 8.  
In the above algorithm, \(\delta_{ro}\) is the observed actual rudder angle, \(\delta_{ri}\) is the desired rudder angle calculated by the controller at time step \(i\).