Polygonal plot scaling method for plant protection of rotor-like UAVs

In this paper, a universal polygonal block boundary method is proposed to solve the problem of integral shrinkage and integral expansion of the boundary of the operation area when facing complex operation area boundary and obstacle boundary in the plant protection process of rotor-wing unmanned aerial vehicles (UAVs). When rotorcraft UAVs carry out plant protection operation, they cannot spray more or miss spraying, and they cannot have any collision with obstacles. Based on the method proposed in this paper, the boundary of the operation area and the boundary of the obstacles can be shrunk and expanded as a whole, so as to improve the safety factor of UAVs and the operation accuracy and efficiency.


Introduction
Because the aging situation in our country is more and more serious and the younger generation tend to go out to work in big cities, rural labour force will continue to reduce [1]. The most of domestic rural land is still in the small block. The reasons why the costs of labour force of producing unit weight food are relatively high and the process is inefficient are the number of land block and the current situation of mechanical work inadequate and so on. In the future, it is a general trend to combine small plots of farmland [2] and use unmanned aerial vehicle (UAVs) to spray pesticide and fertilize to achieve full autonomous operation. If we want to ensure that there is no some farmland missed and avoid obstacles safely when UAVs work, it is necessary to input data points of the boundary of obstacles and plots which are shrunk or extended properly according to the specific environment. In this way, the subsequent path planning and UAVs work will be safe and efficient.

Preprocessing process of boundary polygons and obstacle boundaries
Before the boundary polygon of the block or obstacle can be shrunk and expanded, it is necessary to pre-process the collection point of the boundary. Specific pre-processing steps are as follows: Step 1: coordinate transformation. The polygonal plot boundary points and the obstacle boundary points in the plot operated by UAVs can be obtained by manual collection, aircraft collection and high-precision map collection based on aerial survey. These coordinates are represented by longitude and latitude. To facilitate calculation, Gauss -Kruger Projection is used to convert them into plane coordinates [3]. And this paper focuses on the algorithm directly using plane rectangular coordinate to demonstrate.
Step 2: removal of coordinate. Sometimes, by artificial collection, there are two points which are quite close between them. This situation will increase the amount of calculation and will bring some difficulties to the subsequent algorithm processing. Considering that working accuracy of UAVs don't have to be too precise, so we only remain the first point as a useful point if there are some points which are continuous and the distance of points is too close.
Step 3: removing collinear sides from polygons. Calculate the unit vector of each side of the boundary polygon of the block or obstacle. If the unit vector of the adjacent two sides is the same, we combine them into one side.
Step 4: uniform sorting. Obtaining the boundary vertices of the polygon of plots or obstacles may arrange storage in the clockwise or anticlockwise. To facilitate follow-up algorithm implementation, we need to unified them into clockwise to arrange storage here, namely: firstly, judge the arrangement of the original point is clockwise or anticlockwise; if it is anticlockwise, invert the order of all the points; Otherwise, nothing is done. Secondly, the original arrangement of points is stored in the variable Clock_Flag and if that is clockwise, the Clock_Flag is assigned a value of 1; If it is anticlockwise, the Clock_Flag is assigned a value of 0.

Polygon integral indenting and integral outspread methods
After preprocessing, based on the plane rectangular coordinates arranged in clockwise order of the polygon boundary of the block or the obstacle, the polygon coordinates can be used for the overall shrinking and expanding of the polygon. Before the operation, it is necessary to calculate the following quantities used in the overall shrinking and expanding:

Indenting algorithm
On the basis of the vertex coordinates of the polygon and the sine value of the angle between the two sides of each vertex, the overall indenting algorithm can be implemented. The steps are as follows: Step 1: according to formula (1), calculate the coordinate i Q of each new vertex after shrinking L meters of the polygon, in which i P is the coordinate of the original vertex of the polygon.
Step 2: removal of coordinate and removing collinear sides from polygons. The specific steps are the same as the removal of coordinate and removing collinear sides from polygons in the pretreatment.
Step 3: removing simple invalid polygons [4] [5]. A simple valid polygon is a polygon that contains no other polygons and whose vertex coordinates are in the same direction as the original polygon. After the polygon is shrunk inside, some invalid simple polygons may be formed. When UAVs are making route planning, these simple invalid polygons not only are useless but also increase the difficulty of subsequent route planning.
Step 3.1: calculate the intersection points of each side. First, invert the vertices of the polygon arranged clockwise into anticlockwise, and then loop over to judge whether there is an intersection point between each side and its subsequent sides. If there is any intersection point, record the intersection point coordinates and the sides numbers on both sides of the intersection (the side with a smaller side number is denoted as the starting side, and the side with a larger side number is denoted as the ending side).
Step 3.2: arrange all intersections in ascending order according to the size of the number of the starting side. The purpose is to facilitate the subsequent insertion of intersections in the polygon vertex set.
Step 3.3: insert the intersections into the polygon vertex set. Starting from the first intersection point: 1) locate the starting side and ending side of the intersection point in the polygon vertex set; 2) insert the intersection point respectively behind these two positions. If there are more than one intersection point which are going to be inserted behind the same vertex, insert the intersection points in the order of the distance from each intersection point to the vertex from small to large; loop until all intersections are inserted, forming a new 2-d array of polygon vertices which is stored in the 2-d array PolygonList .
Step Step 3.5: keep the valid polygons. Calculate the order of arrangement of each polygon in the two-dimensional array newPolygonList . And calculate the area of the simple anticlockwise polygon. The vertex set of the simple anticlockwise polygon with the maximum area will be reserved.
Step 4: Ensure that the arrangement direction of polygon vertex set before and after shrinking is the same. points returned in step 3.5.  By comparing the two shrinking algorithms, it is found that the shrinking algorithm proposed in this paper can better deal with invalid polygons and valid polygons with small area, and effectively retain the main valid polygons, thus effectively reduce the difficulty of route planning caused by inaccurate sampling points.

Extended algorithm
On the basis of the vertex coordinates of the polygon and the sine value of the angle between two sides at each vertex, the overall outspread algorithm can be implemented. The steps are as follows: Step 1: Calculate the cosine value of the angle between the unit vectors of two adjacent sides of each vertex and save it in one-dimensional array Cos a . The cosine value of the last edge and the previous edge of each vertex can be calculated by the point multiplication of the unit vector of the last edge and the unit vector of the previous edge of each vertex.
Step 2: optimize small acute angles. If the sine value Sin (1, ) a i and the cosine value Cos (1, ) a i at each vertex satisfy the condition (2), then the vertex is replaced by three points when it expands out. The coordinates of these three points are able to be calculated by formula (3). Otherwise, formula (4) is used to calculate the new outspread vertex. The parameter Theita in condition (2) is the angle value set according to the specific project needs, for example, you can set it to 15 or 10 degrees. In formula (3) Step 3: removal of coordinates and removing collinear sides from polygons. This step is the same as steps 2 and 3 in the pre-processing process.
Step Step 5: the same third step.
Step 6: make the arrangement direction of polygon vertex set same before and after expanding. If the condition 0 _ Clock Flag  is satisfied, invert the set of points returned in step 5.  By comparing the two algorithms, it is found that the algorithm proposed in this paper can deal well with the case with small acute angles and the case with internal polygons resulted from the intersection of sides after expanding and the algorithm is able to preserve the external boundary contour effectively, thus effectively reduce the difficulty of route planning during the operation of UAVs.

Conclusion
In this paper, a universal method of integral shrinking and integral outspreading of polygonal block boundary is proposed. This method can eliminate the simple and invalid polygons caused by the polygon shrunk integrally and the phenomenon that the vertices of small acute angles extend too long and concave edges intersect to form complex inner polygons. Based on the method proposed in this paper, the boundary polygons of the operation area and the boundary polygons of obstacles can be well integrated to shrink or expand, which reduces the difficulty of UAVs route planning [6] and improves the operation accuracy and efficiency.