Disclosure of Invention
According to the technical problem, the unmanned aerial vehicle autonomous path finding and obstacle avoiding method and the system are provided, wherein after global path planning, local dynamic planning is carried out, and environment changes are better processed. The technical means adopted by the invention are as follows:
an unmanned aerial vehicle autonomous road-finding obstacle-avoiding method comprises the following steps:
s1, collecting position information of the obstacles;
s2, modeling a three-dimensional environment through a grid method, dividing the three-dimensional environment into a plurality of grids, respectively processing grids containing obstacles and grids not containing obstacles in different colors, and dividing the grids through a judgment plane passing through a starting point and a target end point to obtain a two-dimensional grid model;
s3, making a global static path plan on the two-dimensional grid model based on an A-x algorithm, and searching an optimal global reference path between a starting point and a final point;
s4, after the global static path is planned, local dynamic path planning is carried out for returning to the originally planned path as soon as possible after the sudden dynamic environment change is processed;
further, after the local dynamic planning, the method includes: and S5, tracking the planned line points through the Bezier curve, and finishing the smoothing processing of the path track.
Further, the step S1 specifically includes:
s101, acquiring position information of an obstacle in a sensor coordinate system through a sensor;
s102, converting the position information under the sensor coordinate system to an unmanned aerial vehicle coordinate system through coordinate transformation;
and S103, importing the position information in the unmanned aerial vehicle coordinate system into an inertial coordinate system through navigation calculation to obtain dynamic obstacle position information.
Further, the obtaining of the two-dimensional grid model by plane segmentation of the grid through the judgment of the starting point and the target end point specifically includes:
s201, generating a judgment plane perpendicular to a yz plane by passing through a starting point and a target end point;
s202, mapping the two-dimensional grid of the xy plane to the judgment plane,
when the level of the starting point is higher than the level of the target end point:
when the level of the starting point is lower than the level of the target end point:
when the horizontal height of the starting point is higher than the horizontal height of the target end point and is consistent, the judgment plane is parallel to the xy plane,
Pz=Ez=Sz (3)
wherein, P1(Py,Pz) A projection point S representing the coordinate of any point P on the judgment plane on the yz plane1(Sy,Sz) Representing the projection of the starting point S on the yz plane, E1(Ey,Ez) Represents the projection point of the target end point S on the yz plane,
combining the formulas (1), (2) and (3) to obtain the coordinate of any point in the judgment plane,
s203, setting the coordinate P of a certain point in the judgment planex=Bx,Py=ByJudging an obstacle grid and a free grid in the two-dimensional grid through a formula (4), wherein:
if Pz>BzThe point P (P) on the plane Fx,Py,Pz) The grid that is the center is a free grid,
if Pz<BzThe point P (P) on the plane Fx,Py,Pz) The grid that is the center is the barrier grid,
B(Bx,By,Bz) Representing three-dimensional obstacle grid coordinates.
Further, the step S3 specifically includes the following steps:
s301, mapping the established two-dimensional grid model into a two-dimensional array, assigning the corresponding element of the barrier grid in the array to be 1, and assigning the corresponding element of the free grid in the array to be 0;
s302, adding the starting point into the OpenList, assigning the address of the starting point information structure body to the parent pointer of the current node,
the starting set is used for storing the information of the grid nodes to be selected;
s303, putting the current node into a closed set CloseList, wherein the closed set is used for storing the grid node information which is searched and selected and cannot be searched again;
s304, searching all free grids in the neighborhood of the current node in the two-dimensional array, calculating the value of a cost function of each node, comparing the value with the nodes in the opening set, if the node exists in the opening set, comparing the respective values of g (k), if the value of g (k) of the node is smaller, updating g (k) and f (k) in the opening set, pointing the parent pointer of the node stored in the opening set to the current node, if the node does not exist in the opening set, adding the node into the opening set, if a target end point is added into the opening set, executing a step S306, otherwise executing a step S305,
g (k), the path cost from the starting point to k of the node to be selected; (k) the total cost value of the node k to be selected;
the cost function f (n) is expressed by the following expression:
f(n)=g(n)+h(n),
g (n) represents the path cost from the starting point to the node n, g (n) is calculated using a formula based on minkowski distance, the cost for each direction is calculated to be different so that the path cost is not the same, h (n) represents the heuristic function from the node to the target point; h (n) denotes a Manhattan distance | x1-x2|+|y1-y2|;
S305, selecting a node with the minimum f (k) from the starting set, pointing a current node pointer to a current node, and executing S303;
and S306, starting from the target node, determining a final path by tracing the parent node pointer, finishing the global path planning, and outputting a path result.
Further, the step S4 specifically includes the following steps:
s401, reading the path point and judging whether the path point reaches a target end point, if so, ending the process, otherwise, executing S402;
s402, judging whether the environment in the current node field changes, if so, performing local dynamic path planning, executing S403, if not, returning to S401, continuing path point tracking,
wherein the dynamic path planning is shown by the following algorithm:
f(n)=g(n)+h(n)+x(n)
g (n) represents the path cost from the starting point to the node n, g (n) is calculated using a formula based on minkowski distance, the cost for each direction is calculated to be different so that the path cost is not the same, h (n) represents the heuristic function from the node to the target point; h (n) denotes a Manhattan distance | x1-x2|+|y1-y2L, |; x (n) represents the newly planned node to the original static stateEuclidean distance of the planned path;
s403, after dynamic path planning, judging whether a global path is returned, if so, returning to S401, continuing path point tracking, and if not, continuing dynamic path planning until the global path is returned;
and after the path points are judged point by point, the target end point is reached, and the local dynamic path planning in the global path is completed.
An unmanned aerial vehicle is independently sought way and is kept away barrier system includes:
the acquisition unit is used for acquiring the position information of the path barrier;
the preprocessing unit is used for carrying out three-dimensional environment modeling on the acquired information and reducing the dimension of the acquired information into a two-dimensional grid model; a path planning unit comprising
The global planning module generates an optimal global reference path between a starting point and a final point in the two-dimensional grid by adopting an A-x algorithm;
the local planning module adopts an improved A-x algorithm with memoryless regression to perform local path optimal planning;
and the post-processing module tracks the planned line points by adopting a Bezier curve to ensure that the track is smooth.
The invention carries out three-dimensional environment modeling on the environment of the unmanned aerial vehicle, lowers the model through the judgment plane to obtain a two-dimensional grid model, carries out global path planning on the two-dimensional grid model based on the A-x algorithm, replans sudden dynamic environment change through local dynamic planning, and carries out smooth planning on planned line points through a Bessel curve, so that the unmanned aerial vehicle can find the change of the position of an obstacle caused by the dynamic change of the environment in time, the local dynamic planning has high response speed, good real-time performance and simple, convenient and quick calculation process, solves the problem that the traditional flight line is easy to touch the obstacle, and can be widely popularized in the fields of unmanned aerial vehicle path planning and track tracking based on the reasons.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As shown in fig. 1, an autonomous route finding and obstacle avoidance method for an unmanned aerial vehicle includes the following steps:
s2, modeling a three-dimensional environment through a grid method, dividing the three-dimensional environment into a plurality of grids, respectively processing grids containing obstacles and grids not containing obstacles in different colors, and dividing the grids through a judgment plane passing through a starting point and a target end point to obtain a two-dimensional grid model;
s3, making a global static path plan on the two-dimensional grid model based on an A-x algorithm, and searching an optimal global reference path between a starting point and a final point;
s4, after the global static path is planned, local dynamic path planning is carried out for returning to the originally planned path as soon as possible after the sudden dynamic environment change is processed;
and S5, tracking the planned line points through the Bezier curve, and finishing the smoothing processing of the path track.
As shown in fig. 2, an autonomous path-finding and obstacle-avoiding system for an unmanned aerial vehicle includes:
the acquisition unit is used for acquiring the position information of the path barrier;
the preprocessing unit is used for carrying out three-dimensional environment modeling on the acquired information and reducing the dimension of the acquired information into a two-dimensional grid model;
a path planning unit comprising
The global planning module generates an optimal global reference path between a starting point and a final point in the two-dimensional grid by adopting an A-x algorithm;
the local planning module adopts an improved A-x algorithm with memoryless regression to perform local path optimal planning;
and the post-processing module tracks the planned line points by adopting a Bezier curve to ensure that the track is smooth.
Embodiment 1, wherein step S1 includes: the position information of the obstacle under the sensor coordinate system is obtained through the laser and the ultrasonic sensor, the obstacle is converted into the unmanned aerial vehicle coordinate system through coordinate change, and the position of the obstacle under the inertial coordinate system is represented through the navigation system, so that the position information of the dynamic obstacle is obtained.
A planning space is divided into a plurality of basic units with regular shapes by adopting a unit decomposition modeling method, each basic unit is divided into nodes containing obstacles and nodes not containing obstacles, the nodes can visually describe environmental information and are convenient for storage of a computer, and meanwhile, each node is convenient to split and is convenient for processing and operation of a planning algorithm.
The grid method is used for modeling a three-dimensional environment, a three-dimensional planning space with a limited range is divided into equal-sized units, as shown in (a) and (b) of fig. 3, the three-dimensional space is divided into n × n × n grids, in the embodiment, 30 × 30 × 30 grids are adopted, each grid is a cube, the center of each grid is used as a calculation unit of a planning algorithm, an obstacle grid containing obstacles is assigned as 1, the grid is processed by dark color, a free grid not containing obstacles is assigned as 0, and the center of each unit grid is used as the coordinate of the grid by light color processing.
As shown in fig. 4(a) (b), a judgment plane F perpendicular to the yz plane is generated by passing through the starting point and the target end point, the judgment plane F includes the starting point S and the target end point E, and cuts through an obstacle grid higher than the judgment plane F;
as shown in fig. 5(a) (b), a two-dimensional grid of the xy plane is mapped to the judgment plane F, and the unit grid size of the judgment plane F is determined by the angle between the judgment plane F and the xy plane and the unit grid size of the xy plane. The figure includes an acute angle alpha formed by a judgment plane F and an xy plane, and an intersection C (C) of an extension line of a connecting line of a starting point and a target end point and a y axisy,0),
As shown in (a) of fig. 3, 4, and 5, when the level of the start point is higher than the level of the target end point:
as shown in (b) of fig. 3, 4, and 5, when the level of the start point is lower than the level of the target end point:
when the horizontal height of the starting point is higher than the horizontal height of the target end point and is consistent, the judgment plane is parallel to the xy plane,
Pz=Ez=Sz (3)
wherein, P1(Py,Pz) A projection point S representing the coordinate of any point P on the judgment plane on the yz plane1(Sy,Sz) Representing the projection of the starting point S on the yz plane, E1(Ey,Ez) Represents the projection point of the target end point S on the yz plane,
combining the formulas (1), (2) and (3) to obtain the coordinate of any point in the judgment plane,
s203, setting the coordinate P of a certain point in the judgment planex=Bx,Py=ByJudging an obstacle grid and a free grid in the two-dimensional grid through a formula (4), wherein:
if Pz>BzThe point P (P) on the plane Fx,Py,Pz) The grid that is the center is a free grid,
if Pz<BzThe point P (P) on the plane Fx,Py,Pz) The grid that is the center is the barrier grid,
B(Bx,By,Bz) Representing three-dimensional obstacle grid coordinates.
The essence of the A-algorithm is the combination of the greedy algorithm and the heuristic search algorithm, so the A-algorithm combines the advantages of the greedy algorithm and the heuristic search algorithm and inherits the characteristics of the greedy algorithm and the heuristic search algorithm. Compared with the greedy algorithm, the A algorithm has the advantages that the search efficiency is remarkably improved under the condition that the state space scale is large, compared with the optimal priority search algorithm, the A algorithm gradually tends to optimally search due to the combination of the 'optimization' property of the greedy algorithm, the defect that the optimal priority search algorithm is single in heuristic information is overcome, and theoretically, the optimal solution can be searched in the state space.
The core of the a-algorithm lies in the design of the cost function, and the general expression of the cost function is shown in formula (5).
f(n)=g(n)+h(n) (5)
Wherein (n) is a cost function of each node, g (n) represents the cost from the starting point to the node n, h (n) represents a heuristic function from the node to the target point, and the heuristic function h (n) is designed with emphasis on different situations. When h (n) is designed to be less than or equal to the real minimum cost from the current node to the target end point, the A-algorithm can theoretically find the optimal path in a planning space, the real minimum cost from the current node to the target end point cannot be estimated and calculated in advance, and h (n) is required to be close to the real cost to the maximum extent, so that the accuracy of path finding of the A-algorithm is ensured, and h (n) is required to be elaborately designed by combining with the actual problem.
As shown in fig. 6, in the process of path planning by using the a-algorithm, it is assumed that the environment model is built by a grid method, and the a-algorithm calculates a cost value of a node to be selected in a state space of the grid model through a cost function, and stores the cost value in the open set. And after the A-algorithm searches the end point and stores the end point into the closing set, the parent node pointer of each node is used for backtracking, and the path searching process of the A-algorithm is completed.
h (n) selecting a manhattan distance having:
h(n)=D*(|n.x-goal.x|+|n.y-goal.y|)
in the process of global path planning, the algorithm actually checks the information of the two-dimensional grid nodes after dimension reduction and calculates the information as a cost value, and in the process of software simulation, the information contained in each grid node is stored in the form of a structural body, so that a program can be conveniently accessed and called. The structure is shown in the following code.
And member variables g, f and h in the structure respectively represent g (), f (), h (), and farthenot is a node father pointer and points to the structure address of the father node of the current node.
As shown in fig. 7, the global path planning process on the dimension reduction model based on the a-x algorithm is as follows:
s301, mapping the established two-dimensional grid model into a two-dimensional array, assigning the corresponding element of the barrier grid in the array to be 1, and assigning the corresponding element of the free grid in the array to be 0;
s302, adding the starting point into the OpenList, assigning the address of the starting point information structure body to the parent pointer of the current node,
the starting set is used for storing the information of the grid nodes to be selected;
s303, putting the current node into a closed set CloseList, wherein the closed set is used for storing the grid node information which is searched and selected and cannot be searched again;
s304, searching all free grids in the neighborhood of the current node in the two-dimensional array, calculating the value of a cost function of each node, comparing the value with the nodes in the opening set, if the node exists in the opening set, comparing the respective values of g (k), if the value of g (k) of the node is smaller, updating g (k) and f (k) in the opening set, pointing the parent pointer of the node stored in the opening set to the current node, if the node does not exist in the opening set, adding the node into the opening set, if a target end point is added into the opening set, executing a step S306, otherwise executing a step S305,
g (k), the path cost from the starting point to k of the node to be selected; (k) the total cost value of the node k to be selected;
the cost function f (n) is expressed by the following expression:
f(n)=g(n)+h(n),
g (n) represents the path cost from the starting point to the node n, g (n) is calculated using a formula based on minkowski distance, the cost for each direction is calculated to be different so that the path cost is not the same, h (n) represents the heuristic function from the node to the target point; h (n) denotes a Manhattan distance | x1-x2|+|y1-y2|;
S305, selecting a node with the minimum f (k) from the starting set, pointing a current node pointer to a current node, and executing S303;
and S306, starting from the target node, determining a final path by tracing the parent node pointer, finishing the global path planning, and outputting a path result.
As shown in fig. 7, the dynamic path planning process,
s401, reading the path point and judging whether the path point reaches a target end point, if so, ending the process, otherwise, executing S402;
s402, judging whether the environment in the current node field changes, if so, performing local dynamic path planning, executing S403, if not, returning to S401, continuing path point tracking,
wherein the dynamic path planning is shown by the following algorithm:
f(n)=g(n)+h(n)+x(n)
g (n) represents the path cost from the starting point to the node n, g (n) is calculated using a formula based on minkowski distance, the cost for each direction is calculated to be different so that the path cost is not the same, h (n) represents the heuristic function from the node to the target point; h (n) denotes a Manhattan distance | x1-x2|+|y1-y2L, |; x (n) tableShowing the Euclidean distance from the newly planned node to the originally statically planned path;
s403, after dynamic path planning, judging whether a global path is returned, if so, returning to S401, continuing path point tracking, and if not, continuing dynamic path planning until the global path is returned;
and after the path points are judged point by point, the target end point is reached, and the local dynamic path planning in the global path is completed.
Because the traditional obstacle avoidance method directly avoids obstacles along a straight line after detecting the obstacles, and is easy to collide with an unmanned aerial vehicle to cause task failure, the method adopts a track planning method based on a Bezier curve to track the track bypassing the obstacles.
Second order Bezier curve, as shown in FIG. 8, by bypassing P0,P1,P2A bezier curve composed of these three points:
B(t)=(1-t)2P0+2t(1-t)P1+t2P2,t∈[0,1] (6)
general formula for the third order bezier curve:
the method carries out trajectory tracking on the line points planned in the front in a Bezier curve mode, so that the trajectory is smoother and more controllable, and the method has excellent applicability.
Finally, it should be noted that: the above embodiments are only used to illustrate the technical solution of the present invention, and not to limit the same; while the invention has been described in detail and with reference to the foregoing embodiments, it will be understood by those skilled in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.