Modeling and control for an underwater vehicle using dual quaternions.

In this work, the analysis of the dynamic general model of an unmanned underwater vehicle (UUV) based on dual quaternions is presented, then the general dynamic model is reduced to a speciﬁc vehicle of 4 DoF , this model eliminates the singularities that exist with the representation of the Euler angle and that the model is more compact than others proposed in the literature [1],[2]. To demonstrate the applicability of the model, three controller strategies are proposed for tracking a trajectory, the ﬁrst controller is a PD + G, under unknown disturbances it produces a considerable tracking error, the second is an adaptive controller that estimates unknown hydrodynamic parameters , and the third is a robust controller for unknown disturbances and parameter uncertainties. The closed-loop system stability analysis for each controller is based on Lya-punov’s theory, a set of numerical simulations is per-formedto show the behavior of the vehicle with the proposed controllers. The eﬃciency of the controllers is shown in Table 2 where it is deduced that the adaptive controller has a better performance. The graphics show that the robust controller has little error tracking and the computational cost is lower.


Background
Nowadays, the UUV's have had a great impact on industry and research [3], due to their applications such as 3D reconstruction [4,5], marine fauna recognition [6][7][8], marine inspection [9,10] and acquisition of physical variables such as temperature, Ph and dissolved oxygen [11]. The autonomous underwater vehicles (AUV's) perform tasks without human intervention and controlling the position of the vehicle autonomously is very important, but it has several difficulties since it must compensate the uncertainties that exist in the model, disturbances caused by sea waves and currents and other factors [12].
This article addresses the problems related to obtaining the mathematical model and the implementation of control laws capable of stabilizing their position and orientation. Several works there are different approaches to obtain the mathematical representation of this type of vehicle, among which are those proposed in [1] based on newton's laws and part of the general robotics equation, Bailey [13], a 6 DoF mathematical model was developed for surface vehicles that operate in waves. In which the inertia and damping parameters are considered, in addition to showing some simulations of standard maneuvers (straight line, the turn maneuver, the zigzag maneuver), Leonard [14] He describes the mathematical modeling for a glider-type underwater vehicle, which generates its movements from the mass distribution and changes in buoyancy. in addition to proposing a robust controller for state feedback, and Graver [15], in this work they talk about the mathematical model for underwater vehicle type glider, in which several mass are considered which together generate the movements of the vehicle, in addition to making use of physical properties such as volume change and buoyancy. This modeling is different from that of conventional underwater vehicles, although it also uses Euler's angles.
The article [2] proposes a vector mathematical model that allows taking advantage of the matrix properties of symmetry, anti-symmetry and positive, among others. This analysis can be coupled to any underwater vehicle and is based on the theory of manipulator robots. Using these equations, the design of controllers can be facilitated and the stability analysis of the system can be obtained. One way to model the behavior of vehicle movement is by using Euler's angles [1,15],this models analyze different hydrodynamic parameters, including works where the unknown parameters of mass / inertia and damping are estimated, in order to be able to compensate them [16,17], but a problem that this type of model is the singularity that exists in Euler's angles, because of this, a model was developed based on quaternions to eliminate singularities exist in the Euler angles using matrices 6 × 6 [18], another way to model dynamics and kinematics in a more compact way that includes translation and rotation is to use dual quaternions. [19,20,2,21,18], this type of model can represent the behavior of the vehicle in a more compact and simple way, consequently, the computer process is less, in addition to eliminating the singularities of the Euler angles.
To manipulate underwater vehicles one of the most used controller is PD + G [22], this type of controllers needs to know the forces of the buoyancy, which in many situations is very complicated because it does not know, also in in the demonstrating stability it is only for regulation, not for trajectory tracking, to solve the problems, adaptive controls have been developed for robots and vehicles [23] - [24] to estimate dynamic parameters and thus be able to demonstrate stability for trajectory tracking, another disadvantage that this type of controllers have is that it depends on the model and for underwater vehicles there are forces that can't be modeled. Analyzing these factors we focus on the robust controls [25] - [26] to compensate for unmodeled variables and without requiring as much computational processing as compared to adaptive controllers, in addition to they not depending as much on the model and the stability demonstration is performed for trajectory tracking.
The main contribution of this research is a dynamic representation of an underwater vehicle using dual quaternions based on all the forces studied in [1] and the dynamics of a rigid body considering some properties and physical limitations of the vehicle. Also, the development three controllers are presented in this work. A controller PD + G, an adaptive control and robust control. The proposed approaches are simulate with a same trajectory, considering unmodeled dynamics and external disturbances. In addition, a set of simulations demonstrate the performance of the proposed methods. From the comparison performed with proposed controllers, we can deduce that the robust controller has advantages, such as: a low computational cost since it does not depend of estimation of the dynamic parameters, presenting a fast convergence to trajectory. Moreover, the efficiency of the controllers is validated by numerical experiments and obtain Root Mean Square Error.
The remainder of the document is organized as follows. Section 2 the mathematical preliminaries are presented. Section 3 presents the main contribution of this paper, which is the develop of dynamic model of AUV based on dual quaternions. Next, Section 4 describes the development of three controllers using dual quaternions. Then, Section 5 demonstrates the controllers performances through a series of numerical simulations for 3D trajectory tracking. Finally, provides concluding remarks and future works.

Mathematical preliminaries
The notation to represent the sets used in this work are as follows -R represents the set of real numbers.
-H represents the set of quaternions.
-DQ is the set of dual quaternions.

Quaternion Algebra
A quaternion q ∈ H is defined as where q 0 , q 1 , q 2 , and q 3 are real coefficients, vector − → q is defined as − → q = q 0 + q 1î + q 2 + q 3k , andî, andk stand for standard imaginary units in H, which satisfŷ ı 2 = 2 =k 2 =îk = −1, we defined the product of quaternions with the symbol ⊗. The product of quaternions is obtained [27] with the following equation where − → q × − → p is the product cross between vectors.
From the equation (2) the following relationship can be obtained the norm of a quaternion is defined as: we have that the inverse and the conjugate of a quaternion with the following equation In the case of a rotation, it must be considered that the quaternion is normalized, that is q = 1. The representation of the angle of the axis, in which the quaternion is represented as an axis on which the vehicle rotates, and the angle of rotation is given by the following equation where − → Θ is the vector which contains the axis-angle representation. Now for the calculation of the derivative we have to: where− → Θ = − → ω = p q r T is the angular velocity in the body frame. For more details see [28,29].

Dual quaternions
In section 2.1, it can be seen that quaternions are used only when objects rotate, not for translational motion, due to this observation we use dual quaternions, [30] which is defined as: where − → l b is the translation of the vehicle with respect of its body reference, is a dual number, which satisfies that = 0 and 2 = 0. It is obtained that the conjugate of the dual quaternion of the equation (8) and its logarithm by the following equations: where − → P I is the position of the body seen in the inertial system. Deriving (8) we have tȯ is the twist (the combination of translation and angular velocity) and the derivativeξ is: Note the translation with respect of its inertial reference and its derivative can be rewritten as follows From [1] we have that the relationship between the speed seen in the body, − → ν = u v w T , and the speed seen in the inertial system is − → ν = q * ⊗− → P I ⊗ q. From the equation (10) we have to: Naming the following products: where Defining the norm of a dual quaternion as Fig. 1 The BlueROV2 vehicle, coordinate systems: bodyfixed-frame B and earth-fixed-frame I.

Vehicle modeling using dual quaternions
For the realization of a model of a submarine vehicle with dual quaternions, we started by analyzing the forces analyzed [2] , which is represented as follows T is the uncertainties, M is the mass and inertia matrix, C(ν) is the Coriolis matrix, g(q) describes the gravitational and buoyancy forces, , [1], [31]. The matrices M and C is formed from two matrices, where M A , C A are the hydrodynamic added inertial matrices, and M RB , C RB are the rigid-body matrices.

Model of the vehicle with dual quaternions
In this section, we complete the model of equation (13) by analyzing the forces of equation (16). For which the following dual quaternions will be searched -Dual Quaternion Coriolis.
-Dual Quaternion of gravitational forces.
For the construction of these dual quaternions, we first define the following matrices, obtained from the inverse of M RB of equation (16): where I ∈ R 3×3 is the identity matrix, m is the mass of the vehicle, I 0 ∈ R 3×3 is the Inertial matrix of the vehicle and − → r g is the position of the center of gravity and S( − → X ) is the matrix of the cross product which is defined as: Calculating the inverse of the matrix M , we have the following matrices separating the hydrodynamic parts of the inverse of matrix M i.e. M −1 −M −1 RB , we have the following matrices: where With these terms the first dual quaternions that we defined are the followinĝ To divide the elements of the rigid body from hydrodynamics, we name the dual-body rigid quaternion as: With the same idea thatĈ RB was obtained, we named the double quaternion of added mass aŝ whereĈ m =Ĉ 1 •ξ +Ĉ 2 ξ withĈ 1 =Ĉ A1 +Ĉ RB1 and C 2 =Ĉ A2 +Ĉ RB2 . We defined the following matrices, obtained from matrix D On the other hand, the dual quaternion of Damping is defined aŝ whereD m =D 1 •ξ +D 2 ξ withD 1 = D 22 + D 11 and D 2 = D 21 + D 12 . For this part we have to consider the gravity and buoyancy forces, − → f g and − → f B , which are given by the following equation: where − → W = [0, 0, mg] T and B is the buoyancy force of the vehicle. We have that the vector of gravitational forces is: with − → r B as the distance from the origin of the fixed frame to the body to the buoyancy center of the vehicle. We named the dual quaternium of gravitational forces aŝ Defining the dual quaternion of gravity forces: , (26) and (18) we can rewrite equation (13) as: Just as the matrices of the model of this article [2] have certain properties, the dual quaternions also have certain properties that must be met, so we have to consider two dual quaternions of added mass,M andM m , which are given by the following equations.
In [22] we have that the matrices M and D are positive and C is a skewsymmetric matrix, due to this it can be obtained that the dual quaternions must meet the following properties note that in the caseξ = 0 we haveM D =ξ •D = 0.

Model of the BlueROV2 with dual quaternions
In this work the BlueROV2 underwater vehicle was used, the vehicle was developed by the company Blue Robotics. The remotely operated vehicle (ROV) has 6 thrusters, the configuration is shown in the Figure 2.
By the shape of the vehicle, the following considerations are taken -We assume that origin placed in the body coincides with the center of gravity i.e. r g = − → 0 . -By the symmetry of our vehicle, it's assumed that I 0 is a diagonal matrix, in addition to going at low speeds, which is why A 11 and A 22 are diagonal matrices and A 12 =A 21 = 0. -The vehicle is stable in roll and pitch, that is to say The resulting relationship between the distribution of the thrusters and the forces generated by the propellers is presented, due to the direction of rotation in the thrusters the generated moments can be canceled.
Note that for these conditions all products with the symbol are zero, considering the conditions of the model we have the equations (18) and (21) we obtain that Figure 2, shows the diagram of forces generated by the thrusters. Calculating the body-fixed torques generated by the forces, are defined as where − → l i = (l x , l y , 0) is the position vector of the force − → F i ∀i = 1, ..., 6, with respect to the body-fixed refer-ence frame. Assuming that l x ≈ l y , θ 1 ≈ θ 2 ≈ θ 3 ≈ θ 4 and F 5 ≈ F 6 , we have from the equation (36) that: from the equation (32) we have to: where I zz is the moment of inertia in the z-axis. For the conditions of the BlueROV2 model, the equation (24) is rewritten aŝ from the equation (25) we havê for obtain the dual coriolis quaternion, we can perform the sum of the equations (39) and (40) or by the equation (26) For the calculation of this quaternion we suppose that D 12 = D 22 = 0 3×3 besides that D 11 and D 22 are diagonal matrices, for which we have the equation (28) that: due to the initial conditions we only have rotation in ψ so we have that q = cos(ψ/2) +k sin(ψ/2), this way we have the equation (29) that by the equations (21) and (31) we have to:

Control
In this section, we work three controls using dual quaternions of the equation (33), they are: -PD Control with Desired Gravity Compensation.
For the control stage we have to define the dual error quaternion for a desired dual quaternionq d = where q e = q * d ⊗ q and another way of expressing it is with the positions seen in the inertial system, this expression is ⊗ q, in this way the dual error quaternion in the system placed in the body is expressed in terms of positions obtained in the inertial system. From equations (45) and (9b), we define the error as followŝ where − → Θ e = 2 ln (q * d ⊗ q). Deriving the equation (46) in the inertial system, we have to: In the case of wanting to use the model in dual quaternions seen in the body and with measurements in the inertial system, the following convergence can be obtained from equations (12a), (12b) and (47):

PD Control with Desired Gravity Compensation
We have that the hydrodynamic parameters are difficult to model, for this reason a PD control is proposed since it does not need the hydrodynamic parameters and also its ease of implementation. For perform a PD control with desired gravity compensation for regulation i.eξ d = 0 andêξ e =ξ, and for the stability analysis of the control of the equation (50), the following theorem is proposed Theorem 1: Consider the dynamic system given by (33) withδ = 0, PD Control with Desired Gravity Compensation control strategy for regulation is designed â whereτ PD is a PD control with dual quaternions seen in the body, this is definited as: whereK p = k pω + k pν andK d = k dω + K dν where k pω , k pν , k dω , k dν ∈ R 3×3 and the matrices are positive, then it is satisfied that the error converges to zero globally asymptotically stable . Proof: Substituting (51) in (33) and (32), we have: For the stability analysis of the control of the equation (50) for regulation, the following function of Lyapunov is proposed deriving the equation we havė then using the properties of the equation (35) in the equation (54) we have to: We have thatV = 0 ifξ = 0. For prove that the system is globally asymptotically stable we use Salle's theorem, therefore: from (56) and (52) we can see that: (êq e ,êξ e ) = (0,0) is the only condition in Ω for all 0 ≤ t. This means that the equilibrium point is globally asymptotically stable according to LaSalle's theorem.

Adaptive Controller
The control PD+ĝ m is good for regulation, but for track tracking it is not adequate because we need to know the hydrodynamic parameters. In this section we used an adaptive control to estimate all model parameters that are not mass, buoyancy forces or moment of inertia, based on an adaptive control used for manipulative robots [33], for this we assume that the hydrodynamic parameters do not vary both with respect to time, because the vehicle goes at low speeds ( i.e. the parameters are almost constant). With this clarified, the following theorem is proposed Theorem 2: Consider the dynamic system given by (33) withδ = 0, for the estimation of the parameters ofĈ x andD x where x = 1, 2 which are given by equations (57) and (28) and adaptive control strategy is designed â whereβ =ξ de − q * e ⊗ [Λ •êq e ] ⊗ q e = [β p , β q , β r ] T + [β u , β v , β w ] T ,Λ = k −1 dω k pω + k −1 dν k pν and the estimate of a dual matrix or quaternionx is named asx. Then the system path error will converge to zero Proof: First proceed to parameterize the elements (see [34]) of the following way: where ζ ∈ R n×1 is the vector of the unknown nparameters andŶ (ξ,β) = Y 1 + Y 2 is dual matrix regressor with Y 1 , Y 2 ∈ R 3×n . For the estimation of the parameters of ζ, the law of updating [34] is chosen to bė whereσ =ξ −β and Γ ∈ R n×n is a positive definite matrix. Rewriting equation (58) in terms ofσ with the equations (33), (57), (35) and (59), we have tô where ζ = ζ − ζ is the estimation error. For the demonstration of stability, the estimation error is considered, ζ , the following function of Lyapunov is proposed Using the properties of (35) and the equations (60) and (59) we have that the derivative of (61) iṡ by the properties of the dual matrices of the model described by equation (35) we have thatσ •D m (σ) > 0 and since the elements ofK d are positive matrices, so we have toσ • (K d • [q * e ⊗σ ⊗ q e ]) > 0. Finally it is concluded thatV < 0 and that the system converges to zero.

Robust Controller
Due to the computation process that is required for the implementation of adaptive control and non-modeling disturbances caused by the waves that water can produce, for this reason the adaptive control may not be as efficient, due to this situation, robust control is proposed to counteract these disturbances.
For robust control the equation can be rewritten the equation (33) as: x is the dual quaternion of parameters uncertainty of the quaternion dual M x , Using equation (49) we can rewrite the model of equation (63) in terms of the error as: whereτ in consists of the nominal control inputτ N and the robust compensating inputτ RC aŝ The nominal control law is the PD control of the equation (51) and the robust compensating input as follows: whereF (s) is a robust filter that is introduced to restrain the effects of the uncertainties and is given bŷ where s is the Laplace operator and the parameters, Note that the robust compensating controlτ RC (t) is not implementable input thereby we can not measure W (t). Therefore, we obtain W (t) from (64) applying the Laplace to equation 69 we have to: from equation (70) and (66), we can have that wherê we can obtainτ RC applying the inverse Laplace to equations (71) and (72) For stability analysis the following theorem [35] was used ] T , a finite-positive constant T * , a provided constant ε > 0, with sufficiently large parameters of the robust compensator f i , g i where i = u, v, w, p, q, r which satisfy that f i >> g i > 0 and we assume that: -The sum F = 6 i=1 F i of the thrusts is bounded and satisfy that F ≤ δ, where δ is a positive constant.
-The vehicle goes at low speeds -The reference signals are derivable throughout the space.
Proof: From the equation (64) and (66), the state is described as: where with d k ∈ R 6×1 , I m×m ∈ R m×m and 0 n×n ∈ R n×n are a vector with zeros except one on the k-th row, an unit matrix and zero matrix, respectively. From the equations (64), (74) and (63) we have that there are positive constants, W 1 , W 2 and W 3 such that If δ s satisfies that from equations (77), (76) and (74), we have that where ( √ δ s + δ s )W 1 + ζê (0) ≤ W 4 . From eqs. (78) and (74) gives Therefore, the state ê ∞ are bounded. From eq. (77), one can have the attractive region as thus, ifê(t) starts from the attractive region and δ s is sufficiently small, that we have from the equation (81) that the initial stateê(0) satisfies If we chosen δ s that it satisfy δ s < (ε) 2 /(4W 2 4 ), then we can obtain a finite-positive constant T * , with sufficiently large parameters of the robust compensator f i , g i where i = u, v, w, p, q, r. Finally we have that the stateê(t) are bounded and satisfies e(t) ∞ ≤ ε, ∀T * ≤ t. .

Simulations
In this section, provide a general description of the BlueROV2 and a set of simulations tests was performed for comparison of tracking errors of controllers, considering the BlueROV2 model with dual quaternions. The BlueROV2 is a 4DOF underwater vehicle used for the numerical validation, see Figure 3. By design the underwater vehicle is stable mechanically in φ and θ, due to it's two planes of symmetry and location of buoyancy center. The prototype can operate in ROV and UUV mode, with a maximum operating depth of 100m. The dimensions of the vehicle are 45.71×33.81× 22.1cm with a weight of 11.5Kg, the known parameters of the vehicle are presented in Table ( Note that the underwater vehicle changes the value of its mass when the vehicle is submerged, therefore, the following equation is proposed

Simulation tests
Three scenarios are proposed for tracking a spherical trajectory. The first is to validate a PD + G controller, the second is to verify the efficiency of an adaptive controller and finally a robust controller is proposed. The initial conditions of the vehicle are − → P 0 = [0.0, 0.1] T and q 0 = 1. We propose a sphere trajectory q tr in the follow equation, where − → r = [0, 0, 2.9] T , Ω 1 = 0.4107t and Ω 2 = π + 0.0391t. For external disturbances, in [36] proposed the equations for modeling ocean current and waves are denoted bŷ on the other hand, damping coefficients of equation (42) are modeled as follows d 66 =0.07k + 1.55|r|k where | − → ν | = |u| |v| |w| T , D

PD Control with desired Gravity Compensation
The first scenario is a PD+G controller, in this case the gains are heuristically adjusted. The values of the coefficients of the dual matrices of the equation (51) arê For this simulation, the law of control is give for equation (50) and desired trajectory is (84). In the Figure 4, we can observed that reference is reached on the axes x and y but in the z axis is not reached because is not robust against disturbances. The results of the orientation trajectory tracking are present in Figure 5, note that the reference is reached along trajectory tracking because the orientation disturbances are small.

Adaptive Controller
The second scenario is an adaptive controller give in section 4.2 and desired trajectory is (84). We assumed that all elements of dual quaternionĈ are known and we estimated the hydrodynamic parameters of dual quater-nionD, which are the values of the constants of equation (86), for this reason the dual quaternionŶ has the  Fig. 5 Trajectory tracking of the quaternion with PD + G control where q = q 0 +q 1î +q 2 +q 3k is real quaternion (solid blue lines) and q d = q 0 d + q 1 dî + q 2 d + q 3 dk is the desired quaternion (dashed red lines). On the other hand, in Figure 8 we can see the estimation of the hydrodynamic parameters obtained in the simulation, notice that the estimation of the hydrodynamic parameters converges to the parameters introduced in the simulation.

Robust Controller
This scenario validate a robust controller give in section 4.3 and reference trajectory is (84). We assumed that we do not know the hydrodynamic values ofM 3 , the values of the dual matrices of equation (73) Fig. 7 Autonomous trajectory tracking of the quaternion with the adaptive control where q = q 0 + q 1î + q 2 + q 3k is the real quaternion (solid blue lines) obtained with the adaptive control and q d = q 0 d + q 1 dî + q 2 d + q 3 dk is the desired quaternion (dashed red lines).
In the Figure 9, we can observed that desired position is reached from the beginning, whilst the trajectory tracking of the quaternion where we can see in Figure 10.
Notice that was possible to compensate for the disturbances in the orientation.

Comparative analysis of controllers efficiency
In the Figures 11 and 12  can say that the tracking error in position is more small with adaptive controller, while that the tracking error in orientation is most small with robust control, see Table  2. Note that, the adaptive controller needs to know the hydrodynamic parameters and the computational cost is higher. On the other hand, the control inputs obtained with all controllers can be seen in the Figure 13, note that the control input of the robust control in y-axis orientation is larger than the others at first, but then remains in a range similar to the other control inputs, on the other hand the control signal of the adaptive control in the x-axis is larger than the other controllers at first, but in the other control inputs almost the same intervals are kept and another important point is with the PD + G control which is that the control input is within a region ±40N ,this fact is interesting since although it  Fig. 10 Trajectory tracking of the quaternion with the robust control where q = q 0 + q 1î + q 2 + q 3k is the real quaternion (red lines) obtained with the robust control and q d = q 0 d +q 1 dî +q 2 d +q 3 dk is the desired quaternion (dashed blue lines). does not follow the trajectory as efficiently as the other controllers it does not have over impulses like the rest.
x I y I z I θ r PD+G control 0.1659 0.5037 0.3521 0.182 Adaptive control 0.0046 0.0071 0.064 0.0293 Robust control 0.0201 0.0462 0.0742 0.0053 Table 2 Root mean square error criterion for PD + G control, adaptive controller and robust control. Notice that, the most efficient controller was the adaptive control for trajectory tracking in position but in orientation the robust control is more efficient.

Conclusion
In this research work, a kinematic and dynamic model for BlueROV2 was developed using dual quaternions, which allow us to calculate the position and orientation in a function without presenting singularities to difference of the use of representation by Euler's angles. On the other hand,mathematical properties of the model are obtained to facilitate the demonstration of the stability of the controllers based on the theory of dual quaternions. To validate the aforementioned, the development of three controllers is proposed: PD+G, adaptive control and robust control. In addition, a com-parison is made between controllers and it is observed which one presents a better performance, based on the graphs of the results and the data obtained from the Table 2, where the RMSE values are shown, it is concluded that the best performance index for the tracking of trajectory in position, it is presented by the adaptive controller, and for the case of orientation it is the robust controller. Therefore, we conclude that the adaptive controller has better performance. However, keep in mind that adaptive control needs more available information such as knowing the hydrodynamic parameters of the vehicle, moreover to being sensitive to uncertainties in the model.

ACKNOWLEDGMENTS
This work was partially supported by the Mexican National Council for Science and Technology Project Laboratorio Nacional en Vehculos Autnomos y Exoesqueletos 316256.

Declarations
Not applicable and the authors declare that they have no conflict of interest. Data sharing not applicable to this article as no datasets were generated or analysed during the current study.