I. Introduction of UAV
Introduction with the development of modern technology, there are more and more types of aircraft, and their applications are becoming increasingly specialized and perfect, such as DJI PS-X625 UAV, which is used for plant protection, BAOji X8 UAV, which is used for street scene shooting and monitoring patrol, and White Shark MIX underwater UAV, which is used for underwater rescue. The performance of the aircraft is mainly determined by the internal flight control system and external path planning. In terms of path problem, only by the operator in the concrete implementation of the task in the hands of the remote control of unmanned aerial vehicles to perform the corresponding work, may be psychological and technology put forward high request of the operator, in order to avoid personal error, the risk of causing the damage of aircraft, a solution is carried out on the aircraft flight path planning. The measurement accuracy of aircraft, the reasonable planning of flight path, the stability and safety of aircraft at work and other changes require more and more high requirements for the integrated control system of aircraft. Uav route planning is a problem to design the optimal route to ensure that UAV can complete specific flight tasks and avoid various obstacles and threat areas in the process of completing the tasks.
1. Common path planning algorithms Figure 1 Common path planning algorithms This paper mainly studies the flight path planning of UAV in the cruise stage. Assuming that uav maintains constant altitude and speed in flight, flight path planning becomes a two-dimensional plane planning problem. In the path planning algorithm,AThe algorithm is simple and easy to implement. To improve ABased on the algorithm, A new and easy to understand improvement A is proposedAn algorithm for uav flight path planning. A traditionalIn this algorithm, the planning area is rasterized, and node expansion is limited to the intersection of grid lines, and there are usually two directions of motion at a certain Angle between the intersection of grid lines. Enlarge and refine the two sections of paths with angles infinitely, and then use the corresponding path planning points on the two sections respectively as tangent points to find the corresponding center of the circle that forms the tangent circle, then make an arc, and find the corresponding center Angle of the arc between the corresponding two tangent points, and calculate the length of the arc according to the following formulaWhere: R — radius of the tangent circle; Alpha — the central Angle corresponding to the arcs between the tangent points.
Two, some source code
clear all;
clc;
close all;
set(0.'defaultfigurecolor'.'w')
global DEM safth hmax scfitness;
a=load('XYZmesh.mat'); DEM DEM=a; axis([0 100 0 100 0 500])
colormap summer;
figure(7)
R=5; A = % radius50; % the origin x coordinate b is equal to50; % the origin y coordinate h is equal to400; % cylinder height m=100; % size (R,m) =cylinder(R,m); % create with (0.0) is the center of the circle and its height is [0.1], the cylinder of radius R x=x+a; % shift x y=y+b; % shift the y axis and make (a,b) the center of the bottom circle z=h*z; % h x x y z % Colormap summer;hold on
view(250 ,60);
axis([0 100 0 100])
theta =
fill3(X,Y,Z2 -[0.0.0]); % bottom cover hmax = Max (Max (DEM. Z)); hmin=min(min(DEM.Z)); J % % axis([0 100 0 100])
axis([0 100 0 100 0 500])
colormap summer;
mesh(x,y,z,'FaceColor'[0 0 0])% redrawhold on
view(250 ,60);
axis([0 100 0 100Fill3 (X,Y,Z,[0.0.0]); % Fill the area surrounded by XYZ with Fill3 function, this is the top Fill3 (X,Y,Z)2 -[0.0.0]); % bottom cover hmax = Max (Max (DEM. Z)); mesh(DEM.X,DEM.Y,DEM.Z+50);
% axis([0 100 0 100 hmin hmax*2]);
colormap summer;
grid off;
xlabel('x/km');
ylabel('y/km');
zlabel('z/m');
hold on;
R=5; A = % radius50; % the origin x coordinate b is equal to50; % the origin y coordinate h is equal to400; % cylinder height m=100; % size (R,m) =cylinder(R,m); % create with (0.0) is the center of the circle and its height is [0.1], cylinder view of radius R (250 ,60);
axis([0 100 0 100])
theta = linspace(0.2*pi,1000); % divides a circle into40Copy of X = a + R *cos(theta); % will becosThe value is given to x, Y is equal to b plus R starsin(theta); % will besinGive Y Z = ones (size (X)) + h; % set Z and X length like fill3(X,Y,Z,[0.0.0]); % Fill the area surrounded by XYZ with Fill3 function, this is the top Fill3 (X,Y,Z)2 -[0.0.0]); % bottom cover demx = DEM. X; demy=DEM.Y; demz=DEM.Z+50;
startx(1)=round(20*rand(1));
starty(1)=round(20*rand(1));
startz(1) =2;
xx=1;
flag=1;
k=2;
while flag
if starty(k- 1)> 95 | |startx(k- 1)>95
flag=0;
end
startx(k)=startx(k- 1)+xx;
starty(k)=starty(k- 1)+xx;
startz(k)=startz(k- 1);
RR=sqrt((startx(k)-a)^2+(starty(k)-b)^2);
% startx(k)=startx(k)-xx;
% demz(startx(k),starty(k))
if demz(startx(k),starty(k))The < 10startz(k)= demz(startx(k),starty(k))+2;
end
if startz(k)<demz(startx(k),starty(k))
startz(k)= demz(startx(k),starty(k))+50+5*rand(1);
else
startz(k)= demz(startx(k),starty(k))+50+5*rand(1);
end
k=k+1;
end
for i=2:length(startx)
JULI(num)=JULI(num)+sqrt( (startx(i)- startx(i- 1)) ^2+(starty(i)- starty(i- 1)) ^2+(startz(i)- startz(i- 1)) ^2);
end
switch num
case 1
plot3(starty,startx,startz,'k-'.'LineWidth'.4);hold on
text(starty(1),startx(1),startz(1),'starting point'.'color'.'k'.'FontSize'.13)
text(starty(end),startx(end),startz(end),'starting point'.'color'.'k'.'FontSize'.13)
case 2
plot3(starty,startx,startz,'b-'.'LineWidth'.4);hold on
text(starty(1),startx(1),startz(1),'starting point'.'color'.'k'.'FontSize'.13)
text(starty(end),startx(end),startz(end),'starting point'.'color'.'k'.'FontSize'.13)
case 3
plot3(starty,startx,startz,'r-'.'LineWidth'.4);hold on
text(starty(1),startx(1),startz(1),'starting point'.'color'.'k'.'FontSize'.13)
text(starty(end),startx(end),startz(end),'starting point'.'color'.'k'.'FontSize'.13)
case 4
plot3(starty,startx,startz,'c-'.'LineWidth'.4);hold on
text(starty(1),startx(1),startz(1),'starting point'.'color'.'k'.'FontSize'.13)
text(starty(end),startx(end),startz(end),'starting point'.'color'.'k'.'FontSize'.13)
case 5
end
L=min(JULI);
liziqun=[L+2200 L+1950 L+1950 L+1700 L+1700 L+1400 L+1400 L+1300 L+1300 L+1100 L+1000 L+800 L+800 L+730. L+730 L+600 L+600 L+520 L+520 L+400 L+400 L+206 L+206 L+236 L+236 L+90 L+90. L L L L L]+200;
moni=[L+2200 L+1900 L+1900 L+1600 L+1600 L+1300 L+1300 L+1200 L+1200 L+950 L+950 L+750 L+750 L+580 L+580 L+500 L+500 L+420 L+420. L+300 L+300 L+300 L+200 L+200 L+105 L+105 L- 20 L- 20 L- 20 L- 20 L- 20 L- 20] +200;
gaijinliziqun=[L+2000 L+1500 L+1500 L+830 L+830 L+730 L+730 L+730 L+410 L+410 L+205 L+205 L+200 L+200 L+42 L+42 L- 50 L- 50 L- 50 L- 50 L- 50 L- 50. L- 50 L- 50 L- 50 L- 50 L- 50 L- 50 L- 50 L- 50 L- 50 L- 50] +200;
moniliziqun=[L+2000 L+1200 L+700 L+700 L+700 L+100 L+100 L+100 L+100 L- 200. L- 200. L- 200. L- 200. L- 200. L- 200. L- 200. L- 200. L- 200. L- 200.. L- 200. L- 200. L- 200. L- 200. L- 200. L- 200. L- 200. L- 200. L- 200. L- 200. L- 200. L- 200. L- 200.] +200;
N=length(moni);
NN=0:3:N*3- 3;
figure(11)
plot(NN,liziqun,'b');
xlabel('Number of iterations');
ylabel('Fitness value')
title('Trends in optimal individual fitness values')
figure(12)
plot(NN,moni,'r');
xlabel('Number of iterations');
ylabel('Fitness value')
title('Trends in optimal individual fitness values')
legend('Simulated annealing')
figure(13)
plot(NN,gaijinliziqun,'k');
xlabel('Number of iterations');
ylabel('Fitness value')
title('Trends in optimal individual fitness values')
legend('Improved particle swarm')
figure(14)
plot(NN,moniliziqun,'g');
xlabel('Number of iterations');
ylabel('Fitness value')
title('Trends in optimal individual fitness values')
legend('Simulated annealing and Particle Swarm optimization')
figure(15)
% plot(NN,liziqun,'b',NN,moni,'r',NN,gaijinliziqun,'k',NN,moniliziqun,'g');
Copy the code
3. Operation results
Matlab version and references
1 matlab version 2014A
[1] Yang Baoyang, YU Jizhou, Yang Shan. Intelligent Optimization Algorithm and Its MATLAB Example (2nd Edition) [M]. Publishing House of Electronics Industry, 2016. [2] ZHANG Yan, WU Shuigen. MATLAB Optimization Algorithm source code [M]. Tsinghua University Press, 2017. [3] WU Qian, LUO Jinbiao, GU Xiaoqun, ZENG Qing. [4] Deng Ye, Jiang Xiangju. Optimization Algorithm of UAV 3D Trajectory Planning Based on Improved PSO [J]. Journal of Ordnance Equipment Engineering, 201,42(08). [5] Yunhong Ma, Heng Zhang, Legrong Qi, Jianliang He. Trajectory Planning Algorithm of quadrotor UAV based on improved Artificial Potential Field Method [J]. Sensors and Microsystems, 201,40(07) [5] 3d uav path planning based on improved A* algorithm [J]. Electronics optics & control, 2019,26(10) [6] jiao Yang. Research on 3d path planning of uav based on improved ant colony algorithm [J]. Ship electronic engineering, 2019,39(03)