Disclosure of Invention
Aiming at the defects in the prior art, the invention provides a novel unmanned aerial vehicle path planning method.
The invention aims to solve the problems of large error and overlong operation time of the traditional ant colony algorithm in the aspect of path planning, introduces the particle swarm algorithm, and optimizes the parameters of the ant colony algorithm through continuous updating of particles in the particle swarm algorithm, thereby shortening the operation time of the ant colony algorithm. The technical scheme adopted by the invention for solving the technical problem specifically comprises the following steps:
step 1, determining a flight mathematic model of an unmanned aerial vehicle
The unmanned aerial vehicle flight mathematical model comprises an unmanned aerial vehicle body motion model and an unmanned aerial vehicle dynamics model, and specifically comprises the following steps:
unmanned aerial vehicle organism motion model
The four-rotor aircraft controls the rotating speed of the four rotors to adjust the pitch angle (theta), the yaw angle (psi) and the roll angle
And adjusting to complete a series of flying movements of the machine body.
First, two coordinate systems are established: a body coordinate system and a conventional coordinate system.
The conventional coordinate system e (oexyz) is stationary with respect to the earth's surface.
The machine body coordinate system A (oxyz) is coincident with the center of mass of the machine body, the horizontal axis ox points to the first motor, the longitudinal axis oy points to the fourth motor, and the oz is perpendicular to the oxyy surface.
Euler angles of four-rotor aircraft:
(1) roll angle
The machine body rotates around the ox shaft by an angle.
(2) Pitch angle (θ): the body rotates around the oy axis.
(3) Yaw angle (ψ): and the body rotates the included angle between the projection of the longitudinal axis of the aircraft around the oz axis in the horizontal plane and the axis of the inertial coordinate system OX.
Unmanned aerial vehicle dynamics model
Attitude vector based on four rotors
Wherein
Roll angle, yaw angle,. phi.phi.theta.pitch angle, and displacement vector [ x, y, z]The kinetic equation is as follows:
wherein:
u1representing the total lift of four rotors, u2Representing roll moment, u3Representing the pitching moment, u4Representing yaw moment, w1、w2、w3、w4Respectively representing the rotational speeds of four rotors, Ix、Iy、IzRepresenting the moment of inertia of the body in the xyz axis.
Step 2, Maklink environment model construction
Modeling the two-dimensional path by adopting a Maklink graph theory method:
(1) selecting an obstacle, selecting a vertex on the obstacle, connecting the vertex with fixed points of other obstacles, and making a vertical line segment from the point to the boundary of the environment space;
(2) adding the obtained connecting line segments of all the vertexes and fixed points into a line segment storage table according to the sequence from short to long in length;
(3) selecting a header line segment in a line segment storage table;
(4) and checking whether the header line segment crosses any barrier boundary in the environmental space, and if the header line segment crosses any barrier boundary in the environmental space, the header line segment is not a free connecting line. Thus, the current line segment is discarded and the next line segment in the line segment storage table is selected. Repeating the checking process until a line segment is found to be not intersected with all the barrier boundaries;
(5) connecting the midpoints of the connecting line segments in the line segment storage table, checking whether the link line segment crosses the boundary of the obstacle, and deleting the line segment if the link line segment crosses the obstacle.
Step 3, optimizing the ant colony algorithm parameters by adopting a particle swarm algorithm, and planning a two-dimensional path through the optimized ant colony algorithm;
and optimizing the parameters of the ant colony algorithm through a particle swarm algorithm, and finding out an optimal path in the Maklink environment model through the optimized ant colony algorithm. The path length is calculated by equation (11):
wherein xiyiAs current position coordinates, xi+1yi+1And m is the number of nodes from the starting point to the target point. Dist is the total path length.
Determining an ant colony algorithm pheromone updating method:
the pheromone updating comprises real-time pheromone updating and path pheromone updating, wherein the real-time pheromone updating refers to the pheromone tau of a certain node which must be treated by each ant after the node is selectedi,jUpdating is carried out, namely:
τij=(1-ρ)τij+ρτ0 (12)
wherein tau is0P is the adjustable parameter between intervals (01) for initial pheromone values.
Path pheromone updating shows that when all ants go from an initial point to a terminal point and complete iterative search in sequence, all ants are selected to pass through one path with the shortest length, and pheromones of all points on the path are updated, namely:
τij=(1-ρ)τij+ρΔτij (13)
where Δ τ isij=1/L*,L*Bit shortest path length, ρ is an adjustable parameter between intervals (0, 1).
In conducting the path search, the next node location may be selected according to equation (14).
Wherein tau isi,jIs a pheromone of ηi,jFor heuristic values, α, β are τ, respectivelyi,j、ηi,jA weight coefficient.
However, in the actual simulation process, the situation of premature convergence occurs when the traditional ant colony algorithm searches for a path, and in order to avoid the situation and prevent a stagnation state, the ant colony algorithm pheromone is updated by adopting a method of combining global asynchronism and a novel pheromone updating strategy.
The novel pheromone updating strategy is as follows:
By utilizing the pheromone concentrations of the maximum value and the minimum value on the path, the real-time updating and adjusting amplitude of the pheromone is increased, the pheromone is not updated every evolutionary generation of the ant colony, and the pheromone is updated only when a solution with stronger adaptability occurs.
The global asynchronous updating method comprises the following steps:
τij(t+1)=τij1(t) (16)
wherein tau isij1And (t) is the pheromone which continues to the current generation according to the global synchronous pheromone updating mode.
Further, the process of the particle swarm optimization for optimizing the ant colony algorithm parameters is as follows:
the particle swarm optimization algorithm finds the maximum solution and the optimal solution in the whole population through particle tracking, and updates according to the formulas (17) and (18):
Vi(t+1)=w*Vi(t)+c1*r1(pi(t)-xi(t))+c2*r2(pg(t)-xi(t)) (17)
xi(t+1)=xi(t)+Vi(t+1) (18)
where w is the inertial weight, r1r2Is a random number between (0, 1), c1c2Is a constant,Vi(t) is the velocity vector of the particle, xi(t) is the current position of the particle.
(1) Firstly, parameters alpha, beta and rho are taken as inlet parameters.
(2) Setting learning factor c in particle swarm optimization1c2And inertial weights w, and then randomly selected for the initial position and velocity of each particle.
(3) Judging whether the positions of the particles are good or bad according to the result of the ant colony algorithm, and updating the optimal solution p of the individual extremumbestAnd global extremum optimal solution gbest。
(4) And updating the position and the speed of the particles according to the formulas (17) and (18).
(5) If the conditions are met, the algorithm is ended, and the current global optimal particle position is returned. And if the condition is not met, returning to the step (3). And finally, obtaining the optimal control parameters by continuously updating the particles.
Updating the inertia weight by adopting an inertia weight updating method in the chaotic inertia weight particle swarm optimization algorithm, namely:
z1=4×z2×(1-z2) (20)
wherein z is2Is a random number between (0, 1), wmax、wminRespectively representing the values of the inertial weight w at the beginning and at the end, stepmaxRepresenting the maximum number of iterations, and t being the current number of iterations. Parameter c1,c2A trial and error approach is used to find the appropriate value.
The invention has the following beneficial effects:
the particle swarm optimization is introduced into the ant colony algorithm, so that the parameters needing to be manually adjusted in the original ant colony algorithm can be automatically adjusted on line, and the optimization time of the algorithm is greatly shortened. Compared with the traditional algorithm for path planning, the algorithm provided by the invention can shorten the operation time of the algorithm on the basis of finding out the optimal path, and provides a method for saving the operation cost.
Detailed description of the invention
The present invention will be described in detail with reference to specific embodiments.
The improved ant colony path planning method provided by the invention is implemented according to the following steps:
step 1, determining a flight mathematic model of an unmanned aerial vehicle
The unmanned aerial vehicle flight mathematical model comprises an unmanned aerial vehicle body motion model and an unmanned aerial vehicle dynamics model, and specifically comprises the following steps:
unmanned aerial vehicle organism motion model
The four-rotor aircraft controls the rotating speed of the four rotors to adjust the pitch angle (theta), the yaw angle (psi) and the roll angle
And a series of flying movements of advancing and retreating, ascending and descending, left and right flying and the like of the airframe are further completed through adjustment.
First, two coordinate systems are established: a body coordinate system and a conventional coordinate system. The conventional coordinate system e (oexyz) is stationary with respect to the earth's surface as shown in figure 1.
The machine body coordinate system A (oxyz) is coincident with the center of mass of the machine body, the horizontal axis ox points to the first motor, the longitudinal axis oy points to the fourth motor, and the oz is perpendicular to the oxyy surface.
The Euler angles of the four-rotor aircraft are as shown in the attached figure 2:
(1) b transverse roll angle
The machine body rotates around the ox shaft by an angle.
(2) c pitch angle (θ): the body rotates around the oy axis.
(3) a yaw angle (ψ): and the body rotates the included angle between the projection of the longitudinal axis of the aircraft around the oz axis in the horizontal plane and the axis of the inertial coordinate system OX.
Unmanned aerial vehicle dynamics model
Attitude vector based on four rotors
Wherein
Roll angle, yaw angle,. phi.phi.theta.pitch angle, and displacement vector [ x, y, z]The kinetic equation is as follows:
wherein:
u1representing the total lift of four rotors, u2Representing roll moment, u3Representing the pitching moment, u4Representing yaw moment, w1、w2、w3、w4Respectively representing the rotational speeds of four rotors, Ix、Iy、IzRepresenting the moment of inertia of the body in the xyz axis.
Step 2, Maklink environment model construction
There are many methods for environment modeling, such as grid method, artificial potential field method, Maklink graph theory, etc.
As shown in fig. 3, Maklink graph theory is selected herein to model the two-dimensional path:
modeling the two-dimensional path by adopting a Maklink graph theory method:
(1) selecting an obstacle (convex polygon), selecting a vertex on the obstacle, connecting the vertex with fixed points of other obstacles, and making a vertical line segment from the point to the boundary of the environment space;
(2) adding the obtained connecting line segments of all the vertexes and fixed points into a line segment storage table according to the sequence from short to long in length;
(3) selecting a header line segment in a line segment storage table;
(4) and checking whether the header line segment crosses any barrier boundary in the environmental space, and if the header line segment crosses any barrier boundary in the environmental space, the header line segment is not a free connecting line. Thus, the current line segment is discarded and the next line segment in the line segment storage table is selected. Repeating the checking process until a line segment is found to be not intersected with all the barrier boundaries;
(5) connecting the midpoints of the connecting line segments in the line segment storage table, checking whether the link line segment crosses the boundary of the obstacle, and deleting the line segment if the link line segment crosses the obstacle.
Step 3, optimizing the ant colony algorithm parameters by adopting a particle swarm algorithm, and planning a two-dimensional path through the optimized ant colony algorithm;
overview of Ant colony Algorithm
It has been found in practice that ants always secrete a chemical substance called pheromone in the path of food, and the pheromone remains on the path for a while, and when other ants search the path again, the path with higher concentration of pheromone is selected and the pheromone is left in the path, so that the pheromone on the path is increased. Its optimal path finds figure 4.
Fig. 4 shows the process of ant searching for a path. Ants pass through the paths A-D-E-C and A-B-C from the point A, pheromones do not exist on the two paths at the beginning, and because the length ratio between the two paths is 4:3, the number of the ants from the point A-C is 3:4 in the same time, the pheromones on the paths A-B-C are thicker and thicker. The remaining ants will eventually choose the path a-B-C.
FIG. 5 is a schematic flow chart of an ant colony algorithm;
and optimizing the parameters of the ant colony algorithm through a particle swarm algorithm, and finding out an optimal path in the Maklink environment model through the optimized ant colony algorithm. The path length is calculated by equation (11):
wherein xiyiAs current position coordinates, xi+1yi+1And m is the number of nodes from the starting point to the target point. Dist is the total path length.
Determining an ant colony algorithm pheromone updating method:
the pheromone updating comprises real-time pheromone updating and path pheromone updating, wherein the real-time pheromone updating refers to the pheromone tau of a certain node which must be treated by each ant after the node is selectedi,jUpdating is carried out, namely:
τij=(1-ρ)τij+ρτ0 (12)
wherein tau is0P is the adjustable parameter between intervals (01) for initial pheromone values.
Path pheromone updating shows that when all ants go from an initial point to a terminal point and complete iterative search in sequence, all ants are selected to pass through one path with the shortest length, and pheromones of all points on the path are updated, namely:
τij=(1-ρ)τij+ρΔτij (13)
where Δ τ isij=1/L*,L*Bit shortest path length, ρ is an adjustable parameter between intervals (0, 1).
In conducting the path search, the next node location may be selected according to equation (14).
Wherein tau isi,jIs a pheromone of ηi,jFor heuristic values, α, β are τ, respectivelyi,j、ηi,jA weight coefficient.
However, in the actual simulation process, the situation of premature convergence occurs when the traditional ant colony algorithm searches for a path, and in order to avoid the situation and prevent a stagnation state, the ant colony algorithm pheromone is updated by adopting a method of combining global asynchronism and a novel pheromone updating strategy.
The novel pheromone updating strategy is as follows:
By utilizing the pheromone concentrations of the maximum value and the minimum value on the path, the real-time updating and adjusting amplitude of the pheromone is increased, the pheromone is not updated every evolutionary generation of the ant colony, and the pheromone is updated only when a solution with stronger adaptability occurs.
The global asynchronous updating method comprises the following steps:
τij(t+1)=τij1(t) (16)
wherein tau isij1And (t) is the pheromone which continues to the current generation according to the global synchronous pheromone updating mode.
Further, the particle swarm optimization parameter process is as follows:
the particle swarm optimization algorithm finds the maximum solution and the optimal solution in the whole population through particle tracking, and updates according to the formulas (17) and (18):
Vi(t+1)=w*Vi(t)+c1*r1(pi(t)-xi(t))+c2*r2(pg(t)-xi(t)) (17)
xi(t+1)=xi(t)+Vi(t+1) (18)
where w is the inertial weight, r1r2Is a random number between (0, 1), c1c2Is a constant number, Vi(t) is the velocity vector of the particle, xi(t) is the current position of the particle.
(5) Firstly, parameters alpha, beta and rho are taken as inlet parameters.
(6) Setting learning factor c in particle swarm optimization1c2And inertial weights w, and then randomly selected for the initial position and velocity of each particle.
(7) Judging whether the positions of the particles are good or bad according to the result of the ant colony algorithm, and updating the optimal solution p of the individual extremumbestAnd global extremum optimal solution gbest。
(8) And updating the position and the speed of the particles according to the formulas (17) and (18).
(5) If the conditions are met, the algorithm is ended, and the current global optimal particle position is returned. And if the condition is not met, returning to the step (3). And finally, obtaining the optimal control parameters by continuously updating the particles.
The optimization program comprises the following steps:
VStep(j,:)=w*VStep(j,:)+c1*rand*(pbest(j,:)-Swarm(j,:))+c2*rand*(gbest-Swarm(j,:));
If VStep(j,:)>Vmax,VStep(j,:)=Vmax;end
If VStep(j,:)<Vmin,VStep(j,:)=Vmin;end Swarm(j,:)=Swarm(j,:)+VStep(j,:);
for k=1:Dim
if Swarm(j,k)>Ub(k),Swarm(j,k)=Ub(k);end
if Swarm(j,k)<Lb(k),Swarm(j,k)=Lb(k);end
end
wherein Ub (k), Lb (k) are upper and lower limits of the particle group. Then, calculating a fitness value fSwarm (j) of the particle according to the updated particle, and then comparing:
if fSwarm(j)<fpbest(j)
pbest(j,:)=Swarm(j,:);
fpbest(j)=fSwarm(j);
end
if fSwarm(j)<fgbest
gbest=Swarm(j,:);
fgbest=fSwarm(j);
end
and finally, obtaining the optimal control parameters by continuously updating the particles.
However, when the particle swarm optimization is adopted, the introduction of part of necessary parameters such as (w, c) cannot be avoided1,c2) In order to avoid affecting the final result, chaotic inertial weight particle swarm is adopted in the textThe inertia weight updating method in the optimization algorithm updates the inertia weight, namely:
z1=4×z2×(1-z2) (20)
wherein z is2Is a random number between (0, 1), wmax、wminRespectively representing the values of the inertial weight w at the beginning and at the end, stepmaxRepresenting the maximum number of iterations, and t being the current number of iterations. Parameter c1,c2A trial and error approach is used to find the corresponding appropriate value.
Examples
The algorithm provided by the invention adopts a particle swarm optimization algorithm to optimize parameters alpha, beta and rho, and pheromones are updated once when particles with stronger adaptability appear.
Firstly, initializing parameters and setting a value range, and carrying out limit processing on particles when the parameters exceed the value range.
The operation result is shown in fig. 7, and it can be seen by comparing with fig. 6 that the path length after the traditional ant colony algorithm of fig. 7 is optimized is slightly longer than that of the design method of the present invention. FIG. 6 is a schematic diagram of a path planning for a novel ant colony algorithm; FIG. 7 is a schematic diagram of a conventional ant colony algorithm path planning;
through fig. 8 and fig. 9, it can be seen that in the two methods, when the optimal path is reached, the iteration number of the ant colony algorithm designed herein is small, and the optimal path can be found in a short time.
FIG. 8 is a diagram illustrating iteration times of the novel ant colony algorithm;
fig. 9 is a diagram illustrating the iteration number of the conventional ant colony algorithm.