# Linear Parameter-Varying Model Predictive Control of AUV for Docking Scenarios
## Appendix A
#### Rigid-Body Dynamics Model  
The nonlinear dynamics model of the AUV is formulated in a compact matrix form [14] as:  
\[M\dot{v}+C(v)v+D(v)v+g(\eta)=\tau_{A} \tag{24}\]  
where \(M\) is the matrix of the rigid-body mass. In submerged vehicles it is defined as \(M=M_{RB}+M_{AM}\) with \(M_{RB}\) the constant rigid-body inertia matrix and \(M_{AM}\) is the added inertia matrix. The \(M_{RB}\) is parametrized in the form:  
\[M_{RB}=\left[ \begin{array}{cc}mI&-m\,s(r_{G})\\ m\,s(r_{G})&I_{0}\\ \end{array} \right] \tag{25}\]  
Further, \(m\) is the mass of the vehicle, \(I\) is a 3 \(\times\) 3 identity matrix, \(s(\cdot)\) is the matrix cross product operator, \(r_{G}\) is the vector of distances of the centre of gravity from the origin of the body-fixed reference frame (in the considered model the centre of buoyancy), and \(I_{0}\) is the inertia tensor with respect to the body-fixed reference frame origin. The \(M_{AM}\) is the added mass matrix (or added inertia matrix) used to model the effect of the water displaced by the vehicle during motion. It is composed of a set of constant coefficients, such that \(\dot{M}_{AM}=0\) and:  
\[M_{AM}=\left[ \begin{array}{cccccc}X_{\dot{u}}&X_{\dot{v}}&X_{\dot{w}}&X_{ \dot{p}}&X_{\dot{q}}&X_{\dot{r}}\\ Y_{\dot{u}}&Y_{\dot{p}}&Y_{\dot{w}}&Y_{\dot{p}}&Y_{\dot{q}}&Y_{\dot{r}}\\ Z_{\dot{u}}&Z_{\dot{v}}&Z_{\dot{w}}&Z_{\dot{p}}&Z_{\dot{q}}&Z_{\dot{r}}\\ K_{\dot{u}}&K_{\dot{v}}&K_{\dot{w}}&K_{\dot{p}}&K_{\dot{q}}&K_{\dot{r}}\\ M_{\dot{u}}&M_{\dot{v}}&M_{\dot{w}}&M_{\dot{p}}&M_{\dot{q}}&M_{\dot{r}}\\ N_{\dot{u}}&N_{\dot{v}}&N_{\dot{w}}&N_{\dot{p}}&N_{\dot{q}}&N_{\dot{r}}\\ \end{array} \right] \tag{26}\]  
The coefficients for the previous added inertia matrix \(M_{AM}\), e.g., \(Y_{\dot{u}}\triangleq\partial Y/\partial\dot{u}=Y_{ud}\), are provided in the AUV specifications. Note that for an AUV this matrix is strictly positive. In Equation (24) the term \(C(v)\) is the matrix of Coriolis and centripetal terms. Two terms are used to describe these effects, so that \(C(v)=C_{RB}(v)+C_{A}(v)\) with \(C_{RB}(v)\) representing the skew-symmetrical parametrization of constant mass:  
\[C_{RB}(v)=\left[ \begin{array}{cc}0&-s(M_{11}v_{1}+M_{12}v_{2})\\ -s(M_{11}v_{1}+M_{12}v_{2})&-s(M_{21}v_{1}+M_{22}v_{2})\\ \end{array} \right] \tag{27}\]  
and \(C_{AM}(v)\) represents the effect of the added mass due to the centripetal and Coriolis effects, also defined according to the skew-symmetrical parametrization:  
\[C_{AM}(v)=\left[ \begin{array}{cc}0&-s(A_{11}v_{1}+A_{12}v_{2})\\ -s(A_{11}v_{1}+A_{12}v_{2})&-s(A_{21}v_{1}+A_{22}v_{2})\\ \end{array} \right] \tag{28}\]  
with terms \(A_{\dot{\imath}\dot{\jmath}}\) (\(i,j=1,2\)) computed as for the added mass matrix. The extended form for of \(C_{AM}(v)\) has the same structure as \(C_{RB}(v)\). In addition, in Equation (A5) the term \(g(\eta)\) is the vector of restoring forces and moments. The gravitational force is defined as \(W=mg\) (that is the weight force acting on the vehicle due to the gravity \(g\) acting on the mass \(m\)), the buoyancy is \(B=\rho g\), where \(\rho\) is the fluid density and is the total volume of fluid displaced by the vehicle. Let \(r_{g}=\big{[}x_{g},y_{g},z_{g}\big{]}^{T}\) denote the position of the centre of gravity and \(r_{B}=[x_{B},y_{B},z_{B}]^{T}\) denote the centre of buoyancy with respect to the body-fixed reference frame. The restoring forces and moments \(g(\eta)=[X_{R},Y_{R},Z_{R},K_{R},M_{R},N_{R}]^{T}\) may then be computed as:  
\[X_{R}=(W-B)\sin(\theta)\] (A10)  
\[Y_{R}=-(W-B)\cos(\theta)\sin(\Phi)\] (A11)  
\[Z_{R}=-(W-B)\cos(\theta)\cos(\Phi)\] (A12)  
\[K_{R}=\big{(}y_{g}W-y_{B}B\big{)}\cos(\theta)\cos(\Phi)-\big{(}z_{g}W-z_{B}B \big{)}\cos(\theta)\sin(\Phi)\] (A13)  
\[M_{R}=\big{(}z_{g}W-z_{B}B\big{)}\sin(\theta)+\big{(}x_{g}W-x_{B}B\big{)}\cos (\theta)\cos(\Phi)\] (A14)  
\[N_{R}=-\big{(}x_{g}W-x_{B}B\big{)}\cos(\theta)\sin(\Phi)-\big{(}y_{g}W-y_{B}B \big{)}\sin(\theta)\] (A15)  
The matrix of hydrodynamic damping terms is \(D(v)\) in Equation (A5).