[Path planning] UAV two-dimensional obstacle avoidance shortest path planning based on matlab A_star algorithm (island map) [including Matlab source code 2774]

⛄1. Introduction to A_star Algorithm

1 A Star Algorithm and Its Application Status The
information extracted during the search task that helps simplify the search process is called heuristic information. The heuristic information is transformed into a heuristic function after being refined and formulated. The heuristic function can represent the The estimated distance between the target vertices can also represent the estimated time from the starting vertex to the target vertex. The heuristic functions used to describe different situations and solve different problems are different. We default the heuristic function named H ( n). The search method supported by the heuristic function is called a heuristic search algorithm. In the path planning of the rescue robot, the A Star algorithm can combine the environmental conditions of the search task to narrow the search range and improve the search efficiency. The search process is more directional and intelligent, so the A Star algorithm can be better applied to the fields related to robot path planning.

2 A Star Algorithm Flow
Continued from Section 2.1, the heuristic function of the A Star algorithm is used to estimate the distance from the starting point to the target point, thereby reducing the search range and improving search efficiency. The mathematical formula of the A Star algorithm is: F (n) =G (n) +H (n) , where F (n) is the estimated function from the starting point to the target point via node n, G (n) represents the actual moving cost of moving from the starting point to square n, and H (n) represents Estimated movement cost for moving from square n to the goal point.

As shown in Figure 2, the area to be searched is divided into square grids, and the state of each grid is divided into walkable and unwalkable. The cost value of each passable square is 1, and can Move along the diagonal (diagonal movement is not considered in the valuation). The search path flow is as follows:
insert image description here
Figure 2 A Star algorithm path planning
Step 1: Define two lists named open and closed; the open list is used to store all items considered to find The block of the path, the closed list is used to store the blocks that will no longer be considered;
Step2: A is the starting point, B is the target point, start from the starting point A, and put the starting point A into the open list, and the closed list is initialized to empty;
Step3: View the square n adjacent to A (n is called the child point of A, and A is called the parent point of n), and the passable squares are added to the open list, and their F, G and H values ​​are calculated. Put A Remove from open and add to closed list;
Step4: Determine whether the open list is empty, if yes, the search failed, if not, go to the next step;
Step5: remove n from the open list and add to the closed list, judge Whether n is the target vertex B, if yes, the search is successful, and the algorithm ends;
Step6: If not, then expand the search for sub-vertex of n:
a. If the sub-vertex is not passable or in the close list, ignore it.
b. If the child vertex is not in the open list, it will be added to the open list, and the current square will be set as its parent, and the F, G and H values ​​of the square will be recorded. Step7: Jump to Step4; Step8: End of loop
,
save Path. Starting from the end point, each square moves along the parent node to the starting point, which is the optimal path. The flow chart of A Star algorithm is shown in Figure 3. Figure
insert image description here
3 A Star algorithm process

⛄ 2. Part of the source code

clc;
clear
close all

tic

%% draw map

% Define the number of rows and columns of the grid map
m = 150;
n = 150;
% map m rows n columns

start = [10, 20]; % start node
target = [130, 80]; % end node
% obs = [6, 1; 6, 2; 6, 3; 6, 4; 6, 5; 6, 6 ; 6, 7; 5, 5; 4, 5; 3, 5]; % obstacle area

obs = TrunToGridMap(m, n);

% 画格子
for i = 0 : 5 : m
plot([0, n], [i, i], ‘k’, ‘handlevisibility’, ‘off’);
hold on;
end

for j = 0 : 5 : n
plot([j, j], [0, m], ‘k’, ‘handlevisibility’, ‘off’);
end

⛄3. Running results

insert image description here

⛄4. Matlab version and references

1 matlab version
2014a

2 References
[1] Qian Cheng, Xu Yingqiu, Tan Yingzi. Application of A Star Algorithm in Path Planning in RoboCup Rescue Simulation [J]. Journal of Command and Control. 2017,3(03)

3 Remarks
Introduction This part is taken from the Internet and is for reference only. If there is any infringement, please contact to delete

Guess you like

Origin blog.csdn.net/TIQCmatlab/article/details/131503684