Path Planning of Multi-Objective Underwater Robot Based on Improved Sparrow Search Algorithm in Complex Marine Environment

: Autonomous underwater vehicle (AUV) path planning in complex marine environments meets many chanllenges, such as many inﬂuencing factors, complex models and the performance of the optimization algorithm to be improved. To ﬁnd a path with minimum cost of the actual environmental threats, navigation height changes and the minimum energy consumption of the AUV, an improved sparrow search algorithm is designed under the impact of the time-varying characteristics of the current in the complex marine environment on the AUV and the physical constraints of the AUV movement. In the proposed algorithm, an adaptive weight factor balance strategy is introduced into the position update of the discoverer to improve the convergence speed and search ability. In the follower position, the variable spiral search strategy is improved based on the position update formula to enhance the local jumping ability of the algorithm. After the position update, Levy ﬂying strategy is added, and Cauchy–Gaussian mutation is performed on the optimal individual to increase the population diversity, which improves the anti-stagnation ability of the algorithm. Finally, the AUV global path with minimum cost in the sense of multi-objective weighting is obtained. The simulation results show that the proposed algorithm can plan a path with less cost and quickly converge to an optimized point, and ﬁnally it can meet the global path planning requirements of AUV when navigating in complex sea areas.


Introduction
In recent years, marine exploration and exploitation have received increasing attention as the demand for marine resource exploration and data collection has increased, and marine resources have shown great value [1].As an important part of underwater survey, autonomous underwater vehicle (AUV) have been widely applied in scientific research, military and civil fields due to their energy, high autonomy, high flexibility and wide detection range [2][3][4].AUV research, manufacturing technology, sensors, computing power and battery technology have been continuously developed.A reliable and fully automatic decision-making robot system is the current goal of AUV research [5].However, in the complex marine environment, how to perform efficient path planning of AUV is an important key technology.
There are many commonly used global path planning methods in AUV path planning, including traditional and intelligent path planning.The traditional AUV path planning methods include the A* algorithm [6], D* algorithm [7] and artificial potential field method [8], etc.The intelligent AUV path planning methods include the particle swarm algorithm [9], ant colony algorithm [10], genetic algorithm [11] and path planning method based on machine learning [12], etc.On this basis, researchers continue to propose new path planning methods or improve and fuse previous algorithms.Zhang et al. [13] proposed an improved particle swarm optimization algorithm for the global path planning problem of AUV in the sea area with complex conditions, but this method only considered the prior environmental information and did not consider the dynamic environmental model.Yin et al. [14] proposed an imperial competition for AUV path planning in static terrain obstacles and irregular current environments.Still, they did not consider the real seabed environment and time-varying current information.Cao et al. [15] proposed a velocity vector synthesis method combined with a belief function method to overcome the influence of current on AUV navigation.Although the method considered the influence of time-varying ocean current, it did not consider the real terrain and multiple constraints.
However, most of the above studies ignore the effects of time-varying ocean current, real terrain and multiple constraints on AUV navigation.These impacts often directly affect AUV navigation; for example, strong ocean current will threaten AUV navigation safety, but reasonable use of ocean current energy can save AUV energy consumption [16].On this basis, this paper considers the effect of time-varying current characteristics on navigation and takes the actual environmental threat, the change in navigation altitude and minimum AUV energy consumption as the path planning objectives under the physical constraints of AUV motion.An improved sparrow search algorithm is designed to obtain the global path of the AUV with minimum cost in a multi-objective weighted sense.

Modeling Multi-Objective AUV Path Planning Problems in Complex Ocean Environments
Real terrain, the time-varying current model, potential threats and physical constraints of the AUV should be considered when the AUV performs its mission in complex oceanic environments.From this perspective, a comprehensive cost function for AUV navigation is established in terms of topography, sailing altitude change, energy consumption under time-varying currents, underwater threats, physical constraints, etc. Suppose a complete route has n nodes, where the coordinates of the ith navigational trajectory point are denoted (X i , Y i , Z i ) noted as g i .This paper considers that the physical constraint is that the turning angle does not exceed 90 • .The terrain constraint means that the planned path point needs to be higher than the terrain.The total cost function is as follows: where ω i is the weight coefficient; α max is the maximum turning angle; z i is the vertical height of the ith track point from the seafloor; h i is the terrain elevation value corresponding to the ith track point; f H , f T and f E are the height cost [17], threat cost [18] and energy cost [19], respectively; Equations ( 2)-( 4) are the weight coefficient constraint, maximum turning angle constraint and terrain constraint, respectively.The respective costs are as follows: where f H is the standard deviation cost function of the navigational altitude, and z is the mean of the sailing altitude.Reference [15] mentioned that the navigation height should not change too much, and a stable navigation height can reduce the burden of the control system and save more energy.
where K T is the threat coefficient; d ij is the straight-line distance from the ith trajectory point to the center j of the spherical obstacle or threat area; R Tj is the radius of the spherical obstacle or the radius of the threat area.
where k is the drag coefficient, the value of which is determined by the AUV design and is taken as 3.425 in this paper based on experience; → g i g i+1 is the modulo value of the path point g i to g i+1 vector; V is the real speed; V e is the desired speed, which is taken as 2.5 m/s; V c is the time-varying seawater velocity, which can be obtained from the time-varying ocean current equation in the literature [20].The literature only considers the cost of AUV sailing time and does not comprehensively consider other costs during sailing.cos(V e , V c ) is the cosine of the angle between the desired speed and the seawater flow velocity vector.

An Improved Sparrow Search Algorithm
The sparrow search algorithm (SSA) is an optimization algorithm proposed by imitating the group foraging behavior of sparrows [21].The main difference between this algorithm and the traditional group algorithm is that the population is divided into three categories: discoverers, followers and vigilantes.There is also an early warning mechanism.The discoverer generally has a good fitness value and is responsible for providing discovery for other individuals in the entire population to obtain food; the follower improves fitness by following the discoverers for food; the vigilant are predators that watch their surroundings for companions and threats, and sparrows that sense danger will sound an alarm to warn their companions away from it.In the process of foraging, the positions of the three will be constantly updated to obtain the optimal food source, and the position of the optimal food source is the optimal solution.To improve the optimization performance of the sparrow algorithm and improve the algorithm's shortcomings, the following focuses on the improvement strategy of the sparrow algorithm.

Discoverer Adaptive Adjustment Strategy
The discoverer adopts a random search strategy in the foraging process, and this strategy slows down the convergence rate to some extent.Inspired by [22], this paper introduces adaptive inertial weights into the discoverer's update equation, which are described mathematically as follows: where X i,j is defined as the position of the ith sparrow in the jth dimension; t is the current iteration number; R 2 is a random number from 0 to 1; ST ∈ [0.5, 1], which is taken as 0.5 in this paper; Q is a random number that obeys a normal distribution; L represents a 1 × d matrix, where each element in the matrix is 1; Iter max is the maximum iteration number; a is a constant, which is set to 1 in this paper; η is the step size adjustment coefficient, which is taken as 1.2 in this paper.ω is an adaptive inertial weight, and the value of ω decreases with the number of iterations.At the beginning of the iteration, the ω value is larger, corresponding to a wider range of sparrows preying.However, the ω value of the later iterations is small, which is beneficial to the algorithm's convergence.

Follower Variable Spiral Search Strategy
In the SSA, the follower follows the discoverer's lead and performs a detailed search around it.One can see that the discoverer has stronger global exploration ability, while the follower is better at local development.This also leads to an insufficient search range for followers, and it is easy to fall into local optimum, resulting in reduced accuracy.
Inspired by the helical flight of moths [23], this paper introduces a variable helical position update strategy, which enables the follower to have multiple search paths to update the position better while balancing the global and local search of the algorithm.After integrating the spiral strategy, the participants explore the search space in the form of a spiral, which increases the ability of the participants to explore unknown areas, then increases the possibility of the algorithm jumping out of the local optimum and is conducive to improving the global search performance of the algorithm.
The improved follower position update is as follows: z = e k×cos(π×(1−(t/Iter max ))) (11) where z varies according to the number of iterations; k is the coefficient of variation taken as 5 in this paper; l is a random number within [−1,1].X P is the current best position occupied by the finder, and X worst represents the global worst position in the current sparrow population.A denotes a 1 × d matrix where each element is randomly assigned a value of 1 or −1, and A + = A T (AA T ) −1 .

Levy Flight Strategy
This paper adds the random walk generated by the Levy flight strategy into sparrow updating.After the discoverers and followers complete the position update, the sparrow individuals satisfying the condition of Equation ( 12) are updated by the Levy flight strategy.The uncertainty in Levy's direction of flight and step length reinforces the diversification of search directions, which improves the diversity of population positions and avoids falling into the local optimum.The random Levy flight step size [24] can be obtained by the following equation: where X best is the position representing the current global optimum, f (X t i ) is the fitness value of the current sparrow individual, and f (X t+1 i ) is the fitness value after the revised Levy flight strategy.If the v fitness value is smaller than the current fitness value, then update the position according to the Levy flight strategy; otherwise, it will not be updated.L is the Levy flight path, µ and v are random numbers that follow the normal distribution, µ ∼ N(0, σ 2 µ ), v ∼ N(0, σ 2 v ), the range of the parameter β takes the value 0 < β < 2, and generally, β = 1.5.

Cauchy-Gaussian Mutation Strategy
In the foraging process, sparrows gradually move closer to the optimal individuals, resulting in insufficient population diversity, and the algorithm easily falls into local optimality.To solve this problem, this paper introduces the Cauchy-Gaussian mutation strategy [25], which mutates the individuals with the current optimal fitness to improve their global foraging ability.The mathematical description of the mutation strategy is as follows: where U t+1 best denotes the position of the optimal individual after mutation; σ 2 denotes the standard deviation of the Cauchy-Gaussian mutation; Gauhy(0, σ 2 ) is a random variable satisfying the Cauchy distribution; Gauss(0, σ 2 ) is a random variable satisfying the Gaussian distribution; λ 1 = 1 − t 2 /(Iter max ) 2 and λ 2 = t 2 /(Iter max ) 2 are dynamic parameters that adjust adaptively with the number of iterations, with λ 1 gradually increasing and λ 2 gradually decreasing in the process of finding the optimal.

Path Coding
When solving path planning problems using the sparrow search algorithm, each path is a line consisting of multiple trajectory points connected.A sparrow in the population is defined as a path X i = [X i,1 , X i,2 , • • • X i,j ], and every three dimensions X i,j in the sparrow represent the coordinates of the trajectory points in the x, y, z directions in turn, so there are j/3 navigation track points.In solving the AUV 3D path planning problem using the SSA, the number of track points n is determined, and the optimal navigation route is determined by optimizing the x, y and z coordinates.

Decoding of Path Smoothing Based on B-Spline Interpolation
The AUV navigation trajectory is composed of line segments.To ensure the smooth turning of the path and avoid the physical constraints of the AUV, the B-spline curve is used to smooth the path.The method is characterized by overall global optimization, geometric invariance, continuity, symmetry, recursion, convexity preservation and microperformance [26].Assuming that the AUV path is g and finally, a smooth path is formed.The effect of cubic spline curve is shown in Figure 1.The green line segment is the original path, and the red curve is the smoothed path.

Improved SSA for AUV Path Planning
This section describes the calculation steps of path planning using the improved SSA.The pseudo-code of the algorithm is shown in Algorithm 1, and the flow chart is shown in Figure 2. ometric invariance, continuity, symmetry, recursion, convexity preservation and microperformance [26].Assuming that the AUV path is , respectively, and finally, a smooth path is formed.The effect of cubic spline curve is shown in Figure 1.The green line segment is the original path, and the red curve is the smoothed path.

Improved SSA for AUV Path Planning
This section describes the calculation steps of path planning using the improved SSA.The pseudo-code of the algorithm is shown in Algorithm 1, and the flow chart is shown in Figure 2.
x y z , the boundaries of the map space and the number of control points n ; 7. Set the position and range of threat areas and spherical obstacles, initialize the currents and initialize the sparrow population by the principle of trajectory coding; /*Iterative search*/ 8. While(t< max Iter ) 9. Each sparrow represents a path.After decoding the generated path, the cost is calculated using the cost function Equation (1), and then the sparrow population is sorted; 10.

(1)
Update the discoverer's position using Equation (8); 13. end for 2. Set the total number of sparrows as M; 3. Set the number of discoverers as PD; 4. Set the number of sparrows perceiving danger as SD; 5. Set the alarm value as R 2 ; 6. Set the start point (x S , y S , z S ), target point (x G , y G , z G ), the boundaries of the map space and the number of control points n; 7. Set the position and range of threat areas and spherical obstacles, initialize the currents and initialize the sparrow population by the principle of trajectory coding; /*Iterative search*/ 8. While(t < Iter max ) 9. Each sparrow represents a path.After decoding the generated path, the cost is calculated using the cost function Equation (1), and then the sparrow population is sorted; 10.R 2 = rand(1); 11. for i = 1 : PD 12. Update the discoverer's position using Equation (8); 13. end for 14. for i = (PD + 1) : M 15.Update the follower's position using Equation (10); 16. end for 17. for i = 1 : SD 18.
Update the sparrow position using Equation ( 12

Simulation Experiment and Result Analysis
The simulation experiments were performed on a computer with a CPU of AMD Ryzen 7 5800H 3.5 GHz and 16 GB of RAM, operating system of Windows 10 and compiled software of Matlab R2020b.The topographic data in this paper were obtained from the Global Bathymetric Chart of Oceans (GEBCO) [27], and the latitude and longitude used are (Lng: 117.0000 • W, Lat: 23.9099 • N) and (Lng: 137.0000 • W, Lat: 17.9099 • N).Among them, the selected area is 100 × 100 km, the deepest point in the sea area is Z = 0, and the depth of other positions is determined according to the difference from this point.The X-axis is the direction of increasing longitude, and the Y-axis is the direction of increasing latitude.To reduce the calculation and improve the map diversity, the range is compressed to 200 × 200 × 200 in scale.The reciprocal interpolation method is used to approximate the environmental information of the continuous space, and the three-dimensional underwater terrain is established.Figure 3 is the three-dimensional map creation diagram.Figure 3a is the GEBCO plug-in display diagram.The red square in the figure is the selected sea area box.Select the specified sea area box to download the corresponding sampling matrix for subsequent global path planning research.Figure 3b shows the established 3D static environment map.

Simulation Experiment and Result Analysis
The simulation experiments were performed on a computer with a CPU of AMD Ryzen 7 5800H 3.5 GHz and 16 GB of RAM, operating system of Windows 10 and compiled software of Matlab R2020b.The topographic data in this paper were obtained from the Global Bathymetric Chart of Oceans (GEBCO) [27], and the latitude and longitude used are (Lng: 117.0000°W, Lat: 23.9099° N) and (Lng: 137.0000°W, Lat: 17.9099° N).Among them, the selected area is 100*100 km, the deepest point in the sea area is 0 Z = , and the depth of other positions is determined according to the difference from this point.The X-axis is the direction of increasing longitude, and the Y-axis is the direction of increasing latitude.To reduce the calculation and improve the map diversity, the range is compressed to 200 × 200 × 200 in scale.The reciprocal interpolation method is used to approximate the environmental information of the continuous space, and the three-dimensional underwater terrain is established.Figure 3 is the three-dimensional map creation diagram.Figure 3a is the GEBCO plug-in display diagram.The red square in the figure is the selected sea area box.Select the specified sea area box to download the corresponding sampling matrix for subsequent global path planning research.Figure 3b shows the established 3D static environment map.The experimental part of this paper is divided into the offshore sea scene and the distant sea scene, in which there are cylindrical threats in the offshore sea scene and spherical obstacles in the distant sea scene.As shown in Table 1, the coordinates of the starting point, end point, cylindrical threat source or spherical obstacle center of path planning in the two terrain scenarios, as well as their respective radius units are displayed.There are five algorithms in the experiment, including the improved SSA, SSA, particle swarm optimization (PSO) [28], artificial bee colony (ABC) [29] and artificial fish swarm algorithm (AFSA) [30].The PSO algorithm, ABC algorithm and AFSAS algorithm are standard original algorithms.All three algorithms are widely used in the field of 3D The experimental part of this paper is divided into the offshore sea scene and the distant sea scene, in which there are cylindrical threats in the offshore sea scene and spherical obstacles in the distant sea scene.As shown in Table 1, the coordinates of the starting point, end point, cylindrical threat source or spherical obstacle center of path planning in the two terrain scenarios, as well as their respective radius units are displayed.There are five algorithms in the experiment, including the improved SSA, SSA, particle swarm optimization (PSO) [28], artificial bee colony (ABC) [29] and artificial fish swarm algorithm (AFSA) [30].The PSO algorithm, ABC algorithm and AFSAS algorithm are standard original algorithms.All three algorithms are widely used in the field of 3D path planning and are therefore chosen for comparison.In this experiment, the parameters of all algorithms were set according to their respective references, and the population of each algorithm was set to 50, with a maximum number of 200 iterations.For the improved SSA and SSA, the number of discoverers is 20% of the total number of sparrows, the number of sparrows aware of the danger is 15% of the total, and the safety threshold is 0.8.Each algorithm is run independently 30 times, and the performance of each algorithm is evaluated and compared through the experimental results.
The simulation experiment in this paper is divided into two types of sea areas: Scenario 1: Distant Seas and Scenario 2: Offshore Seas.In the offshore sea area, there are usually defensive radar detection threat areas, so the threat cost of operating in this sea should focus on consideration.Meanwhile, the execution of distant sea operations often navigates a long distance, so the simulation under this condition should focus on the energy consumption cost.Therefore, in this paper, different coefficient weights are set in the two sea Equation ( 1) is used as the cost in both scenarios, where Table 2 is the main parameters of offshore sea and Table 3 is the main parameters of distant sea.

Comparison of Simulation Results in Offshore Sea Scenarios
The defensive-oriented offshore sea area is usually deployed with defensive radars to detect the threat area operation, and the blue columns are used to represent the inaccessible threat area for such a sea area.When the AUV accomplishes its mission in this terrain, avoiding such a dangerous area becomes one of the most important objectives.
Figure 4 shows the path trajectory of the improved SSA and the other four algorithms in the offshore sea scenario.Wherein, a and b are the route comparison map and side view in three-dimensional space, respectively, and c, d and e are potential field maps of current at T = 25, T = 50 and T = 80, respectively.The route in the figure is the plan of the AUV navigation path, the marked points are the navigation points corresponding to these moments, and the yellow circle represents the plane area of the threat area.Table 4 shows the comparison of algorithms for navigation results in the offshore area scenario.Table 5 is the comparison of cost error percentage, with the improved SSA as the benchmark.Figure 5 shows the cost curve of algorithms in the AUV offshore area scenario.It can be seen from the above figure that in the offshore sea scene, the improved SSA can not only plan a collision-free path but also the average cost is better than that of the other four algorithms.From the side view of the route comparison in Figure 4b, it can be seen that the improved SSA plans out a smoother height change than the other four algorithms, so the corresponding height change constraint is smaller.At first, it can be seen from Figure 4c that in the early stage of planning, only the AFSA can use the ocean current to navigate, and the ocean current has little influence on the planning of the other four algorithms.Secondly, as the time increases to the T = 50 moment, as shown in Figure 4d, it can be seen that the paths planned by the improved SSA, PSO algorithm and ABC algorithm can better use the ocean current energy to navigate and reduce the navigation cost.Finally, in the later stage of the navigation, as shown in Figure 4e, with the improvement at time T = 80, compared with the other three algorithms, the paths generated by the improved SSA and the SSA can still make better use of the ocean current for navigation and reduce the navigation cost.Considering comprehensive AUV navigation at different moments, from the energy consumption constraint Equation (7), it can be seen that the improved SSA can use the ocean current navigation in the main navigation phase, and the navigation distance is shorter than that of other algorithms, so the energy consumption constraint is also smaller.
Table 4 shows that the values of the improved SSA are better than those of the other It can be seen from the above figure that in the offshore sea scene, the improved SSA can not only plan a collision-free path but also the average cost is better than that of the other four algorithms.From the side view of the route comparison in Figure 4b, it can be seen that the improved SSA plans out a smoother height change than the other four algorithms, so the corresponding height change constraint is smaller.At first, it can be seen from Figure 4c that in the early stage of planning, only the AFSA can use the ocean current to navigate, and the ocean current has little influence on the planning of the other four algorithms.Secondly, as the time increases to the T = 50 moment, as shown in Figure 4d, it can be seen that the paths planned by the improved SSA, PSO algorithm and ABC algorithm can better use the ocean current energy to navigate and reduce the navigation cost.Finally, in the later stage of the navigation, as shown in Figure 4e, with the improvement at time T = 80, compared with the other three algorithms, the paths generated by the improved SSA and the SSA can still make better use of the ocean current for navigation and reduce the navigation cost.Considering comprehensive AUV navigation at different moments, from the energy consumption constraint Equation (7), it can be seen that the improved SSA can use the ocean current navigation in the main navigation phase, and the navigation distance is shorter than that of other algorithms, so the energy consumption constraint is also smaller.
Table 4 shows that the values of the improved SSA are better than those of the other four algorithms in the offshore scene.The standard deviation of the first three algorithms is significant, and the standard deviation of the last two algorithms is small.This is because the environment is more complex, and the first three algorithms have to choose a longer route to meet the navigation conditions.The improved SSA performs better on this complex optimization problem because the performance of the sparrow algorithm itself is better than that of other algorithms, and our improvement strategy is effective.Table 5 is the comparison of cost error percentage, with the improved SSA as the benchmark.Refer to literature [31] for the calculation method of error percentage.It can be seen that the performance of the first three algorithms has a gap compared with the improved SSA.There is a small gap between the improved SSA and the SSA.This is because the two algorithms have essentially been close to the extreme value in the optimization process.The improved SSA is still better than the SSA in the extreme value range.It can be seen from the above figure and table that in the offshore sea area, the improved SSA has a smaller navigation altitude change cost and can make better use of ocean current energy to reduce the energy consumption cost.The global path cost is smaller than that of other algorithms.

Comparison of Simulation Results in Distant Sea Scenarios
Distant sea areas are often faced with unfamiliar and complex terrains.Affected by ocean wind field, seawater temperature, salinity and density, ocean currents change greatly, and there are many non-topographic obstacles in such areas, such as large creatures and shipwrecks.Spherical obstacles are used to simulate these threats.This section takes the Pacific Ocean as an example to conduct a simulation study on the path planning of AUV in the distant sea scenario.
Figure 6 shows the path trajectory of the improved SSA and the other four algorithms in the distant sea scenario.Wherein, a and b are the route comparison map and side view in three-dimensional space, respectively, and c, d and e are potential field maps of current at T = 25, T = 50 and T = 80, respectively.The marked points in the figure are the navigation points corresponding to these times.Table 6 shows the comparison of algorithms for AUV navigation results in the distant sea scenario.Table 7 is the comparison of cost error percentage, with the improved SSA as the benchmark.Figure 7 shows the cost curve of algorithms for AUV in the distant sea scenario.
It can be seen from the above figure that in the distant sea area, the improved SSA can not only plan a collision-free path but also the average cost is better than that of the other four algorithms.From the side view of the route comparison in Figure 6b, it can be seen that the improved SSA plans out a smoother height change than the other four algorithms, so the corresponding height change constraint is smaller.At first, it can be seen from Figure 6c that at the beginning of the planning, the path planned by the improved SSA and SSA can sail along the current direction and reduce the navigation cost.The AFSA algorithm goes against the current in the longitudinal direction, while the PSO and ABC algorithms are less affected by the current.Secondly, as time increases to time T = 50, it can be seen in Figure 6d that the improved SSA, SSA and ABC algorithms can make good use of the ocean current energy to sail and reduce the navigation cost.Finally, at the later stage of navigation, as shown in Figure 6e, the current at time T = 80 has little influence on the navigation trajectory and the navigation cost.Considering comprehensive AUV navigation at different moments, from the energy consumption constraint Equation ( 7), it can be seen that the improved SSA can use the ocean current navigation in the main navigation stages, and the navigation distance is shorter than that of other algorithms, so the energy consumption constraint is also smaller.It can be seen from the above figure that in the distant sea area, the improved SSA can not only plan a collision-free path but also the average cost is better than that of the other four algorithms.From the side view of the route comparison in Figure 6b, it can be seen that the improved SSA plans out a smoother height change than the other four algorithms, so the corresponding height change constraint is smaller.At first, it can be seen from Figure 6c that at the beginning of the planning, the path planned by the improved SSA and SSA can sail along the current direction and reduce the navigation cost.The AFSA algorithm goes against the current in the longitudinal direction, while the PSO and ABC algorithms are less affected by the current.Secondly, as time increases to time T = 50, it can be seen in Figure 6d that the improved SSA, SSA and ABC algorithms can make good use of the ocean current energy to sail and reduce the navigation cost.Finally, at the later stage of navigation, as shown in Figure 6e, the current at time T = 80 has little influence on the navigation trajectory and the navigation cost.Considering comprehensive AUV navigation at different moments, from the energy consumption constraint Equation (7), it can be seen that the improved SSA can use the ocean current navigation in the main navigation stages, and the navigation distance is shorter than that of other algorithms, so the energy consumption constraint is also smaller.
Table 7 is the comparison of cost error percentage, with the improved SSA as the benchmark.It can be seen that there is a gap between the AFSA algorithm and ABC algorithm compared with the improved SSA.There is a small gap between the improved SSA, SSA and PSO algorithm.This is because the three algorithms approached the extreme Table 7 is the comparison of cost error percentage, with the improved SSA as the benchmark.It can be seen that there is a gap between the AFSA algorithm and ABC algorithm compared with the improved SSA.There is a small gap between the improved SSA, SSA and PSO algorithm.This is because the three algorithms approached the extreme value in the optimization process, while the improved SSA is still better than the SSA and PSO algorithm in searching for the average value in the extreme value range.It can be seen from the above figure and table that in the distant sea area, the improved SSA has a smaller navigation altitude change cost and can make better use of ocean current energy to reduce the energy consumption cost.The global path cost is smaller than that of other algorithms.

Conclusions
Aiming at the navigation problem of AUV in the time-varying ocean current environment, this paper proposes a three-dimensional path planning method based on the improved sparrow search algorithm.According to the GEBCO database, the prior map information is obtained, and the continuous space submarine terrain information is approximately obtained by using the reciprocal difference method of adjacent point distance.The cost function is determined by combining the threat model, navigation height change

Algorithm 1 :
Improved SSA algorithm AUV path planning pseudo-code /*Initialization*/ 1. Set the maximum iterations as max Iter ; 2. Set the total number of sparrows as M ; 3. Set the number of discoverers as PD ; 4. Set the number of sparrows perceiving danger as SD ; 5. Set the alarm value as 2 R ; 6. Set the start point ( , y , ) S S S xz , target point ( , , )

Figure 4 .
Figure 4. Path trajectory in the offshore sea scene.(a) Route comparison map in 3D space; (b) route comparison side view; (c) sailing position at the moment T=25; (d) sailing position at the momen T=50; (e) sailing position at the moment T=80.

Figure 4 .
Figure 4. Path trajectory in the offshore sea scene.(a) Route comparison map in 3D space; (b) route comparison side view; (c) sailing position at the moment T = 25; (d) sailing position at the moment T = 50; (e) sailing position at the moment T = 80.

Figure 5 .
Figure 5. Variation diagram of optimal route cost in offshore defensive sea area.

Figure 5 .
Figure 5. Variation diagram of optimal route cost in offshore defensive sea area.

Figure 6 .
Figure 6.Path trajectory in the distant sea scene.(a) Route comparison map in 3D space; (b) route comparison side view; (c) sailing position at the moment T=25; (d) sailing position at the momen T=50; (e) sailing position at the moment T=80.

Figure 6 .
Figure 6.Path trajectory in the distant sea scene.(a) Route comparison map in 3D space; (b) route comparison side view; (c) sailing position at the moment T = 25; (d) sailing position at the moment T = 50; (e) sailing position at the moment T = 80.

Figure 7 .
Figure 7. Variation of optimal route cost in distant sea scenario.

Post-processing and visualization
Update the optimal sparrow position using Equation (14); 28.Get the current new path; 29.If the new path is better than before, update it; 30.t = t + 1 31.end while 32.Output the best route and its cost value.33.

Table 1 .
Position parameter settings in two sea area scenarios.

Table 1 .
Position parameter settings in two sea area scenarios.

Table 2 .
The main parameters for Scenario 1.

Table 3 .
The main parameters for Scenario 2.

Table 4 .
Comparison of algorithms results in offshore sea scenarios.

Table 4 .
Comparison of algorithms results in offshore sea scenarios.

Table 5 .
Comparison of error percentage of each algorithm in the offshore scene.(Improved SSA as benchmark.)

Table 5 .
Comparison of error percentage of each algorithm in the offshore scene.(Improved SSA as benchmark.)

Table 6 .
Comparison of the results of each algorithm in the distant sea scene.

Table 7 .
Comparison of error percentage of each algorithm in the distant scene.(Improved SSA as benchmark.)Variation of optimal route cost in distant sea scenario.