1. Introduction
Unmanned aerial vehicles (UAVs) are ideal for carrying out tasks with relatively high human costs in indoor or outdoor environments because of their mobility, flexibility, rapid deployment, and wide applicability [
1,
2]. In recent years, with the development of technology and growth in demand, UAVs have played a significant role in agriculture [
3], logistics and transportation [
4,
5], security monitoring [
6], network communication [
7], and rescue and emergency response [
8]. Today, people recognize the importance of UAVs to human life and to production. UAVs must obtain more control and planning capacity due to changing environments. The path-planning problem is a significant issue that UAVs must resolve in practical applications and is one of the current research hotspots [
9]. The problem refers to the requirement for UAVs to obtain a path from the starting point to the target point without coming into contact with any obstacles [
10].
Research in path planning generally focuses on “path optimality” and “probabilistic completeness”. Path optimality is the ability of an algorithm to find the path with the lowest cost, and probabilistic completeness is the ability of an algorithm to find a path that is feasible. It is difficult for path-planning algorithms to satisfy both fast planning and optimal planning. Early path-planning methods typically transformed the original map into a grid map and then searched for the target location. The most representative methods were the Dijkstra algorithm [
11,
12] and the A* algorithm [
13,
14]. Both could find the optimal path but would occupy a lot of memory and time. The artificial potential field method (APF) assumed the existence of an attractive potential of the target point and the repulsive potential of the obstacle in the map. The path could be determined by the change in the gradient of the potential field [
15]. However, there might be regions in the map where the potential field is in equilibrium, causing the UAVs to fall into local minima [
16]. The ant colony algorithm (ACO) mimics the natural phenomenon in which ants leave pheromones on the path to find the shortest path, but the algorithm converges slowly when dealing with complex problems, and it also falls into local minima [
17,
18]. Genetic algorithms (GA) encode each path and, finally, form feasible paths after crossover, mutation, and selection [
19]. However, the complex adaptation functions and coding make the algorithm memory- and time-intensive [
20].
In recent years, sampling-based algorithms have gradually attracted the attention of researchers, and the most influential ones include the Probabilistic RoadMap (PRM) [
21] and rapidly exploring random tree (RRT) [
22]. The main idea of the PRM algorithm is to sample randomly in space and obtain a collision-free set of nodes. Then, the PRM is connected to the start and target points to obtain the paths. Furthermore, with a sufficiently large number of samples, the PRM is complete [
23]. The RRT algorithm is a single-query planner in which the random tree connects nodes and grows from the starting point after randomly sampling the nodes obtained. The random tree gradually grows around the target point and, finally, finds a path connecting the starting point and the target point. Like the PRM, the RRT is complete for a sufficiently large number of samples [
24]. The biggest advantage of the sampling-based algorithm is that it can find the path quickly and can meet the requirements of UAVs for fast maneuvers.
Despite the probabilistic completeness of both algorithms, the quality of the initial paths is usually not excellent, and the optimal path cannot be obtained. To address this issue, Karaman and Frazzoli proposed PRM* and RRT* [
25] and demonstrated their asymptotic optimality. The new node tries to update the parent node continuously to obtain a smaller path cost [
26]. RRT*-Smart [
27] uses a bias sampling strategy for fast optimization of the obtained initial solution but the possibility of obtaining the globally optimal path is lost [
28]. Bidirectional-RRT* (Bi-RRT*) [
29] proposed a new algorithm for joint pathfinding by two random trees, i.e., each explores from the starting point and the target point towards the other to improve efficiency [
30,
31]. Informed-RRT* [
32] sped up convergence by restricting sampling points to less costly elliptical regions. Quick-RRT* (Q-RRT*) [
33] expanded the range of reselected parent nodes and used pruning means to reduce the path cost. The algorithm can be effectively integrated with other improved algorithms [
34].
Potential-RRT* (P-RRT*) [
35] successfully combines APF and RRT* to accelerate the exploration efficiency of RRT*. It also uses the random sampling property of RRT* to avoid falling into local minima, which is common in APF algorithms. The P-RRT* algorithm assumes that the sampling is affected by the target point, and the new nodes expanding from the random tree are then gradually biased towards the target point. Compared with the RRT* algorithm, the P-RRT* is more suitable for the path planning of UAVs. P-RRT* can also be combined with other algorithms such as potentially guided bidirectionalized RRT* (PB-RRT*) [
30] and PF-RRT* [
36]. The former makes two random trees attract each other through potential guidance. The latter combines with F-RRT* [
37] to reduce the path cost by inserting the parent nodes. However, this algorithm still has the inherent drawback of the RRT* algorithm, i.e., a large amount of sampling and expansion occurs in high-cost regions, which is not useful for obtaining optimal paths.
UAVs need a responsive, high-quality, and smooth path-planning algorithm. This paper presents an improved UAV path-planning algorithm based on P-RRT* that can be applied to various environments. First, considering the need for rapid planning for UAVs, the algorithm contains a greedy strategy. The algorithm guides the greedy expansion with the direction of the artificial potential field on the node as the optimal direction, which can explore the depth of the map faster. Second, by calculating the heuristic costs of nodes and sampling points, comparing them to the existing path costs, and rejecting nodes and sampling points in the high-cost region, the algorithm increases the search efficiency of each iteration. Then, the random tree is pruned, and the parents of the nodes are reselected to reduce unnecessary redundant nodes on the path. Finally, compared with the simulation results of the traditional RRT* algorithm and P-RRT* algorithm, the algorithm proposed in this paper has significant superiority in sparse, complex, as well as in realistic application scenarios.
The rest of this paper is presented as follows.
Section 2 explains the necessary definitions, equations, etc., and introduces related algorithms.
Section 3 describes in detail the principles and algorithmic contents of the proposed algorithms.
Section 4 simulates each algorithm in different environments and compares and analyzes the simulation results, and
Section 5 and
Section 6 present the discussion and conclusion of this work. The relevant algorithms’ code has been released at:
https://github.com/ZFF20231101/RRT-algorithms (accessed on 1 November 2023).
3. Improved P-RRT*
The increased target point attraction of the P-RRT* algorithm aids in speeding up the convergence, but due to the property of the algorithm, the random tree expands with low exploration efficiency, with only one new node per iteration. In addition, the configuration space contains a significant number of high-cost regions, such as edges of the map and regions far from the target points. The random sampling property of the algorithm makes it possible for the random tree to explore high-cost regions, but nodes located in such regions cannot be part of the optimal path. The algorithm should reduce the path nodes to smooth the flight path of UAVs. To address these problems, the following improvements were made in this paper.
Greedy strategy: to address the problem of the slow exploration of random trees, a greedy strategy is incorporated to speed up the expansion. The greedy expansion is carried out if the APF direction of the node is within a certain deflection angle from the actual expansion direction;
High-cost rejection: the heuristic cost of sampling points and nodes is calculated; if it exceeds the current optimal path cost , the points and nodes are in the high-cost region. The algorithm rejects high-cost sampling points and nodes, resamples, and expands only on low-cost nodes;
Path optimization: the random tree is pruned in order to remove redundant nodes from the path. This not only lowers the cost of the path but also enables the UAVs to pass through fewer path turning points.
The proposed algorithm based on the above ideas is shown in Algorithm 4, and each improvement point is described in detail in the
Section 3.1,
Section 3.2 and
Section 3.3.
Algorithm 4: Improved P-RRT* () |
1: ; ; |
2: ; ; |
3: for to do |
4: ; |
5: ; |
6: while do |
7: ; |
8: ; |
9: if then |
10: ; |
11: ; |
12: ; |
13: ; |
14: end if |
15: end while |
16: end for |
17: return ; |
3.1. Greedy Strategy
The greedy expansion method can be applied to the RRT* algorithm to expedite the exploration. The random tree keeps expanding in the
direction using this method until it runs into an obstacle, producing multiple
in the process. This method has an obvious drawback in that the greedy expansion direction is frequently undesirable and sometimes even far from the target point. The target greedy expansion method [
38] was improved by only allowing greedy expansion to occur when
xrand =
xgoal, thereby minimizing greedy expansion in the wrong direction. The disadvantage of this method is that after obtaining the initial solution, it is not possible to perform greedy expansion. Because the nearest node
of
must be the last node of the initial path, the random tree cannot be expanded. In addition, greedy expansion toward the target point may trap the path in an area surrounded by numerous obstacles.
To solve the above problem, it was necessary to make the random tree expand greedily in the optimal direction and normally in the other directions. In this paper, we proposed a greedy expansion algorithm based on APF guidance. The proposed algorithm subjects the nodes to both attractive and repulsive potentials, and the expansion also takes into account the
as an attractive source. The node is subjected to
and
, as shown in
Figure 1, and the APF force
(red line) is produced under the combined action of both. The node is simultaneously affected by the attraction
of the sampled point
, which results in the combined force
(green line) as the direction of expansion, ultimately. Note that there are generally multiple obstacles in the configuration space, and that the repulsive force generated by each obstacle in the range of
should be calculated to form the combined force
. The expression of the combined force on the node is shown in Equation (6). The improved
procedure is shown in Algorithm 5.
Algorithm 5: |
1: ; |
2: for each do |
3: ; |
4: if then |
5: ; |
6: ; |
7: end if |
8: ; |
9: end for |
10: return ; |
The direction of the potential field force
obtained by the APF algorithm represents the optimal direction of the expansion in the local region. The proposed algorithm, combined with the greedy strategy, adds the
procedure, which can determine whether the angle
between the
and the expansion direction satisfies the greedy expansion condition. As shown in
Figure 2, the starting point is expanded to obtain
. At this time the node is only subjected to the attraction
of
, and the angle
is below the algorithmic threshold, which means that this expansion is toward the optimal direction and greedy expansion can be carried out. The newly generated
,
and
all satisfy the condition, and the random tree is expanded to
. The obstacle repulsive force
has a significant effect on
, and the greedy expansion stops when the pinch angle
is out of range. As shown in the figure, the random tree is greedily expanded to reach the favorable position quickly along the optimal direction, which greatly reduces the time required for exploration. It is worth noting that the APF direction only represents the optimal direction for a certain local region. Sometimes, random trees are extended to local minima regions, while the random expansion of the RRT algorithm can help the random tree leave these regions.
3.2. High-Cost Rejection
As the algorithm obtained the initial solution, we divided the configuration space into high-cost and low-cost regions. The division was based on the current shortest path cost
and the heuristic cost f-value of the region. The cost g-value of the path length between
and
and the cost h-value of the linear distance between
and
were calculated based on the method in [
13]. From this, the heuristic function f-value was calculated as follows:
where
was the theoretical minimum cost of the path through the point. If the
of a node or sampling point was greater than
, it was considered to be in the high-cost region.
According to the original RRT* and the P-RRT* algorithm, the randomness of sampling ensures that, regardless of the cost of the current optimal path, the sampling region is located throughout the configuration space. However, sampling points falling in high-cost regions make it difficult to accelerate convergence. The improved algorithm proposed in this paper generates
randomly in
, but valid sampling must satisfy
, where
. As shown in
Figure 3a, after obtaining the initial path
and the path cost
, the algorithm rejects the newly generated sampling points
and
successively, because
. By resampling to obtain
, as opposed to the original sampling point, it is more likely to obtain a better path. The algorithm for the sampling part is shown in Algorithm 6.
Algorithm 6: |
1: if then |
2: ; |
3: else |
4: while True |
5: ; |
6: ; |
7: if then |
8: break; |
9: end if |
10: end while |
11: end if |
12: return ; |
As the number of iterations of the RRT* algorithm increases and
became smaller and smaller, there were some nodes on the random tree with
. It was impossible for these high-cost nodes to be part of the optimal path in subsequent iterations. Nodes were classified as possible nodes and impossible nodes based on
and
:
As shown in
Figure 3b, the traditional algorithm took the nearest node
as the parent node to extend the random tree to
, but the path cost was too high for this to be the optimal path. The proposed algorithm rejects
and used
as the parent node extension to avoid the path passing through the high-cost region. The pseudocode of the improved algorithm is shown in Algorithm 7. The process of traversing the nodes on the random tree by the algorithm sets the possibilities of the nodes, which do not make the algorithm more complex.
Algorithm 7: |
1: ; |
2: for each do |
3: |
4: ; |
5: ; |
6: end for |
7: for to N do |
8: ; |
9: if then |
10: break; |
11: else ; |
12: end for |
13: return ; |
3.3. Path Optimization
The path generated by RRT* contained many redundant nodes, so the random tree can be pruned to turn the path from zigzag to straight, which reduces the path cost and smooths the UAVs’ flight path. The RRT* algorithm only considers
as a potential parent node, while the proposed algorithm also considers other nodes along the path. The principle of the improved algorithm is shown in
Figure 4. When the new node
is added to the random tree, the algorithm connects
with the most suitable node
. Then,
can try to connect the parent node
of the parent node
and determine whether it will collide with the obstacle. If the condition is met,
chooses
as the parent node; the red dashed line reflects this process. According to the triangle inequality, the path cost of
at this time must be smaller than in the previous case. The algorithm repeats this process until the condition is not satisfied when it is connected to
. Finally, the algorithm obtains a path with fewer nodes suitable for UAV flight. The pseudocode for this part is shown in Algorithm 8.
is similar to the above process. The node
tries to connect with
and determine whether the path cost is smaller. If the condition is satisfied,
is set as
’s parent node. The above process can be repeated until the node cannot satisfy the condition.
Algorithm 8: |
1: for each do |
2: if then |
3: ; |
4: if then |
5: ; |
6: ; |
7: end if |
8: end if |
9: end for |
10: while do |
11: if then |
12: ; |
13: else |
14: break |
15: end while |
16: return ; |
3.4. Algorithm Flow
The proposed algorithm is represented in Algorithm 4. First, the algorithm is initialized based on the information in the space to construct a random tree starting with , and then the first sampling is performed in a loop. The initial sampling range is unrestricted. Once the initial path is obtained for the random tree, the algorithm rejects the high-cost region sampling points based on . Then, all nodes are classified according to the f-value, and only nodes with are set as possible nodes and connected to . Due to the APF, each node expands in the procedure in the direction of the total combined force . After expansion in a certain direction, the proposed algorithm determines whether to start the greedy expansion based on the force acting on the node and the direction of the expansion. If the edge generated by joining and passes the collision-free detection, is added to the random tree. Next, finds the parent node with the lowest cost among the set of nearby nodes and the ancestor nodes on the path, which removes a large number of redundant nodes. If the Euclidean distance between and is less than the set value, the nodes can be connected, and the path is output in the algorithm. Otherwise, the next iteration is carried out. The loop ends after reaching the set number of iterations.
3.5. Algorithm Analysis
The probabilistic completeness and asymptotic optimality of RRT* and P-RRT* have been proven in their respective papers [
25,
35]. The proposed algorithm is identical to the sampling method of P-RRT* until the initial solution is obtained. The greedy strategy does not change the way new nodes are expanded by sampling. In addition, path optimization only changes the connection distribution of the random tree, and the nodes remain connected to the starting point. Hence the proposed algorithm is probabilistically complete, i.e., a feasible solution is obtained when the number of iterations tends to infinity. Asymptotic optimality requires that the algorithm obtains a solution with a minimum cost as the number of iterations tends to infinity. The nodes of the more optimal solution after the algorithm obtains the initial solution are necessarily distributed in the low-cost regions. The proposed algorithm restricts the sampling to the low-cost regions after obtaining the initial solution and does not miss the optimal solution. Moreover, the greedy strategy and path optimization do not affect the way the nodes are generated. Therefore, the proposed algorithm is also asymptotically optimal.
The computational complexity of the algorithms has been analyzed in the original papers proposing RRT* and P-RRT*. Time and space complexity is used to measure the time and space required by the algorithm. For two functions,
and
,
is said to belong to
if
Let be the amount of memory space occupied by the proposed algorithm after iterations, it is obvious that , where and are the number of nodes and edges.
Theorem 1. .
Proof of Theorem 1. The greedy strategy increases the number of nodes and edges produced in each iteration. However, the boundary of the map limits the number of nodes added by the greedy strategy, , where is the total number of nodes added in iterations. The number of edges is the same as the number of nodes, so that and . Hence Theorem 1 can be proved from Equation (9). □
The time complexity needs to be calculated for the program that the algorithm executes the most frequently in the loop, which in this paper’s algorithm is the program. Let be the total time for the algorithm to call under iterations, and and be the time for and to call , respectively, then .
Theorem 2. .
Proof of Theorem 2. Let a total of
nodes
participate in the
process; it has been shown in [
25] that obstacle collision detection needs to run in
time. The proposed algorithm adds
nodes and an optimization path step. In the worst case,
selects a parent node with a total of
ancestor nodes, and all of them participate in the path optimization. Hence,
,
. The
in
needs to perform the optimization path step for the
ancestor nodes of
in the worst case, so
and
. Thus Theorem 2 can be proved. □
4. Simulation Results
In this section, the proposed algorithm with RRT* and P-RRT* was compared to verify the superiority. The simulation experiments were run on a computer with a 2.50 GHz processor and 16 GB RAM. To fully analyze the effectiveness of the proposed algorithm, four 2D maps and two 3D maps were used to simulate the various UAV scenes. Due to the randomness of the RRT algorithm, 100 simulations for each map were run to analyze the performances of different algorithms. The black graph on the map represents the obstacle. The starting point and the target point are represented by the red x. Each black dot represents a node in the random tree. The path between two nodes is represented by a green line, and the red line is the optimal path at the current iteration.
The UAVs needed to find the initial solution quickly to complete the path planning and obtain a small cost path. Based on the above requirements, three evaluation indicators were used: was the path cost obtained by the algorithm within the specified number of iterations, the smaller the number of iterations, the better the path quality; was the time cost of the algorithm obtaining the initial path, the lower the cost the better for fast planning; was the time cost the of the algorithm finding an excellent path with a cost of , which measured the convergence speed of the algorithm, where was the cost of the optimal path. Failure meant that the algorithm could not find an excellent path within 10,000 iterations. In addition to the three evaluation indicators, the simulation data included the nodes and runtimes generated by the algorithms executing 500 or 1000 iterations in each environment.
4.1. 2D Environment
In this section, the 2D environments used for simulation testing included a sparse environment Map A (
Figure 5), a cluttered environment Map B (
Figure 6), a simple maze environment Map C (
Figure 7), and a complex maze environment Map D (
Figure 8). The size of each map is 100 × 100.
Table 1 shows the average data of 100 simulations for each algorithm in the four maps, and the data visualization is shown in
Figure 9.
The cases plotted in the four maps highlights the characteristics of each algorithm. The random tree of RRT* was distributed over the whole area of the map, which slowed down the convergence of the algorithm. While the random tree of P-RRT* grew toward the target point as a whole, a large number of nodes were distributed at the edge of the map. The proposed algorithm has a large number of continuous nodes generated by the greedy strategy and the random tree is distributed in the center of the map. The proposed algorithm has a large number of continuous nodes generated by the greedy strategy and the random tree is distributed in the center of the map. Benefiting from pruning to remove redundant nodes, the proposed algorithm has the least number of path inflection points. As shown in
Figure 5, RRT* has eight inflection points and P-RRT* has nine inflection points, while the proposed algorithm has only five inflection points, which is more suitable for planning the flight paths of UAVs.
The data in
Table 1 and the data distribution reflect the advantages of the proposed algorithm. The proposed algorithm has the strongest search ability, and hence
is minimized. Taking Map A as an example, the
of the algorithm was reduced by 10.36% and 8.19% compared to RRT* and P-RRT*, respectively, which was mainly due to the high-cost rejection and pruning methods implemented by the algorithm. Among all four maps, P-RRT* had the largest time
searching for the initial path, RRT* had the second largest, and the proposed algorithm had the smallest. Since P-RRT* added the step of sampling-point deflection in the sampling procedure, this increased the time of each iteration. The proposed algorithm expanded the random tree according to the direction of the artificial potential field and incorporated a greedy strategy that allowed for fast expansion toward the target point at the early stage of the algorithm operation. In an empty environment, such as Map A, the proposed algorithm had the greatest advantage:
was reduced by 37.15% compared to RRT*. The
data show that P-RRT* had a faster convergence speed compared to RRT* in complex environments. However, the boxplots in
Figure 9a and c are very close to each other, which indicates that P-RRT* has no advantage in empty environments, such as those of Map A and Map C. The proposed algorithm sped up the convergence by rejecting high-cost nodes and sampling points, and the data show that the method is effective. In Map B, the proposed algorithm searched for excellent paths in only 1.91 s, compared with 25.47 s and 19.96 s for RRT* and P-RRT*, respectively, and they failed five and six times, respectively. The runtime data show that the proposed algorithm took more time. However, in practice, the proposed algorithm requires fewer iterations to obtain better quality paths, hence the time cost is lower.
4.2. 3D Environment
In reality, UAVs need to consider six directions of movement, so we constructed two 3D maps to simulate the realistic scenarios that UAVs may encounter. Map E, shown in
Figure 10, simulated the environment of dense woods, where UAVs need to fly for operations such as plant data collection or pesticide spraying. To simplify the problem, only the main trunks of trees were kept as obstacles in this paper, and the map size is 50 × 50 × 20. Map F, shown in
Figure 11, simulated a real plant factory environment, with tall plant cultivation racks used to grow crops with the greatest possible space utilization. The UAVs needed to quickly reach the target point according to the operator’s command and perform pest and disease detection on crops that are at different heights on the plant cultivation racks. The size of Map F is 50 × 50 × 10.
Table 2 shows the average data of 100 simulations of each algorithm in two maps, and the data visualization is depicted in
Figure 12.
Similar to the cases in the 2D environment, the random trees generated by RRT* were still distributed throughout the configuration space, while P-RRT* tried to make the random trees grow toward the target point under the gravitational force of the target point, but with limited effect. The proposed algorithm not only obtained paths with smaller costs but also with fewer inflection points. The
of the proposed algorithms in Map E and F was reduced by 2.54% and 3.24%, respectively, compared to that of P-RRT*, although the value of
was already very close to the optimal value. In the 3D environment, the proposed algorithm reduced the time by at least 25.18% more compared to that of RRT*. Contrary to the cases in the 2D environment, RRT* had difficulty in searching for excellent paths in the complex 3D environment and therefore had the largest
and it had as many as 29 failures in Map E. The distribution of the
data in
Figure 12a shows that P-RRT* had a smaller median compared to that of the proposed algorithm, but due to the large number of outliers in the former, both the box and the mean were higher than those of the latter. The proposed algorithm limited the expansion of the random tree in the high-cost region and significantly improved the convergence speed. The data in
Table 2 and the data distribution show that the proposed algorithm is more suitable for UAVs to deploy and fly rapidly to accomplish realistic application tasks.
6. Conclusions
In this paper, we proposed an improved algorithm based on P-RRT* applied to UAVs, with the main goal of combining greedy strategy, rejecting high-cost nodes and sampling points, and optimizing paths. The greedy strategy can help with the expansion of the random tree to the optimal direction quickly and greatly reduce the time to obtain the initial solution. The algorithm rejected nodes and sampling points located in the high-cost region using the current path cost as the criterion, which improved the algorithm’s iteration efficiency and sped up convergence. Finally, the random tree was pruned to reduce redundant nodes and complete the optimized path. Compared to P-RRT*, the improved P-RRT* not only had less cost and fewer path inflection points, but also obtained the initial solution and converged to the optimal solution with faster efficiency. Simulations in six environments showed that the proposed algorithm has significant advantages. Comparing the , , and indicators of the three algorithms, the results demonstrated that the proposed algorithm reduced the path cost by at least 2.54% and shortened the search time by at least 68.32% compared to P-RRT* in each environment. Moreover, the paths of the proposed algorithm had fewer inflection points. In conclusion, the proposed algorithm performed better under the same conditions, enabled the UAVs to complete planning more quickly, and generated a better path with fewer turning points.
The improved algorithm proposed in this paper was applied to the global path planning of UAVs, which was suitable for the environment where the information was known and there were no moving obstacles, The algorithm can be deployed on the ROS system under the Ubuntu system and replace the global planner in the move_base feature pack, which enables the UAVs to perform global path planning according to the customized algorithm. However, in real applications, UAVs will run into many unknown obstacles and need to use a local path-planning algorithm for dynamic obstacle avoidance. Future research will focus on combining global path planning and local path planning to adapt UAVs to real-world application environments.