A Novel Method of Trajectory Optimization for Underwater Gliders Based on Dynamic Identiﬁcation

: For underwater gliders (UGs), high trajectory accuracy is an important factor in improving the observation of ocean phenomena. In this paper, a novel method of trajectory optimization is proposed to increase the trajectory accuracy of UGs, which is approximately based on the nonlinear dynamic model, rather than the linearization model. Firstly, a dynamic model of UGs is established to analyze the effect of the input parameters on the trajectory error, based on some approximate models that replaced the dynamic model due to its strong nonlinearity. Then, an identiﬁcation strategy for the trajectory error is proposed, and the trajectory optimization strategy is analyzed while considering gliding range loss and observation distance loss. Finally, the identiﬁcation strategy and trajectory optimization strategy proposed in this paper are veriﬁed by a sea trial of Petrel-L. The dynamic model, identiﬁcation strategy, and optimization strategy are appropriate for other UGs.


Introduction
With the development of marine science and technology, the scientific expedition vessel is no longer the only way of exploring the ocean. In recent years, autonomous underwater exploration has become a worldwide research hotspot. Therefore, various types of underwater equipment have been developed, such as autonomous underwater gliders, remotely operated vehicles [1], and manned submersibles [2]. The underwater glider (UG) [3] is one of the most promising ocean observation platforms, and it has been widely applied to long-duration and long-range ocean phenomena. A UG can ascend and descend in the water column, realizing horizontal motion by controlling its attitude so that its wings always generate lift. Thus, its motion is a zigzag. Since the concept of the UG was first proposed in 1989, various types of UGs have been developed successfully, such as the Slocum [4], Seaglider [5], Spray [6], Sea-Explorer [7] and Petrel-L [8].
In practical applications, UGs are required to follow planned trajectories, which are determined by specific mission requirements. Thus, the trajectory-keeping ability is an important index for UGs to better serve the observation of ocean phenomena. Generally, dynamic modeling provides an efficient way to study the trajectory accuracy of UGs, which has been established successfully with many methods, such as the Newton-Euler method [9], second Lagrange equation [10], Gibbs-Appell equation [11], differential geometry method [12], and Kirchhoff equation [13].
Based on the dynamic model, much significant research on the trajectory analysis of UGs has been carried out. Wu et al. [14] established a dynamic model of UGs validated by experimental data and studied an analysis method and a compensation strategy of glider motion accuracy. Leonard and Graver [9] derived a dynamic model of UGs to study stability and controllability of glide paths and to derive feedback control laws based on 2 of 20 linearization. Ziaeefard [15] presented a novel roll mechanism and an efficient control strategy for UGs using multiple feedforward-feedback controllers. Mahmoudian [16] presented an approximate analytical expression for steady-turning motion for a realistic UG model. Mahmoudian and Woolsey [17] described the dynamic modeling of the UG and the numerical implementation of a motion control system with approximate analytical expressions for wings-level and turning flight. Sang et al. [18] presented a new hybrid heading tracking control algorithm, which integrated an adaptive fuzzy incremental PID and an anti-windup compensator to improve the adaptability and robustness of an underwater glider's heading control. Lyu et al. [19] established a dynamic model by considering the buoyancy and pitch-regulating system and investigated the impact of the winglet on hydrodynamic performance and gliding trajectory of a blended-wing-body UG. Wu et al. [20] established a dynamic model and studied a multi-objective optimization method to determine the control parameter values that improve the performance of the glider. Smith et al. [21] investigated the implementation of a large-scale, regional ocean model into the trajectory design for autonomous gliders to improve their navigational accuracy. Wang et al. [22] designed a linear-quadratic regulator for the underwater glider and studied the motion path of the feedback control system in an ocean vertical plane. De la Cruz and Torres [23] presented a pitch-based depth-tracking controller for a hybrid UG propelled by a constant forward force applied through a single thruster. Yoon and Kim [24] addressed the optimization of the longitudinal trajectory of a UG operating in water of limited depth, obtaining the minimum-time trajectory to achieve the maximum-advance speed.
Although the above research reported some results about the trajectory of UGs, few works consider the following problems, which are summarized from the sea trial data of the Petrel-L, a UG developed by Tianjin University, China. Generally, UGs only carry an electronic compass for underwater navigation, which can measure the attitudes of UGs, including the pitch angle, roll angle, and heading. Disturbed by the ocean environment or calibration error, the heading of a UG will frequently change, and the UG will adjust to the planned value when the difference value is large enough, which will lead to the deviation from the planned trajectory. The UG cannot return to the planned trajectory on the premise that it is lacking an underwater positioning device. Thus, the problems to be solved can be summarized as: (1) What is the relationship between the trajectory of the UG and the sequence of heading adjustments? (2) How can we compute the deviation of the vehicle trajectory from the planned trajectory? (3) What motion strategies can the UG adopt to return to the planned trajectory?
To fill this research gap, this paper proposes a novel method to decrease the deviation of UGs from the planned trajectory and improve the UGs' trajectory accuracy. First, a dynamic model is established to analyze the effect of the heading adjustment on the trajectory deviation. Then, an identification strategy is presented to obtain the distance of the UG to the planned trajectory with the surrogate model method. Next, a trajectory optimization is carried out to study the advantages and disadvantages of a range of heading adjustments. Finally, a sea trial of Petrel-L verifies the correctness of the method proposed in this paper. The main contributions of this paper are summarized as follows.
(1) The effect of the heading adjustment, realized by rotating the internal mass block of the Petrel-L UG, on its trajectory error is studied with the dynamic model. (2) A systems identification is presented for the first time to obtain the deviation distance of UGs caused by heading adjustment to the planned trajectory. (3) To improve the trajectory accuracy of UGs, trajectory optimization schemes are contrasted while considering gliding range loss and observation distance loss. (4) The proposed method is verified using data from a Petrel-L sea trial.
The rest of this paper is organized as follows. Section 2 establishes the dynamic model of UGs. In Section 3, the identification strategy is introduced. Section 4 gives the trajectory optimization results and discussion, and Section 5 describes the test verification. Section 6 concludes the paper with a discussion of the future work.

Dynamic Modeling of Petrel-L
As shown in Figure 1, this paper takes the Petrel-L [8,25,26], a long-range UG developed by Tianjin University, China, as the study object. It consists of a cylindrical pressure vessel, two fixed wings, two fairings, a vertical stabilizer, and an antenna. After some optimization of hydrodynamic shape [27], pressure hull design [28], motion parameter [8,29] and multidisciplinary design [30], the gliding range of Petrel-L reached over 4000 km. To analyze the trajectory accuracy of Petrel-L, a dynamic model needs to be established. First, the coordinate frames of Petrel-L are defined to facilitate the subsequent deduction, as shown in Figure 2. Three frames, including the inertial frame, E-XYZ, body frame, O-xyz, and velocity frame, O'-x'y'z', are defined. The directions of all the coordinate axes in one frame are shown in Figure 2, which obey the right-hand rule.

Kinematics
In the inertial frame, the position and the attitude of Petrel-L are expressed by the position vector, b = [X, Y, Z] T , and the angle vector, η = [ϕ, θ, ψ] T , where the roll angle, ϕ, pitch angle, θ, and heading, ψ, denote the angles that the body frame rotates around the X-axis, Y-axis, and Z-axis, respectively, from the attitude, coinciding with the internal frame. The inertial frame, E-XYZ, can be coincident with the body frame, O-xyz, after rotating three times and following the rotation matrix of [31].
In the body frame, the velocity and the angular velocity of Petrel-L can be expressed by the velocity vector, V = [u, v, w] T , and the angular velocity vector, Ω = [p, q, r] T , involving velocities and angular velocities along the x-axis, y-axis, and z-axis, respectively. The relationship between body frame and velocity frame is determined by the angle of attack, α, and the sideslip angle, β, shown in Figure 2, and the rotation matrixes between, which can be expressed as Similarly, the relationship between the change rate of the attitude angles and the angular velocities can be expressed as ϕ = p + q tan θ sin ϕ + r tan θ cos ϕ θ = q cos ϕ − r sin ϕ ψ = (q sin ϕ + r cos ϕ)/cos θ (4) The attitude of Petrel-L in the inertial frame, ϕ(t), θ(t), ψ(t), can be obtained by integrating Equation (4).
The velocity, V, angle of attack, α, and the sideslip angle, β, are respectively expressed as

Force Analysis
When Petrel-L travels in the seawater, it is subject to external forces, including the buoyancy, weight, inertial forces, and viscous hydrodynamic forces. In addition, there exist interactive forces between the UG body and the movable internal mass block. All forces are expressed relative to a local origin, O. Before force analysis, an assumption is adopted that the displacement of Petrel-L is constant, and the mass of Petrel-L is variable when the buoyancy changes.

Buoyancy Device and Attitude Device
As shown in Figure 3a, the buoyancy device (BD) can transfer oil between the internal oil tank and external bladder, which results in the net buoyancy variation required by Petrel-L for dive or climb motion. When Petrel-L is neutrally buoyant at the sea surface, the volume of oil inside the oil tank is denoted as V bN . Thus, when the oil volume inside the internal oil tank is V b , the mass variations of the internal oil tank, ∆m bin , and the external bladder, ∆m bout , are expressed as where ρ oil and ρ w are the density of oil and seawater, respectively. Thus, compared with the neutrally buoyant state of Petrel-L, the total weight variation of buoyancy unit B b can be calculated by Equation (10). When B b is positive, Petrel-L dives in the seawater. On the contrary, it climbs when B b is negative.
In the body frame, the position variation of the transferred oil, ∆r b1 , and mass variation of seawater inside the rear fairing, ∆r b2 , can be expressed as where l bin and l bout are the distances of the internal oil tank and the external bladder to the center of buoyancy, respectively. In this paper, the bladder and the oil tank are considered to be symmetrical relative to the O-xz, so the inertia tensor variation, ∆J b , caused by oil transfer can be expressed as Petrel-L adjusts its pitch angle and heading by translating and rotating its internal mass block. This paper ignores the effect of the acceleration of the mass block on the glider motion. As shown in Figure 3b, a local coordinate frame, O p -x p y p z p , is definite at the center of weight of the mass block, the initial center of which is r p0 = [x p0 , 0, z p0 ] T .
In the body frame, when the translation distance and the rotation angle of the internal mass block are l p and ϕ r , respectively, the movement of the center of weight, ∆r p , can be expressed as: Influenced by the calibration error and some other factors, there usually exists a rotation angle error, which has an effect on the glide motion. Considering the initial rotation angle error of the mass block, ∆ϕ, ∆r p can be further expressed by Equation (13).
The increment of inertia tensor in the body frame is expressed as where

Weight, Buoyancy and Righting Moment
The gravity force and the buoyancy of the Petrel-L are G 0 and B 0 , respectively. When the glider is neutrally buoyant, the center of weight, r G0 , is where z G0 is the height of the metacenter. The inertia tensor, J 0 , of neutrally buoyant Petrel-L in the body frame is When the oil volume inside the oil tank is V b , the total mass m of Petrel-L is where m 0 is the mass of the UG when it is in the initial neutrally buoyant state. The center of mass is influenced by the relative motion of the oil and the mass block, the vector of which, r G , can be expressed as where ∆r b1 and ∆r b2 are the displacement variations of center of weight. Thus, the total inertia tensor, J, of Petrel-L can be expressed as where J x , J y , and J z are the rotational inertias relative to the x-axis, y-axis, and z-axis, respectively, J xy , J yz , and J xz are the products of inertia relative to the plane, O-xy, the plane, O-xy, and the plane, O-xy, respectively. The weight of Petrel-L F G and righting moment, T G , can be expressed as Thus, the buoyancy force, F B , acting on Petrel-L in the body frame is In the initial neutrally buoyant state, the weight, G 0 , is equal to the buoyancy B 0 .
where ρ 0 is the density of seawater at the surface, V 0 is the volume of Petrel-L under the barometric pressure.
To sum up, the net buoyancy of Petrel-L can be expressed as

Viscous Hydrodynamic Force
The viscous hydrodynamic forces, including the forces, F VHV = [D, SF, L ] T , and the hydrodynamic moments, T VHV = [ T x' , T y' , T z' ] T , are caused by the surrounding fluid when Petrel-L is in the state of steady motion.
where drag, D, side force, SF, and lift, L, are the hydrodynamic forces in the velocity frame relative to the x'-axis, y'-axis, and z'-axis, respectively, T x' ,T y' , and T z' are the hydrodynamic moments in the velocity frame relative to the x'-axis, y'-axis, and z'-axis, respectively, C D , C SF , and C L are the effective hydrodynamic force coefficients for drag, side force, and lift, respectively, and C x' , C y , ' and C z' are the effective hydrodynamic moment coefficient, for the moments in the velocity frame relative to the x'-axis, y'-axis, and z'-axis, respectively. According to the coordinate transformation relation of Petrel-L, the hydrodynamic forces and moments in the body frame can be obtained.

Inertial Hydrodynamic Force
The inertial hydrodynamic forces are caused by the surrounding fluid of Petrel-L when the UG accelerates in the seawater, which are determined by the shape of Petrel-L and the density of the fluid. Usually, the inertial hydrodynamic forces are introduced into the dynamic model by the form of the added mass. Considering the symmetry of Petrel-L, the added mass λ ij [31] of Petrel-L is In the body frame, the inertial hydrodynamic forces, F IH , and moments, T IH , are expressed as

Dynamics
In the inertial frame, the momentum, p, and the moment of momentum, L, relative to O are where V G = V + Ω × r G is the velocity of the center of mass.
In the body frame, the total external forces and the external moments acted on the Petrel-L are The dynamic equations can be obtained according to the momentum theorem and the moment of momentum theorem [20]. dp dt = dp dt where d dt is the time derivative of the vector in the inertia frame, and d dt is the time derivative of the vector in the body frame.
The decomposition equations can be expressed by Equation (39) according to the projection along the O-x axis, O-y axis, and O-z axis in the body frame.
where Fx, Fy, Fz and Tx, Ty, Tz are projections of the external force principal vector, F, and the principal moment, T, along the three axes.
Equations (2), (4) and (40) make up the dynamic model of the glider, which is used for simulating the glider motion. In this study, we use the MATLAB software to solve the dynamics, and the numerical method used is ode45, which is widely used for solving the ordinary differential equation. In the simulation, the initial values of V, Ω, b, and η are set as 0, and the variations of them can be obtained by importing the input parameters, including the oil volume V bN , inside the internal oil tank and the position of the mass pack, consisting of the translation distance, l p , and the rotation angle, ϕ r .

Trajectory Error Analysis
In this paper, we ignore the effect of the ocean current on the trajectory. Usually, Petrel-L glides in the vertical plane when the initial rotation angle error, ∆ϕ, of mass block in Equation (13) is 0 • . However, caused by the trim error and calibration error, the initial rotation angle error, ∆ϕ, of mass block exists, which leads to the deviation of heading of Petrel-L. To reduce the energy consumed by frequent heading adjustments, the heading, ∆ψ, is set as 15 • in the practical engineering, and Petrel-L begins to adjust its heading when the deviation of its heading to the planned heading, ψ T , is larger than ∆ψ. In the process of deviation of heading, Petrel-L moves in a spiral motion in the three-dimensional space, which causes Petrel-L to deviate from the vertical plane and results in the trajectory error, ∆Y, shown in Figure 4. Due to the lack of an underwater positioning sensor carried by Petrel-L, it can only adjust the heading instead of its underwater position.
Compared with the process of the deviation of heading, the adjustment of the heading is relatively quick because of a larger rotation angle of the internal mass block, ϕ r , a process which is ignored in this study. Although the heading has been adjusted as the planned heading, Petrel-L cannot return to the planned trajectory, and the trajectory error is generated. Moreover, as the number of the heading adjustments increase, the trajectory error gradually increases, and Petrel-L keeps away from the planned trajectory, which is disadvantageous for its application in ocean observation.
With the dynamic model established in Section 2, the effect of the input parameters on the trajectory error can be analyzed. Figures 5 and 6 show the trajectory errors of Petrel-L in dive motion under the different pitch angles, net buoyancies, and rotation angle errors, respectively, when the deviation of its heading gradually changes from 0 • to 15 • , which indicates that the trajectory error increases with the pitch angle and net buoyancy and decreases with the rotation angle error. Thus, the trajectory error is more dependent on the velocity of the UG because the UG moves a longer distance under the same deviation of its heading. The heading of the UG with a larger rotation angle error will change faster, and the time consumed for the deviation of heading from 0 • to 15 • is shorter, so the trajectory error is smaller.   To obtain the trajectory error of Petrel-L for trajectory optimization, an identification strategy needs to be proposed based on the dynamic model and glider datasets in the sea trial. Due to the strong nonlinearity of the dynamic model, the relationship between the input parameters (net buoyancy, pitch angle, and rotation angle errors) and the output parameters (vertical velocity, Z', horizontal velocity, V XY , and heading angular velocity ψ ) cannot be explicitly expressed by a function, which makes it difficult to directly identify the trajectory error by the data of Petrel-L. Thus, the approximate models are established to express these relationships replacing the dynamic model. The establishment processes of the approximate models are shown as follows.
(1) Design space: the design space of the approximate models needs to be determined according to the engineering practice, which is shown in Table 1. (2) Data collection: The optimal Latin hypercube method [32] is adopted the design space which can ensure a uniform distribution of the sampling points. The initial sample size is 400. Considering the symmetry of the glide motion, we use the approximated dynamic model and record from the pitch, heading, and depth sensors to estimate the trajectory error while the vehicle dives. (3) Establishment and verification: Seventy-five percent of the datasets are used to establish the approximate models in which the response surface method [33] is used. The surplus 25 percent of the datasets are used to verify the accuracies of the approximate models. If the correlation coefficients are smaller than 0.99, we will increase the sample number and repeat the processes (1)-(3) until the accuracies meet the requirements.
The approximate models established by 300 datasets are shown in Figures 7-9, which indicate the effect of the design variables on the output parameters. Figures 7 and 8 indicate that the vertical velocity, Z , and the horizontal velocity, V XY , increase with the net buoyancy, F BN , and the pitch angle, θ, and vary little with the rotation angle error, ∆ϕ. Figure 9 indicates that the heading angular velocity, ψ , increases with the net buoyancy, F BN , the pitch angle, θ, and the rotation angle error, ∆ϕ.

Identification Strategy of Trajectory Error
In this section, we try to identify the trajectory error of Petrel-L by the approximate models established above and its time series datasets in the sea trial. In Equations (41)-(43), some variables can be directly measured by the sensors carried by Petrel-L, including the pitch angle, θ, and the heading angular velocity, ψ , measured by a TCM3 sensor and vertical velocity, Z , measured by a pressure sensor. Other variables are unknown and need to be identified.
As shown in Figure 4, the trajectory error, ∆Y, can be deduced by the deviation of the heading, ∆ψ, and the arc length is calculated by the vertical velocity and heading angular velocity, ψ , shown as where t 1 and t 2 are the start time and end time of the datasets, respectively, t is the time of datasets, and ψ T is the target heading of Petrel-L.
According to Equations (41)-(44), the following identification strategies of trajectory error are generated.
(1) By data processing of the Petrel-L when its heading gradually changes in the sea trial, the time series datasets, including the pitch angle, θ, vertical velocity, Z , and heading angular velocity, ψ , can be obtained.

Trajectory Optimization Strategy and Discussion
A trajectory error, ∆Y, is caused when the rotation-steering angle has an error, ∆ϕ, after Petrel-L has adjusted its heading. The trajectory error, ∆Y, generates when the rotation angle error, ∆ϕ, of the mass block exists, and Petrel-L adjusts the heading. According to the above analysis, the trajectory error, ∆Y, can be identified by the approximate models and the datasets of Petrel-L. To make Petrel-L return to the planned trajectory and travel in the vertical plane, a trajectory optimization strategy can be proposed with a given trajectory error, ∆Y, the processes of which are shown as follows.
(1) Petrel-L begins to adjust its heading when the deviation of the heading, ∆ψ, is larger than 15 • . To compensate the trajectory error, ∆Y, a heading adjustment, ψ o , is required, shown by the red dotted lines in Figure 11. Thus, the distance travelled by Petrel-L is Figure 11. Trajectory optimization strategy.
(2) With the identification strategy proposed in Section 3, the rotation angle error, ∆ϕ, of the mass block can be obtained. After the heading adjustment 1, a rotation angle, −∆ϕ, of the mass block needs to compensate for Petrel-L to realize glide motion in the vertical plane instead of the spiral motion in the three-dimensional space.
Although the trajectory of Petrel-L can be optimized and adjusted using the above strategy to improve the trajectory accuracy, a gliding range loss of Petrel-L caused by the trajectory error and trajectory optimization strategy will be generated. In addition, the observation distance of Petrel-L along the planned trajectory becomes shorter. Thus, considering the gliding range loss and the observation distance loss, the selection of the heading, ψ o, needs to be discussed.
As shown in Figure 11, the gliding range loss can be obtained by the difference value of the actual trajectory and its projection on the planned trajectory, shown as The observation distance loss along the planned trajectory is calculated as The selection range of the heading, ψ o , is 0-90 • , and the deviation of the heading, ∆ψ, is 15 • for Petrel-L. Figure 12a,b show the gliding range loss and the observation distance loss with the heading, ψ o, respectively. As shown in Figure 12a, the gliding range loss increases with the heading, ψ o , the trend of which is basically linear. However, the observation distance loss rapidly decreases with the heading, ψ o, when the heading, ψ o , is smaller than around 10 • and varies little when it is larger than 10 • . By contrasting Figure 12a,b, the conclusion can be drawn that the gliding range loss is far less than the observation distance loss. In practical engineering, the heading, ψ o , can be determined by the specific observation missions. In some long-term observation missions, a smaller heading, ψ o, is suggested to realize a smaller gliding range loss. However, some observation missions, such as the networking observation mission with multiple gliders, require a high trajectory accuracy, and a larger heading, ψ o, is suggested for obtaining a smaller observation distance loss. Generally, a heading, ψ o , around 10 • has a comprehensive performance for realizing a smaller gliding range loss and observation distance loss.

Test Verification
To verify the effectiveness of the identification strategy proposed in this paper, we adopt some datasets of Petrel-L from 2018 in the South China Sea, the position of which is shown in Figure 13. Considering the effect of the ocean current on the trajectory error, the datasets of some profiles with lower ocean currents are selected. We choose two continuous 1000 m depth profiles of Petrel-L with the same parameter settings except for the rotation angle error, ∆ϕ, of the mass block. The rotation angle error, ∆ϕ, of the mass block in these two profiles are set as 0 • and −7 • , respectively. By using the datasets of Petrel-L, the approach proposed in this paper can be carried out to obtain the theoretical position and trajectory error of the Petrel-L at the sea surface after the profile. By contrasting the trajectory error in the sea trial and the identification results, the effectiveness of the identification strategy proposed in this paper can be verified. Moreover, after compensating the rotation angle, −∆ϕ, of the mass block, the trend of heading can also be contrasted with that before compensation, which can verify the correctness of the approximate models. The identification of the trajectory error is carried out with the software, MATLAB, in a computer with the Windows 10 system and a RAM of 8G, and the process of identification consumes about 1 min.  Figures 14 and 15 show the datasets of Petrel-L in the dive motion and the climb motion, which will be used in the identification strategy of trajectory error. As shown in Figures 14c and 15c, the heading in the dive motion is steady, which indicates that the rotation angle error, ∆ϕ, of the mass block is small enough in the dive motion. However, there exists a larger rotation angle error, ∆ϕ, of the mass block in the climb motion, which causes Petrel-L to frequently adjust its heading. This large difference is caused by the asymmetry of Petrel-L along the O-xz plane, which may be caused by the problems of assembly error, biofouling, or corrosion. In the verification, the actual position and the theoretical position of Petrel-L at the sea surface can be purely contrasted due to the lack of the real-time location of Petrel-L. Due to the accumulation of the trajectory errors in dive motion and climb motion, the datasets with the above large difference in dive motion and climb motion can better verify the approach proposed in this paper.
there exists a larger rotation angle error, Δφ, of the mass block in the climb motion, which causes Petrel-L to frequently adjust its heading. This large difference is caused by the asymmetry of Petrel-L along the O-xz plane, which may be caused by the problems of assembly error, biofouling, or corrosion. In the verification, the actual position and the theoretical position of Petrel-L at the sea surface can be purely contrasted due to the lack of the real-time location of Petrel-L. Due to the accumulation of the trajectory errors in dive motion and climb motion, the datasets with the above large difference in dive motion and climb motion can better verify the approach proposed in this paper.  In the dive motion, Petrel-L has adjusted its heading for only one time from 6010 s to 6100 s, the process of which is ignored, and other datasets can be used in the identification. According to the identification strategy in Section 3.2, the average rotation angle error, Δφ, is 0.34°, and the identification results are shown in Figure 16. As shown in Figure 16b, In the dive motion, Petrel-L has adjusted its heading for only one time from 6010 s to 6100 s, the process of which is ignored, and other datasets can be used in the identification. According to the identification strategy in Section 3.2, the average rotation angle error, ∆ϕ, is 0.34 • , and the identification results are shown in Figure 16. As shown in Figure 16b, the trajectory error of Petrel-L at the end of the dive motion is −17.17 m.
(c) In the dive motion, Petrel-L has adjusted its heading for only one time from 6010 s to 6100 s, the process of which is ignored, and other datasets can be used in the identification. According to the identification strategy in Section 3.2, the average rotation angle error, Δφ, is 0.34°, and the identification results are shown in Figure 16. As shown in Figure 16b, the trajectory error of Petrel-L at the end of the dive motion is −17.17 m.  In the climb motion, Petrel-L has adjusted its heading for only six times, the process of which is ignored, and other datasets can be used in the identification. According to the identification strategy in Section 3.2, the average rotation angle error, ∆ϕ, is 6.72 • , and the identification results are shown in Figure 17. As shown in Figure 17b In the climb motion, Petrel-L has adjusted its heading for only six times, the process of which is ignored, and other datasets can be used in the identification. According to the identification strategy in Section 3.2, the average rotation angle error, Δφ, is 6.72°, and the identification results are shown in Figure 17. As shown in Figure 17b, the trajectory error of Petrel-L in the dive motion is −274.74 m. To sum up, the total estimated trajectory error, ΔY, from the dive motion and the climb motion is −292 m, which is reasonably close to the measured trajectory error of around −379 m in the sea trial. Except the influence of the ocean current, the unsteady motion processes of Petrel-L, such as the heading adjustment and the buoyancy adjustment, may also influence the identification accuracy.
As shown in Figure 18, after giving a compensation of −7° of rotation angle error, the heading of Petrel-L varies little in the climb motion and does not need to be frequently To sum up, the total estimated trajectory error, ∆Y, from the dive motion and the climb motion is −292 m, which is reasonably close to the measured trajectory error of around −379 m in the sea trial. Except the influence of the ocean current, the unsteady motion processes of Petrel-L, such as the heading adjustment and the buoyancy adjustment, may also influence the identification accuracy.
As shown in Figure 18, after giving a compensation of −7 • of rotation angle error, the heading of Petrel-L varies little in the climb motion and does not need to be frequently adjusted anymore, which verifies the correctness of the identification results.
To sum up, by contrasting the theoretical trajectory error obtained by the approach proposed in this paper and the actual trajectory error, the identification strategy and the identification results are preliminarily verified. Thus, the underwater trajectory of Petrel-L can be adjusted by our approach in the lack of the underwater positioning sensor. To implement the approach in practical engineering, the relevant procedure can be written in the control system of Petrel-L to explore the efficiency of the approach. However, the approach proposed in this paper does not consider the effect of the ocean current on the motion of the UG, which has a certain influence on the trajectory of the UG.

Conclusions
In this paper, a dynamic model of Petrel-L is first established to carry out the trajectory error analysis. Then, the approximate models are established based on the dynamic model, with which an identification strategy of trajectory error for Petrel-L is proposed to obtain the real-time error. To reduce the trajectory error, we propose a trajectory optimization strategy while considering the gliding range loss and observation distance loss. Finally, the error of 87 m between the identification result and the actual trajectory error preliminarily verifies the approach proposed in this paper.
The uniqueness and contribution of this study are fourfold. First, the effect of the heading adjustment on the trajectory error of the Petrel-L glider is studied with the dynamic model. Second, the identification strategy is presented for the first time to obtain the deviation distance of UGs. Third, to improve the trajectory accuracy of UGs, the trajectory optimization schemes are contrasted while considering gliding range loss and observation distance loss. Forth, the proposed method is verified by the datasets of Petrel-L in the sea trial.
For future works to adequately verify the approach proposed in this paper, an underwater positioning device will be integrated by Petrel-L to obtain the real-time position of Petrel-L, and the comparison can be carried out between the theoretical real-time position and actual real-time position. In addition, the ocean current will be considered in the analysis of the trajectory error of underwater gliders, which has a certain influence on its trajectory.