## 2 Materials and Methods
### Flc  
Figure 2 presents the flowchart of the FLC. The heading error and heading error rates were obtained using the IMU sensor and water pressure gauge. Before these data were inputted into the fuzzy inference engine, they were passed through the fuzzification process by using triangular membership functions. The fuzzy rule database was also defined for the inference engine. Finally, the output values were calculated through defuzzification, based on which the ROV propeller was driven. Detailed descriptions are provided as follows. For fuzzification, triangular and trapezoidal membership functions were defined as follows [17]:  
\[A(x)=\left\{ \begin{array}{l}b\Big{(}1-\frac{|x-a|}{s}\Big{)}\ \,\ a-s\leq x\ \leq a+s\ \text{For triangular}.\\ 0,\ otherwise\\ \end{array} \right. \tag{1}\]  
\[A(x)=\left\{ \begin{array}{l}\frac{(a-x)e}{a-b},\ when\ a\leq x\leq b\\ \epsilon,\ when\ b\leq x\leq c\\ \frac{(d-x)e}{d-c},\ when\ c\leq x\leq d\\ 0,\ otherwise\\ \end{array} \right.\quad\text{For trapezoidal}. \tag{2}\]  
The parameters \(a\), \(b\), and \(s\) of the triangular function are portrayed in Figure 3a: a value \(a\), a distance \(s\), a membership function value \(b\), a lower limit \(a-s\), and an upper limit \(a+s\). The parameters \(a\), \(b\), \(c\), \(d\), and \(e\) of the trapezoidal function are portrayed in Figure 3b similarly. Using the triangular membership function, two parameters--heading error and heading error rate--were defined as input functions. Figure 4a presents 12 membership functions for the heading error: right zero (zero), right very small (RVS), right small (RS), right medium (RM), right big (RB), right very big (RVB), left very big (LVB), left big (LB), left medium (LM), left small (LS), left very small (LVS), and left zero (Zero). Membership functions for the heading error rate are presented in Figure 4b. Figure 1: The remotely operated vehicle (ROV) and experimental sensors. The red oval is a water pressure gauge. The blue oval is an inertial measurement unit (IMU) sensor. The green oval is the scanning sonar. Figure 2: Fuzzy Logic Control (FLC) flowchart. Figure 4: Fuzzy logic membership functions: (**a**) heading error and (**b**) heading error rate. The horizontal axis is the range of the error and error rate. The vertical axis is the membership function value. Figure 3: Membership functions: (**a**) Triangular and (**b**) Trapezoidal. In the fuzzy rule database, the \"if-then\" format was used to specify the relations between input and output values. Table 1 presents the fuzzy rule database of heading control for the ROV horizontal propeller. The heading error had 12 membership functions--RVB, RB, RM, RS, RVS, zero, Zero, LVS, LS, LM, LB, and LVB--and heading error rate had nine membership functions--LB, LM, LS, LVS, Zero, RVS, RS, RM, and RB. This resulted in 108 rules in the fuzzy logic database (Table 1). For example, if the heading error was RS and the heading error rate was LS, then the velocity of the horizontal propeller was LVS. Generally, the Mamdani implication method is used for fuzzy inference. When \(\mu_{A}(x)\) and \(\mu_{B}(x)\) are the minimum membership values, they can be mathematically represented as follows:  
\[\mu_{C}(x,\ y)=min(\mu_{A}(x),\ \mu_{B}(y))\,. \tag{3}\]  
Therefore, defuzzification was performed using the following gravity center:  
\[Z^{*}=\frac{\sum_{i=1}^{k}Z_{i}B^{\prime}(Z_{i})}{\sum_{i=1}^{k}B^{\prime}(Z_{ i})}\,, \tag{4}\]  
where \(Z^{*}\) is the explicit output value after defuzzification and \(B^{\prime}(Z_{i})\) is the output value from fuzzy inference. The output value \(Z_{i}\) denotes the position of the center of gravity of the fuzzy inference. Figure 5 illustrates the heading error surfaces as outputs from the FLC. Coordinate axes are inputs and outputs. The heading error and error rate were used as inputs, which were sensed using ROV sensors, and inferences were generated using fuzzy logic. The output value from the controller represented the voltage of propeller motors on the ROV.