Abstract

Unmanned aerial vehicle (UAV) has been widely used in various fields, and meeting practical high-quality flight paths is one of the crucial functions of UAV. Many algorithms have the problem of too fast convergence and premature in UAV path planning. This study proposed a sparrow particle swarm algorithm for UAV path planning, the SPSA. The algorithm selects a suitable model for path initialization, changes the discoverer position update, and reinforces the influence of start-end line on path search, which can significantly reduce blind search. The number of target points reached is increased by adaptive variable speed escapes in areas of deadlock. In this case, the planned trajectory will fluctuate, and adaptive oscillation optimization can effectively reduce the fluctuation of the path. Finally, the optimal path is simplified, and the path nodes are interpolated with cubic splines to improve the smoothness of the path, which improves the smoothness of the UAV flight trajectory and makes it more suitable for use as the UAV real flight trajectory. By comparison, it can be concluded that the improved SPSA has good convergence speed and better search results and can avoid local optimality.

1. Introduction

Unmanned aerial vehicle (UAV) has been widely used in various fields, such as transportation, rescue, and military, with the continuous progress of technology. Compared with ground robot path planning, the path planning of UAV in 3D environment increases the complexity of trajectory calculation as the spatial dimension rises. UAVs are affected by buildings, weather, and their energy consumption during flight, so how to plan a safer, more efficient, and faster path is an ongoing hot research problem. Traditional algorithms such as the A algorithm [1], artificial potential field method [2, 3], and RRT [4] have been used for path planning, but most of them still suffer from high computational complexity and local convergence.

A heuristic algorithm is a new solution algorithm obtained by imitating various natural phenomena and summarizing and refining that natural phenomenon. The heuristic algorithm can solve some problems that ordinary methods cannot solve. The UAV path planning problem is a multivariate problem in the real environment to find the optimal solution. Many scholars have studied this problem with heuristic algorithms [511] to find suitable solutions. Duan [12] et al. used the maximum-minimum adaptive ant colony optimization algorithm to replan the UAV collaborative path in dynamic and uncertain environments, determine the time for the UAV to reach the conflict point, and then determine the flight trajectory and speed of the UAV to avoid static threats and popup threats. Shiri et al. [13] proposed a neural network-assisted online control algorithm for remote UAV paths that enable UAV to make control decisions locally in harsh communication environments, thereby reducing travel time. Qu [14] et al. proposed a reinforcement learning algorithm based on the grey wolf algorithm that adaptively switches selection by controlling the performance accumulated by individual four operations of exploration, exploitation, geometric adjustment, and optimal adjustment, which has better results than other improved grey wolf algorithms. Duan [15] et al. proposed a UAV path planning based on an improved water droplet algorithm, which considers the effects of ice accumulation, Richardson number, meteorological changes, and different flight altitudes on UAV path planning. They used the virtual potential field method to adjust the flight direction of the UAV to perform static path planning and dynamic path planning for the UAV. Liu [16] et al. proposed an evolutionary algorithm based on the evolutionary algorithm for UAV path planning, which changes the distribution algorithm to effectively solve the high computational complexity and low efficiency in UAV dynamic path planning.

The sparrow search algorithm [17] is a new heuristic algorithm proposed by Jiankai Xue in 2020, and it is a group intelligence algorithm that imitates sparrow predation. The algorithm has the characteristics of fast convergence and merit-seeking solid ability. The sparrow search algorithm has been widely used in the field of control engineering, for example, tracking the maximum power point [18], network configuration [19], and path planning field [20]. Liu [21] proposed a modified sparrow search algorithm (CASSA) to balance the convergence speed and searchability. The algorithm improved the efficiency of path planning by the Corsi–Gaussian variation strategy and adaptive inertia weights. Ouyang [22] proposed the learning sparrow search algorithm (LSSA) to improve stability and security. This algorithm solves the shortcomings of strong randomness and easy to fall into local optimum. Abdulhammed [23] applied the sparrow search algorithm to the load balancing problem of cloud computing by separately provisioning different tasks to shorten the server response time and reduce power consumption. The algorithm shows that the advantages of fast convergence and good searchability of the sparrow search algorithm are highly applicable in solving engineering problems.

Particle swarm algorithm [24] is an algorithm proposed by James Kennedy and Russell Eberhart, which has the characteristics of fast convergence and simple structure. Many scholars have applied it to various optimization scenarios [2530] and achieved good results. Li [31] proposed an SLPSO algorithm for solving collision hazards, insufficiently smooth paths, and long planning paths of mobile robots in path planning, and the experimental results showed that the algorithm is effective and feasible. Phung [32] proposed an improved discrete particle swarm algorithm (DPSO) to be used in UAV path planning to improve the algorithm's performance through qualitative initialization, random variation, and edge swapping by taking advantage of parallel computing. Foo [33] proposed a particle swarm algorithm-based 3D UAV path planning that considers the fuel consumption of the UAV, flies over specified obstacles, and leaps over specified reconnaissance targets. Thabit [34] proposed a multi-robot particle swarm optimization algorithm for multi-UAV path planning in unknown situations. The robot decides the direction of movement based on the information collected by sensors and combines probabilistic windows to obtain current information and previous robot experience to select the path with better fitness.

In the field of human-machine path planning, the current UAV still suffers from the problem of locally optimal solutions, making it difficult to search for globally optimal paths. A novel SPSA is proposed for this problem, which guides the subsequent path search through path initialization. The discoverer position update rule is improved to enhance the search near the start-end line. Adaptive variable speed escape search is used to improve the search efficiency of paths when obstacles are encountered. Adopting adaptive oscillation optimization reduces path fluctuations and improves path smoothing. Finally, the path smoothness is improved by simplifying the nodes and smoothing process, which is more suitable for path planning in the real environment. It is also verified that the SPSA has a shorter convergence path and lower energy consumption than other algorithms.

The structure of this study is as follows: Section 2 establishes the environment model that matches the actual situation. Section 3 describes the specific implementation of the sparrow search algorithm and the particle swarm algorithm. Section 4 describes the specific implementation of the SPSA. Section 5 draws the corresponding structure and flow chart for the structure of the SPSA. Section 6 analyzes the experimental results for the algorithm complexity analysis and experimental results. Section 7 concludes the SPSA.

2. Environment Modelling

In the actual complex environment, the UAV will encounter multiple threats such as obstacles and trees in reaching the target set from the start point, and sometimes, it also needs to consider the climate, the energy of the UAV, and other factors. The main problem of UAV path planning is the path optimization problem considering multiple disturbance factors. By building a mathematical model, the optimal flight path is calculated.

2.1. Environmental Model Building

The movement of the UAV is less restricted by the terrain and can reach the target point quickly in a complex environment, but the trajectory of the UAV's movement is in a three-dimensional environment. The three-dimensional environment is more complicated than the two-dimensional environment. The amount of calculation will also be tremendous. To reduce the time of UAV path calculation, the establishment of a suitable model has an important influence on the calculation of the optimal path. This study adopts the modelling method in the literature [35]. Each time the position is selected, it will move forward by one unit in the x-axis direction, simplifying the three-dimensional path problem into a two-dimensional path planning problem.

Assuming that the velocity of the UAV flight is variable and disregarding the effect of the structure of the UAV on the flight, the square tall building in the real environment is equated to a square obstacle, and the cylindrical building is equated to a cylindrical obstacle, as shown in Figure 1.

2.2. Adaptability Calculation

The trajectory of the UAV flight is usually close to the line between the start point and the endpoint (start-end line) when avoiding obstacles, while the path should be as smooth as possible. The distance and the safety of UAV from the obstacles are considered in the literature [14]. However, the computational effort also increases with the increase in obstacles, which is not conducive to finding the globally optimal path. Considering the energy loss of UAV, a new fitness calculation is proposed as follows:

The fitness value of UAV flight is the total energy required for UAV path planning. is the energy consumed for all planned paths assuming that the UAV flies at a constant speed. indicates the additional energy consumed for UAV flight turning. indicates the energy is required for UAV climbing and landing. represents the energy consumption for climbing and landing. It is assumed that the energy of the UAV flight consists of three parts, and one part is the energy of uniform flight, and it is assumed that the energy consumption of this part is proportional to the distance flown. The second part is that when turning, there will be additional turning energy loss in addition to the first part of energy. When the turning angle is larger, as the speed remains the same centripetal force is needed to do work, more energy is needed to maintain a constant speed and complete the flight turning. Similarly, more work is required to move the aircraft in the vertical direction, assuming that the energy required by the UAV is proportional to the distance travelled in the vertical direction. Each part of the solution equation is as follows:

Here, , , and denote the coordinates of , , and axes of the nodes, respectively, denotes the turning angle coefficient, and denotes the angle between two adjacent line segments. When the angle is larger, the trajectory is smoother, and the fuel cost is lower. When the turn is smaller, the UAV needs to slow down, steer, and accelerate the process, which will consume more fuel. denotes the variation on the z-axis between two adjacent nodes, where , , and are scale factors. The fitness is performed by cubic spline interpolation, and the summation is performed for each slice of the fitness, which is similar to the energy consumption in the real situation.

As the UAV flight in the actual situation of variable speed flight needs to adjust the route to avoid trees, buildings, and other obstacles, UAV flight steering requires more energy , while for the flight trajectory without substantial height oscillation, the flight altitude constantly changes will also consume more energy. In general, the optimal adaptation in UAV flight corresponds to a smooth and smooth flight trajectory.

3. Basic Theoretical Algorithms

The choice of the algorithm has an essential impact on path planning. A suitable algorithm can improve the convergence of the optimal path and avoid local optima. This section describes the specific implementation of the involved sparrow search algorithm and particle swarm algorithm.

3.1. Basic Sparrow Search Algorithm

The sparrow search algorithm is a novel bionic algorithm with fast convergence and merit-seeking solid ability. Sparrows are divided into producers and scroungers. The identities of producers and scroungers can be interchanged, but the weight remains the same in the population. The producer with good adaptation in the sparrow search algorithm will get food first. The producers' positions are updated by the following equation

Here, denotes the current iteration, denotes the serial number of the current scrounger, denotes the dimension, is a random number, and denotes the maximum number of iterations. and denote the warning value and safety value, which are constants, is a random number, and is a 1 × d matrix, and each element is 1. When , it means there are no predators around the foraging environment, and the scrounger can conduct an extensive search. If , it means that some sparrows in the population found the predator and alerted other sparrows, and then, the sparrows needed to fly to other places for foraging.

The scrounger will watch the scrounger, and if it perceives that the scrounger has found better food, it will leave its present position to grab the food, and if it wins, it gets the scrounger's food. The scrounger's position is updated as follows:

Here, denotes the optimal position of the next iteration, is the worst position in the current iteration, and is the number of scroungers, where denotes a  ×  matrix where each element is randomly assigned to 1 or -1, and . When , the less adapted scroungers need to fly elsewhere in search of food.

Sparrows aware of the danger account for 10% to 20% of the total population. The locations of these sparrows are updated as follows:

Here, is the current global best position, and are random numbers, and are the current global best and worst fitness values, and is a constant to avoid the denominator being zero.

The presence of obstacles in the environment of UAV path planning can interfere with the sparrow search algorithm to search the optimal and worst paths, resulting in the presence of unsearchable target points and loss of good search routes. Since the absolute value of each element in is the same, the presence of obstacles in the planned path loses the number of individuals.

3.2. Basic Particle Swarm Algorithm

The particle swarm algorithm is an algorithm that is studied by imitating the predatory behaviour of a flock of birds. The particle swarm algorithm uses massless particles to simulate the birds in a flock, and the particles have velocity and position properties. The optimal solution obtained by each particle searching for a single individual in space is used as the individual's extremum, and the extremum of all individuals is used as the optimal global solution. All particles in the swarm adjust their velocity and position according to the current individual extreme value and the optimal global solution.

The particle swarm algorithm first initializes the position of the particle itself and adjusts its position by iteration. In each iteration, the particle adjusts its speed by the extreme individual value and the optimal global solution, thus changing its position. The particle swarm algorithm velocity and position updates are shown in equations (6) and (7) as follows:

Here, denotes the velocity in -dimensional space of the particle with index , denotes the position in -dimension corresponding to the particle with index obtaining the local extremum, and denotes the position in -dimension corresponding to the optimal global solution obtained by all particles. is a random number from 0 to 1, and and are learning factors.

The corresponding pseudocode for the basic particle swarm algorithm 1 is shown below.

Initialize
  Set the basic parameters
   For each particle
   Initialize velocity and position of particles
  Calculate fitness and set
  End For
   = 
  For each iteration
   For each particle
    Update the position and velocity using by (6) and (7)
    Calculate the fitness
    If <
      = 
    End If
    If <
      = 
    End If
    End For
  End For
Return results
Terminate

4. Sparrow Particle Swarm Algorithm

4.1. Path Initialization

UAV path planning is a pathfinding optimization that considers multiple environmental constraints and the UAV's dynamics. The selection of the next adjacent path node is affected by obstacles and the current node position constraints, and from safety considerations, the UAV cannot cross obstacles from the current node to the next node. The path initialization of the sparrow particle swarm algorithm has an essential impact on the convergence of the subsequent sparrow search algorithm. A good path initialization can effectively improve the search efficiency and prevent the path from generating large oscillations that do not conform to the characteristics of the smooth movement of the UAV in the real environment, for which a path initialization method is proposed.

Assuming a variable speed of the UAV, the UAV should tend to fly to the target point if the target point is known. As shown in Figure 2, denotes the current position and denotes the position of the target point. denotes the x-axis coordinates corresponding to the current position, and is the next point to be determined, and it is the orange point in Figure 2. is the centre of the following available coordinate range determined from the current point and the coordinates of the target point. is calculated according to the following equation:

Here, is the difference between the horizontal coordinate of the target point and the horizontal coordinate of the current point . is chosen by the following formula:

Here, denotes rounding. is a random value from 0 to 1. denotes half of the square length of the range of selectable coordinate points.

During the initialization process, each time the individual confirms the following position based on the current point and the target point, this improved method can avoid too much difference between two adjacent nodes during the UAV movement, interfering with the subsequent convergence.

4.2. Improving the Producer Location Update Formula

The traditional sparrow search algorithm with better pathfinding capability can lead to stagnant search in an environment with more obstacles, thus losing more individuals. The intelligence body has weaker search capability in an environment with more obstacles, leading to local convergence of the path search. The current speed of the particle swarm algorithm is affected by the globally optimal path, assuming that there are no obstacles between the start point and the target point. The optimal path is start-end line. If there is an obstacle, the shortest path should be closer to the start-end line. Using the start-end line as an idealized global optimal path increases the influence of this optimal global path on the producer and enhances the producer's ability to find the optimal solution in the start-end line and enhance the ability to search near the start-end line by changing the producer's function.

Here, is the corresponding coordinate position on the start-end line. is a random number from 0 to 1. By increasing the difference between the current path and the start-end line, the searchability around the start-end line is strengthened to avoid falling into the local optimum.

4.3. Adaptive Variable Speed Escape Search

In the sparrow search algorithm, when , it indicates that the sparrow needs to fly to other places to find food for more energy, since each element in has the same absolute value and is a number from 0 to 1 (excluding 0 and 1). Since the values of formula (4) running to , , , and have been fixed, when the next node is unreachable due to obstacles, even if the search is carried out again, it still cannot reach the next node, which is the same as the last one, and at this time, the path search is stalled. For this stagnation, the adaptive variable speed escape exploration is inspired by the particle swarm algorithm.

When the scrounger flies to other places in search of food, if the next node is unreachable, the scrounger searches at the lowest speed and searches ten times, and if a moveable node cannot be found, the speed of movement is increased. If there is a moveable node, the search stops, and the point is taken as the current point. Every ten searches are no moveable point, and then, the speed increases by one until it reaches the maximum search speed. If it still cannot find a moveable node, then the search ends.

Here, denotes the current velocity, increasing from the lowest velocity, since the globally optimal path corresponds to the smallest possible distance between two adjacent points.

The pseudocode for the variable speed escape search Algorithm 2 is shown below.

 Update the position by equation (4)
 Initialize the velocity of individual:  = 
 Set T = 0
While the position can not reach
  If T = Tmax
    =  + 1
   If > 
    break
   End If
   Set T = 0
  End If
  T = T + 1
  If
   Update the position by equation (12)
  End If
End While
4.4. Adaptive Oscillation Optimization

Since there are random numbers in the selection of paths and significant differences between other paths and the current path, it leads to the planning with oscillation. The oscillation of the drone trajectory will interfere with the judgment of the optimal path adaptation value and easily fall into local minima. The oscillating trajectory will also consume more energy of the UAV and is not suitable as the actual UAV flight trajectory.

For addressing this problem, an adaptive oscillation optimization method is proposed to optimize the planned original path with adaptive oscillation to reduce the trajectory oscillation of the UAV. To reduce the path oscillation at certain points, the overall trajectory trend is judged by its multiple adjacent points to reduce the path oscillation better. The trajectory optimization equation is as follows:

Here, means rounding the value. is the number of adjacent nodes that will have an impact on the current position (including the node itself), the maximum value of is 5, and the minimum value is 3. Initially, the value of is 5. The optimization of the current position is influenced by the position of the previous node, this node, and the next three nodes. If the optimized position has obstacles, then the value of is subtracted by 1 and re-optimized. If is less than 3, no position optimization is performed for the current point. As shown in Figure 3, the original trajectory is blue, and the path after adaptive oscillation optimization is red, which shows that the smooth trajectory has better smoothness.

4.5. Simplification of Path Nodes and Smoothing

The paths after adaptive oscillation optimization have lower oscillation compared with the original paths. The UAV should move in a straight line or smoothly as much as possible in the actual environment. To make the path more realistic, the SPSA finally converges and simplifies the optimal path nodes found to facilitate the subsequent smoothing process with the third spline interpolation.

In Figure 4(a), a simplified diagram of the nodes is shown, where the black line represents the planned path and the blue line represents the simplified path nodes. Point A can reach points B, C, and D, and cannot reach points E and F. Assuming that the UAV reaches point F from point A, which subsequent nodes can be reached from point A is first determined. The corresponding vector is (1, 1, 1, 0, 0), where 1 represents that it can be reached safely and 0 means that it cannot be reached safely, and there are obstacles in the linear path. The last one among these nodes sorted to represent the node that can be reached is D, and it is taken as the current node. When the current node is D, judging the subsequent nodes is continued, assuming that point D can reach point E and point F, the corresponding path vector is (1, 1), and then F is selected as the next node.

This method can effectively avoid the situation that the path is not streamlined enough due to path oscillation, etc. For example, point A′ in Figure 4(b) can reach points B′, C′, D′, and F′, corresponding to the vectors (1, 1, 1, 0, 1). Due to the presence of obstacles, point A′ cannot reach point E′, so directly choose F′ as the next node. Points A′, D′, and F′ form a triangle in space, by the triangle. The sum of line segment A′D′ and line segment D′F′ is greater than A′F′ by the law, from which it can be concluded that this optimization method can minimize the path.

The triple spline interpolation function can improve the path's smoothness and reduce the path's twists and turns, and the path is more consistent with the flight path of the UAV as a real environment. The simplified path can be smoothed better by the cubic spline interpolation function, which reduces the turn amplitude in the path and saves the energy consumption of the UAV.

5. Structure and Flow chart of the Sparrow Particle Swarm Algorithm

5.1. Structure of the Sparrow Particle Swarm Algorithm

The pseudocode of the sparrow particle swarm algorithm Algorithm 3 is shown below.

Initialize
 Set the basic parameters
 Set the start point and target point
 Initialize the position of each individual in the population using equations (10)–(12)
 Oscillation optimization of all individuals trajectories
For each iteration
  Initialize optimal fitness and worst fitness
  For each producer
   For each dimension
    Update the position of by the equation (11)
    Set T = 0
    While the position can not reach and T < Tmax
     Update the position of by the equation (11)
     T = T + 1
    End While
   End For
  End For
  For each scrounger
   For each dimension
    Update the position of by the equation (4)
    Set T = 0
    While the position can not reach and T < Tmax
     Update the position of by the equation (4)
     T = T + 1
    End While
    If T ≥ Tmax
     Search for the next position by adaptive escape using equation (12)
    End If
   End For
  End For
For each individual that finds danger
   For each dimension
    Update the position of by the equation (5)
    Set T = 0
    While the position can not reach and T < Tmax
     Update the position of by the equation (5)
     T = T + 1
    End While
   End For
  End For
  Optimize adaptive oscillation using equation (13)
  Update position of all individuals
  Calculate and sort fitness values
  End For
 Perform node optimization on the optimal path and smooth optimization
Return results
Terminate
5.2. Flow chart of the Sparrow Particle Swarm Algorithm

The sparrow particle swarm algorithm flow chart is shown in Figure 5.

6. Experimental Simulation and Result Analysis

To verify the feasibility of the sparrow particle swarm algorithm for path planning, experimental simulations are conducted in three different environments with increasing complexity, and each algorithm is simulated 30 times in each case. The equipment parameters of this simulation experiment are as follows: CPU is Intel(R) Xeon(R) E5-2450H @ 2.10 GHz; graphic card is GTX 1050 Ti; memory space is 32G; and simulation software is MATLAB 2020b.

To verify the performance of the algorithms, we need to avoid the effect of path initialization and perform the same path initialization for all the compared algorithms. In the initialization of the search path, the path shifted one unit in the x-axis direction (corresponding to a horizontal movement of 20 m) and by ten units in the y-axis and z-axis (corresponding to a movement of 200 m in the y-axis direction and 100 m in the z-axis direction, respectively). In Table 1, Tmax is the maximum number of cycles. For improving the efficiency of all path searches, when the search reaches the next path point, it is determined whether the next path point is an obstacle, and if it is an obstacle, it is reselected. If the reselected times reached Tmax, then the search is deadlocked, and the search for that individual ends, and the path search continues for the next individual. For reflecting the fairness of each algorithm comparison, the method is used for each algorithm individual if it encounters an obstacle when searching for the next path. The results of the initialization of the experimental data are shown in the following table.

6.1. Algorithm Complexity Analysis

The complexity analysis of the algorithm is one of the criteria to evaluate the performance of the algorithm. SPSA is divided into the initialization phase and the algorithm iteration phase: the initialization phase is executed only once and the algorithm iteration phase is executed according to the iteration cycle. The dimension to be calculated for each individual is , the number of individuals is , the maximum number of iterations is , the range of movement in the y-axis and z-axis directions selected during initialization is and , respectively, and is the proportion of sparrows found to be in danger. The structure of the sparrow search algorithm for path planning in three-dimensional space is , where the complexity of the initialized path is . The computational complexity of the path iterative search optimization is . The SPSA increases some computational complexity due to the enhanced ability to optimize the search path, and the complexity of the adaptive oscillation optimization algorithm is considering the worst case. The complexity of adaptive variable speed escape search is , and the computational complexity of path simplification and smoothing is only for the final converged minimum value path. Since the SPSA does not improve the structure of the sparrow algorithm, the maximum computational complexity is , so the computational complexity of this SPSA is . It shows that the SPSA also has a fast convergence rate.

6.2. Analysis of Experimental Results

To verify the effect of the simplified node on the path, the experimental results are shown in Figure 6. The red line is the trajectory curve of the path without the simplified node after three times of spline interpolation, and the blue line is the curve after three times of spline interpolation after the simplified node. It can be seen that there is almost no oscillation in the x-axis and y-axis directions, and there is oscillation in the z-axis direction for the nodes of the un-simplified path, which shows that the simplified path is more suitable as the flight path of the UAV.

It can be seen in Figures 79 that the SPSA has better convergence than other algorithms. The SSA has better smoothness than the paths planned by CSO, DE, GWO, and PSO algorithms, which all show different degrees of oscillation, and the altitude of the flight trajectory keeps changing with less smoothness. Oscillation optimizes and simplifies the nodes, improves the smoothness of the trajectory, and is more suitable for smooth operation as a UAV. The fitness values of SPSA in Figures 1012 can converge to the optimal value faster than other algorithms. For the presence of different obstacles in the UAV-specific constrained environment, increasing the influence of the start-end line on the producer strengthens the searchability of the individuals near the start-end line, leading to a path that can converge quickly. The SPSA has significantly better results in the first iteration due to the start-end line guidance, which makes the path shorter than other algorithms. For the stability of the actual UAV flight path, the adaptive oscillation optimization makes it possible that there is no excessive distance difference between two adjacent path nodes, making the path length much shorter and achieving better results than other algorithms. The exploration of the optimal path is avoided by oscillatory optimization to avoid missing the optimal path. Figures 1315 show that the SPSA is highly robust in different environments.

From the mean, worst, optimal, and standard deviation of different algorithms in Table 2, we can see that the CSO algorithm has the worst convergence effect in path planning. Because in the CSO algorithm, there are differences in the routes between each individual, the smooth paths may be affected by other paths leading to oscillations instead of easy convergence. DE algorithm, PSO algorithm, and SSA have better convergence effect as the iteration increases, and the iterative oscillation of the path makes it difficult to converge to a better path. By comparison, the SPSA has better convergence stability and the lowest fitness value due to the directional nature of the path search, which strengthens the ability of individuals to search near the start-end line. The smoothness of the paths is improved by continuously optimizing the paths and avoiding the oscillating paths from interfering with the convergence of subsequent paths.

7. Conclusions

The traditional SSA algorithm is suitable for the optimization search algorithm performed in an unconstrained environment. In the real environment, various environmental factors will affect the SSA algorithm planning path, resulting in poor convergence of the algorithm and loss of more individuals. To address this situation, strengthening the search efficiency and improving the path smoothing are the main problems that need to be solved for UAV path planning. In this study, we combine the sparrow search algorithm and particle swarm algorithm to propose the SPSA, and the main contributions of this study are as follows:(1)Path initialization has a guiding role in the convergence of the subsequent algorithm. The next node's range is calculated according to the spatial geometry, and then, the node that can be moved within the range is randomly selected as the next node. This method avoids the interference of the initialization path trajectory oscillation on the convergence of the subsequent algorithm and can ensure the search capability of the algorithm.(2)Position update of the producer. The start-end line as the globally optimal path, combined with the particle swarm algorithm, improves the position update of the producer in the sparrow particle swarm algorithm, strengthening the searchability of the algorithm near the start-end line.(3)The searchability of discovering dangerous individuals. Due to the existence of A^+ in the position update formula of the sparrow found to be dangerous in the algorithm, the path may not reach the target point and lose the searched individuals. Inspired by the particle swarm algorithm, a variable speed escape search method is proposed to improve the sparrow search algorithm when the next node is unreachable, improve the path's exploration ability, and reduce the loss of the searched individuals.(4)Adaptive oscillation optimization. For the randomness on path selection resulting in oscillation, an adaptive oscillation optimization method is proposed to reduce the interference of path oscillation to the subsequent path search and improve the smoothness of the path.(5)Simplify node and smoothing processing. Node optimization can reduce the path turning points and improve the smoothness of the path, making the path suitable as the actual flight trajectory of the UAV.

Through simulation experiments, it can be concluded that the sparrow particle swarm algorithm has better convergence and stronger searchability in complex environments, and the smoothed path is suitable as the flight path of the UAV.

Data Availability

The data used to support the findings of this study are included within the article.

Conflicts of Interest

The authors declare that they have no conflicts of interest.

Acknowledgments

This work was partly supported by the National Natural Science Foundation of China (NSFC, Project no. 61973209) and Shanghai Municipal Information Development Special Fund-5G+ Intelligent Manufacturing Demonstration Line Innovation Laboratory Construction (Shanghai Municipal Commission of Economy and Informatization Project no. 202001008).