## 2 Materials and Methods
### The Nonlinear Mathematical Model of the AUV's Dynamics  
To achieve a highly accurate representation of the AUV's motion and to provide realistic conditions for the control algorithms, a nonlinear mathematical model was used to describe the motion of the autonomous underwater vehicle (AUV) with both kinematic and dynamic constraints. The following assumptions are made for this model [10]:  
* The AUV is treated as a rigid body with three planes of symmetry moving in six degrees of freedom and has a longitudinal plane of symmetry, which is also the plane of symmetry of the mass distribution. * The vehicle moves in viscous fluid at a low speed and has a torpedo-like shape. * The origin of the stationary coordinate system overlaps with the center of gravity. * The mass distribution, moments of inertia, and deviant moments of a vehicle operating in a movable coordinate system are constant. * The parameters responsible for the AUV's dynamics are determined for a torpedo-shaped vehicle with a 45 kg mass and a 0.3 m diameter. These parameters could easily be adapted to other AUVs. * The PID controller parameters are tuned using a genetic algorithm [58]. * The model does not include limitations on the driving system because it is not focused on a specific driving system. The model is based on equations for motion in six DOFs, which, using the SNAME notation [59], take the following matrix-vector form:  
\[M(\hat{v})+D(v)v+g(\eta)=\tau \tag{1}\]  
where  
\(v\)--a vector of the linear and angular velocities in the movable system, expressed as  
\[v=[u,v,w,p,q,r] \tag{2}\]  
\(\eta\)--a vector of the coordinates for the vehicle's position and its Euler angles in an immovable system, expressed as  
\[\eta=[x,y,z,\phi,\theta,\psi] \tag{3}\]  
\(M\)--a matrix of inertia, which is the sum of the matrices of the rigid body \(M_{RB}\) and the added masses \(M_{A}\), expressed, respectively, as  
\[M_{RB}= \begin{bmatrix}m&0&0&0&0&0\\ 0&m&0&0&0&0\\ 0&0&m&0&0&0\\ 0&0&0&I_{x}&0&0\\ 0&0&0&0&I_{y}&0\\ 0&0&0&0&0&I_{x}\end{bmatrix}  \tag{4}\]\[M_{A}=- \begin{bmatrix}X_{\dot{u}}&0&0&0&0&0\\ 0&Y_{\dot{v}}&0&0&0&0\\ 0&0&Z_{\dot{w}}&0&0&0\\ 0&0&0&K_{\dot{p}}&0&0\\ 0&0&0&0&M_{\dot{q}}&0\\ 0&0&0&0&0&N_{p}\end{bmatrix}  \tag{5}\]  
\(D(v)\)--a hydrodynamic damping matrix, expressed as  
\[D(v)= \begin{bmatrix}X_{u}+(X_{\dot{u},\dot{v}}|u|)&0&0&0&0\\ 0&Y_{\dot{v}}+(Y_{\dot{v},\dot{v}}|v|)&0&0&0&0\\ 0&0&Z_{\dot{w}}+(Z_{\dot{w}|\dot{w}|}|v|)&0&0&0\\ 0&0&0&K_{\dot{p}}+(K_{\dot{p},\dot{p}}|P|)&0&0\\ 0&0&0&0&M_{\dot{q}}+(M_{\dot{v}|\dot{w}|}|0)\\ 0&0&0&0&0&N_{r}+(N_{[r]}|r|)\end{bmatrix}  \tag{6}\]  
where  
\(X_{u},Y_{v},Z_{w}\)--the first-order damping coefficients for the forces in the \(X,Y,Z\) directions;  
\(K_{\dot{p}},M_{\dot{q}},N_{r}\)--the first-order damping coefficients for the moments in the \(K,M,N\) directions;  
\(X_{|u|},Y_{|v|},Z_{|w|}\)--the second-order damping coefficients for the forces in the \(X,Y,Z\) directions;  
\(K_{|p|},M_{|\dot{q}|},N_{|r|}\)--the second-order damping coefficients for the moments in the \(K,M,N\) directions. \(g(\eta)\) is a vector of the restoring forces and the moments of forces of gravity and buoyancy, expressed as  
\[g(\eta)= \begin{bmatrix}(P-B)\cdot\sin\theta\\ (P-B)\cdot\cos\theta\cdot\sin\phi\\ -(P-B)\cdot\cos\theta\cdot\cos\phi\\ (z_{G}\cdot P+y_{B}\cdot B)\cdot\cos\theta\cdot\cos\phi-(y_{G}\cdot P+z_{B} \cdot B)\cdot\cos\theta\cdot\sin\phi\\ -(z_{G}\cdot P+z_{B}\cdot B)\cdot\sin\theta\cdot\cos\phi+(x_{G}\cdot P+x_{B} \cdot B)\cdot\cos\theta\cdot\cos\phi\\ 0\end{bmatrix}  \tag{7}\]  
where  
\(P\)--the weight of the body;  
\(B\)--the force of buoyancy;  
\(x_{G},y_{G},z_{G}\)--coordinates of the center of gravity;  
\(x_{B},y_{B},z_{B}\)--coordinates of the center of buoyancy;  
\(\theta\)--the pitch angle;  
\(\phi\)--the roll angle. \(\tau\)--a vector of the control signals (the sum of the vector of the forces and moments of the force generated by the propulsion system \(\tau_{p}\) and by environmental disturbances \(\tau_{d}\)). \[\tau= \begin{bmatrix}X,Y,Z,K,M,N\end{bmatrix}