A convex hull algorithm-based path planning method for plant protection unmanned aerial vehicle in irregular farmland
Through the path planning method that combines the convex hull algorithm and the density clustering algorithm, the difficult problems of boundary recognition and path planning of UAVs in irregular farmland are solved, efficient coverage of complex terrain is achieved, and comprehensive coverage of farmland and operation accuracy are ensured.
Patent Information
- Application Number
- CN202510120480.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-25
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2045-01-25
AI Technical Summary
Existing UAV path planning algorithms have problems with poor coupling between boundary recognition and path planning in irregular farmland and insufficient adaptability to complex terrain, resulting in missed boundaries and redundant paths.
A path planning method based on the convex hull algorithm and the density clustering algorithm is adopted. The coordinate data of the farmland boundary points are obtained, the density clustering algorithm is used for denoising, the convex hull algorithm is introduced to generate the minimum enclosing rectangle, the Yolov7-tiny model is combined for edge detection, and the acceleration sensor is used to calculate the tilt compensation and adjust the UAV heading angle to achieve round-trip path planning.
It improves the accuracy of path planning for irregular farmland and its adaptability to complex terrain, reduces boundary omissions and path redundancy, and improves agricultural operation efficiency.
Smart Images

Figure CN120010478B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of smart agricultural path optimization, and in particular to a method for irregular farmland path planning for a plant protection UAV based on a convex hull algorithm. Background Art
[0002] Smart agriculture is a key area of integration between modern technology and traditional agriculture. Drone technology, due to its high flexibility and versatility, has become a core tool in smart agriculture. In precision agriculture, drones are primarily used for soil testing, pest and disease monitoring, pesticide spraying, sowing, and crop growth monitoring. Pesticide spraying is one of the most widely used areas. Its goal is to improve pesticide utilization, reduce environmental pollution, and increase crop yield and quality through precise pesticide distribution.
[0003] However, current precision spraying technology primarily targets straight or simple curved paths within regular farmland. Irregular farmland, with its complex boundary shapes and uneven area distribution, poses significant challenges to path planning and spraying accuracy. Spraying on irregular farmland primarily relies on operator-controlled remote controls, making precise spraying impossible in areas where operators cannot or have difficulty reaching them. This is crucial for achieving intelligent spraying. Furthermore, in complex terrain such as mountainous areas, plateaus, or farmland with complex boundaries, traditional navigation and path planning technologies are prone to insufficient coverage, missed spraying, or wasted pesticides due to insufficient accuracy or poor algorithm adaptability.
[0004] To date, there have been a large number of studies on drone spraying path planning. For example, the use of genetic algorithms to achieve trajectory planning for several discontinuous farmlands has been verified by experiments to be highly efficient (Zhao Yue., 2023). However, this type of algorithm has high requirements for the quality of initial boundary data and is not adaptable enough to dynamic changes in terrain. There is also a route planning method for plant protection drones based on particle swarm optimization (Wu Jinlong., 2018), which solves the obstacle avoidance problem, but the path planning relies on regular terrain and cannot meet the needs of irregular farmland. Based on the analysis of the above technologies and research status, it can be seen that there are still some unresolved problems in the path planning of plant protection drones in irregular farmland, including the following issues:
[0005] Poor coupling between boundary recognition and path planning: Existing technologies fail to effectively integrate boundary recognition algorithms and dynamic path planning algorithms, which can easily lead to boundary omissions or path redundancy in irregular farmland operations.
[0006] Poor adaptability to complex terrain: Existing drone path planning algorithms are mostly based on regular terrain, and their operating accuracy is significantly reduced in complex terrain or magnetic interference environments. Summary of the Invention
[0007] The application provides an irregular farmland path planning method for plant protection unmanned aerial vehicles based on a convex hull algorithm to overcome the technical problems that the existing path planning method cannot adapt to complex terrains and is prone to boundary omission and path redundancy when path planning is performed.
[0008] In order to achieve the above-mentioned purpose, the technical scheme of the application is:
[0009] An irregular farmland path planning method for plant protection unmanned aerial vehicles based on a convex hull algorithm, comprising:
[0010] S1: Obtain a coordinate data set of farmland boundary points, and use a density clustering algorithm to denoise the coordinate data set to obtain a denoised data set;
[0011] S2: Introduce a convex hull algorithm, use the convex hull algorithm to traverse all coordinates in the denoised data set, find a plurality of convex hull points, connect all the convex hull points, generate a minimum circumscribed rectangle, and randomly select an edge of the minimum circumscribed rectangle to set a reference heading angle;
[0012] S3: Introduce a Yolov7-tiny model and randomly select a corner of the minimum circumscribed rectangle, use the Yolov7-tiny model to perform real-time edge detection with the corner of the minimum circumscribed rectangle as a starting point, and find an actual farmland edge;
[0013] S4: Calculate the inclination compensation in the movement process of the unmanned aerial vehicle according to the acceleration in the horizontal direction and the vertical direction detected by the acceleration sensor of the unmanned aerial vehicle to obtain an actual heading angle;
[0014] S5: Adjust the flight angle of the unmanned aerial vehicle to make the actual heading angle consistent with the reference heading angle, and simultaneously adjust the angle of the reference heading angle to turn 90 degrees to the inside of the farmland to realize the path planning of the farmland in a back-and-forth manner.
[0015] Further, the convex hull algorithm is introduced, the convex hull algorithm is used to traverse all coordinates in the denoised data set, a plurality of convex hull points are found, all the convex hull points are connected, a minimum circumscribed rectangle is generated, and the minimum circumscribed rectangle comprises:
[0016] S21, the denoised data set is randomly divided into n groups, and each group contains m farmland boundary points;
[0017] S22, select a farmland boundary point O point with the smallest x coordinate and y coordinate in the denoised data set as a reference point, and calculate the polar angle of all other farmland boundary points with the point; the x coordinate and the y coordinate are coordinates in a coordinate system with longitude and latitude as coordinates;
[0018] S23. In each group, the farmland boundary points included in the group are sorted in ascending order of polar angle. If two farmland boundary points have the same polar angle, the farmland boundary points are sorted in ascending order of distance from the reference point to form a point set.
[0019] S24. Randomly select a farmland boundary point A from a group as a preset convex hull point, construct a vector OA, randomly select a detection point i from the group, construct a vector Oi, calculate the cross product of the vector OA and Oi, and determine whether the cross product is positive or negative:
[0020] If the result is positive, point i is a non-convex hull point, and point A is still the current convex hull point. Point A and the reference point form a vector and participate in the vector cross product calculation of the next farmland boundary point.
[0021] If the result is negative, then point A is not a convex hull point. Set point i as the new convex hull point, form a vector with the reference point, and use it in the vector cross product calculation of the next farmland boundary point. This continues until all farmland boundary points in the group are traversed and the final convex hull point is used as the convex hull point of the group.
[0022] S25. Traverse the sorted point sets of the remaining groups in turn to obtain all convex hull points including the reference point, connect two adjacent convex hull points in turn, generate a minimum circumscribed rectangle, and enclose the remaining non-convex hull points of the farmland boundary points.
[0023] Furthermore, the convex hull algorithm is a Graham scanning method.
[0024] Furthermore, the tilt compensation of the drone during its motion is calculated based on the acceleration in the horizontal and vertical directions detected by the drone's acceleration sensor to obtain the actual heading angle, including:
[0025] Decompose the Earth's magnetic field into components in the x and y directions parallel to the horizontal plane and a component in the z direction perpendicular to the horizontal plane;
[0026] The component in the x direction is shown in formula (1),
[0027]
[0028] Among them, H x Represents the component in the x direction, X M represents the component of the magnetic compass in the x direction, Z M represents the component of the magnetic compass in the z direction, represents the pitch angle based on the acceleration sensor, as shown in formula (2),
[0029]
[0030] Among them, A x ,Ay ,A z are the accelerations in the x, y, and z directions respectively;
[0031] The component in the y direction is shown in formula (3),
[0032]
[0033] Among them, H y represents the component in the y direction, and θ represents the tilt angle based on the acceleration sensor, as shown in formula (4),
[0034]
[0035] The actual heading angle is calculated based on the x-direction component and the y-direction component, as shown in formula (5):
[0036]
[0037] Where β represents the actual heading angle.
[0038] Furthermore, the flight angle of the drone is adjusted so that the actual heading angle is consistent with the reference heading angle, and at the same time, the reference heading angle is adjusted to rotate 90 degrees toward the inside of the farmland at the actual edge of the farmland to achieve round-trip farmland path planning, including:
[0039] S51, set the two perpendicular sides of the minimum bounding rectangle to be Y1=K1*X1+b and Y2=K2*X2+b, where K1 represents the slope of one side of the rectangle, K2 represents the slope of the other vertical side; X1, Y1 represent the horizontal and vertical coordinates of the side, b is a constant, X2, Y2 represent the horizontal and vertical coordinates of the other vertical side;
[0040] S52, set the flight direction corresponding to the reference heading angle to be parallel to one side of the rectangle, that is, parallel to the slope direction corresponding to Y1=K1*X1+b; calculate the actual heading angle according to the current actual coordinate value of the UAV and formula (5); if the current reference heading angle α and the actual heading angle β are different, adjust the flight direction of the UAV and return to the direction corresponding to the reference heading angle; if the two values are equal, the UAV maintains the direction corresponding to the current actual heading angle;
[0041] S53. When the UAV reaches the edge of the farmland, the reference heading angle is rotated 90 degrees toward the inside of the farmland. At this time, the flight direction is parallel to the vertical side, that is, parallel to the slope direction corresponding to Y2=K2*X2+b. When the UAV reaches the preset flight time, the current reference heading angle is rotated 90 degrees toward the inside of the farmland again, and is parallel to the slope direction corresponding to Y1=K1*X1+b again, and flies in the opposite direction.
[0042] Furthermore, the coordinate data set is denoised using a density clustering algorithm to obtain a denoised data set, including:
[0043] S11, randomly selecting a boundary point in the coordinate data set and forming a neighborhood radius with the point as the center;
[0044] S12. Determine the number of boundary points in the neighborhood of the point. If the number is less than the set density threshold, the point is considered a noise point. If the number is greater than or equal to the set density threshold, the point is marked as a core point and expanded to form a cluster. When all boundary points in the neighborhood of the current point are traversed, the cluster expansion stops.
[0045] S13. After all boundary points are marked, the points that do not belong to any cluster are noise points.
[0046] Beneficial effects: The present invention provides a method for irregular farmland path planning of a plant protection UAV based on a convex hull algorithm. By applying the convex hull algorithm to the operation path planning of the plant protection UAV and combining it with the edge recognition algorithm to identify the boundaries of the farmland, the problem of path planning of the plant protection UAV during irregular operations is solved, boundary omissions and path redundancy are reduced, and the accuracy of path planning for irregular farmland is improved; by calculating the actual heading angle of the UAV, the angle of the UAV can be quickly adjusted to prevent deviation, thereby realizing comprehensive path planning of the farmland. The present invention is suitable for farmland in complex terrain (such as mountainous areas and plateaus), and greatly improves the efficiency of agricultural operations. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following is a brief introduction to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0048] Figure 1 A flow chart of a method for irregular farmland path planning for a plant protection UAV based on a convex hull algorithm provided by the present invention;
[0049] Figure 2 is a schematic diagram of the effect of density clustering algorithm to eliminate noise points;
[0050] Figure 3 is a schematic diagram of the effect of the convex hull algorithm;
[0051] Figure 4 A schematic diagram of a preset reference heading angle according to the present invention;
[0052] FIG5 is a schematic diagram of edge detection of farmland according to the present invention;
[0053] Figure 6 A schematic diagram of virtual path planning of the present invention;
[0054] Figure 7 This is a schematic diagram of the actual path planning of the present invention. DETAILED DESCRIPTION
[0055] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0056] This embodiment provides a method for planning irregular farmland paths for plant protection UAVs based on a convex hull algorithm. Figure 1 Shown, including:
[0057] S1: Obtain a coordinate dataset of farmland boundary points, and use a density clustering algorithm to denoise the coordinate dataset to obtain a denoised dataset;
[0058] S2: Introduce the convex hull algorithm, use the convex hull algorithm to traverse all coordinates in the denoised data set, find multiple convex hull points, connect all convex hull points, generate a minimum bounding rectangle, and randomly select one side of the minimum bounding rectangle to set the reference heading angle;
[0059] S3: Introducing the Yolov7-tiny model and randomly selecting a corner of the minimum bounding rectangle, using the Yolov7-tiny model to perform real-time edge detection with the corner of the minimum bounding rectangle as the starting point to find the actual edge of the farmland;
[0060] S4: Calculate the tilt compensation of the drone during movement according to the acceleration in the horizontal and vertical directions detected by the acceleration sensor of the drone to obtain the actual heading angle;
[0061] S5: Adjust the flight angle of the drone so that the actual heading angle is consistent with the reference heading angle, and at the same time adjust the reference heading angle at the actual edge of the farmland to rotate 90 degrees toward the inside of the farmland to achieve round-trip farmland path planning.
[0062] Specifically, first, a coordinate data set of farmland boundary points is obtained, and the density clustering algorithm is used to denoise the coordinate data set to obtain a denoised data set. Beidou navigation is used to collect real GPS coordinate data along the farmland boundary, and unmanned assistance is used to collect points in difficult-to-reach areas to ensure the integrity of the boundary data and provide an initial data set for the following steps. The convex hull algorithm is introduced using density clustering. The convex hull algorithm is used to traverse all coordinates in the denoised data set, find multiple convex hull points, connect all convex hull points, generate a minimum circumscribed rectangle, and randomly select one side of the minimum circumscribed rectangle to set a reference heading angle. The convex hull algorithm can be used to enclose all farmland boundary points in the convex hull to form a circumscribed rectangle, define the working area of the drone, and ensure the integrity of the coverage range. The heading angle is set according to the formed rectangular edge to provide the drone with an initial navigation direction, and subsequent edge detection and path planning are performed based on this direction. The Yolov7-tiny model is introduced and used with The machine selects a corner of the minimum circumscribed rectangle, uses the Yolov7-tiny model to take the corner of the minimum circumscribed rectangle as the starting point, performs real-time edge detection, and finds the actual edge of the farmland. Through image processing technology, the drone can identify the boundary of the farmland and provide accurate data support for path planning; the tilt compensation of the drone during movement is calculated according to the acceleration in the horizontal and vertical directions detected by the drone's accelerometer, and the actual heading angle is obtained. By calculating the actual heading angle, the flight direction of the drone can be quickly adjusted to prevent the planned path from deviating and failing to fully cover the farmland; finally, the flight angle of the drone is adjusted to make the actual heading angle consistent with the reference heading angle, and at the same time, the angle of the reference heading angle is adjusted to rotate 90 degrees toward the inside of the farmland at the actual edge of the farmland to realize round-trip farmland path planning. The drone flies along the edge of the planned rectangle, ensuring that every corner of the farmland can be accurately covered without omission.
[0063] In a specific embodiment, a coordinate dataset of farmland boundary points is obtained, and a density clustering algorithm is used to denoise the coordinate dataset. The solution for obtaining the denoised dataset is:
[0064] S11. Obtain the coordinate dataset of the farmland boundary points:
[0065] Collection equipment: Use drones equipped with Beidou navigation modules or handheld devices to collect GPS coordinate data along the boundaries of farmlands and store them as a set of longitude and latitude coordinate points using longitude and latitude as the coordinate system;
[0066] Collection method: Operators walk along the boundaries of farmlands, and drones assist in collecting points in hard-to-reach areas to ensure the integrity of boundary data;
[0067] Output result: A coordinate set {P1,P2,...,P n}, the data format is (x,y);
[0068] S12, denoising the coordinate data set using a density clustering algorithm to obtain a denoised data set:
[0069] S121: randomly selecting a boundary point in the coordinate data set, and forming a neighborhood radius with the point as the center; the value of the neighborhood radius is manually set according to actual conditions and experience;
[0070] S122: judging the number of boundary points in the neighborhood of the point, if the number is less than the set density threshold, the point is a noise point; if the number is greater than or equal to the set density threshold, the point is marked as a core point, and a cluster is formed by expansion, and the cluster expansion is stopped when all boundary points in the neighborhood of the current point are traversed;
[0071] S123: after all boundary points are marked, the points not belonging to any cluster are noise points;
[0072] The denoising using the density clustering algorithm is shown in FIG. 2, Figure 2a is a coordinate point diagram before processing, in which the x and y axes are longitude and latitude, the points in the diagram are farmland coordinate points, and the points circled in red are typical noise points, Figure 2b is a coordinate point diagram after processing.
[0073] In this scheme, the actual farmland coordinates are collected by the Beidou system, and the longitude and latitude are used as the x and y axes of the coordinates, so that the actual coordinate values can be used for subsequent path planning, and the unmanned aerial vehicle is equipped with a buckle navigation, realizing the intelligentization of the unmanned aerial vehicle autonomous operation and improving the efficiency of path planning;
[0074] The data denoising using the density clustering algorithm is suitable for irregular farmland, has good noise elimination effect, and can improve the accuracy of the data.
[0075] In specific embodiments, a convex hull algorithm is introduced, the convex hull algorithm is used to traverse all coordinates in the denoised data set, a plurality of convex hull points are found, all convex hull points are connected, a minimum circumscribed rectangle is generated, and a scheme of setting a reference heading angle according to one side of the minimum circumscribed rectangle is:
[0076] In this embodiment, the Graham scan method is used, and the specific steps are as follows:
[0077] S21, the denoised data set is randomly divided into n groups, each group containing m farmland boundary points; in this embodiment, the number of selected convex hull points is 21, that is, the denoised data set is divided into 21 groups;
[0078] S22, selecting a farmland boundary point O point with the smallest x coordinate and y coordinate in the denoised data set as a reference point, and calculating the polar angle of all other farmland boundary points with the point;
[0079] S23. In each group, the farmland boundary points included in the group are sorted in ascending order of polar angle. If two farmland boundary points have the same polar angle, the farmland boundary points are sorted in ascending order of distance from the reference point to form a point set.
[0080] S24. Randomly select a farmland boundary point A from a group as a preset convex hull point, construct a vector OA, randomly select a detection point i from the group, construct a vector Oi, calculate the cross product of the vector OA and Oi, and determine whether the cross product is positive or negative:
[0081] If the result is positive, point i is a non-convex hull point, and point A is still the current convex hull point. Point A and the reference point form a vector and participate in the vector cross product calculation of the next farmland boundary point.
[0082] If the result is negative, then point A is not a convex hull point. Set point i as the new convex hull point, form a vector with the reference point, and use it in the vector cross product calculation of the next farmland boundary point. This continues until all farmland boundary points in the group are traversed and the final convex hull point is used as the convex hull point of the group.
[0083] S25, traverse the sorted point sets of the remaining groups in sequence to obtain all convex hull points including the reference point, connect two adjacent convex hull points in sequence to generate a minimum circumscribed rectangle that encloses the remaining non-convex hull points of the farmland boundary points;
[0084] S26, selecting a corner of the rectangle as a starting point, and presetting a reference heading angle based on one of the sides;
[0085] The convex hull algorithm is shown in Figure 3. Figure 3a The 21 convex hull points are formed in the middle. Connecting the convex hull points can enclose the remaining farmland boundary points in the convex hull. Figure 3b is the virtual minimum enclosing rectangle formed by the convex hull points; the preset reference heading angle is as follows Figure 4 As shown, the convex hull algorithm is used in this embodiment to enclose all the boundary points of the farmland in the convex hull to form a circumscribed rectangle, which defines the working area of the drone and ensures the integrity of the coverage range; at the same time, the heading angle is preset according to the edge of the rectangle to provide the drone with an initial flight direction, and subsequent edge detection and path planning are performed based on the flight direction.
[0086] In a specific embodiment, the Yolov7-tiny model is introduced and a corner of the minimum bounding rectangle is randomly selected. The Yolov7-tiny model is used to perform real-time edge detection starting from the corner of the minimum bounding rectangle. The solution for finding the actual edge of the farmland is:
[0087] S31, grayscale and binarization processing is performed on the image, such as Figure 5a and Figure 5b As shown,
[0088] S32, use Gaussian filtering to reduce the level of detail, and finally use Sobel operator to plan the edge, such as Figure 5c and Figure 5d shown.
[0089] In this embodiment, the Yolov7-tiny model is used in combination with the drone to perform real-time edge detection to obtain the actual farmland edge, providing accurate data support for the subsequent drone to identify the farmland boundary and perform path planning, that is, to change the heading angle.
[0090] In a specific embodiment, the solution for calculating the tilt compensation during the movement of the drone based on the acceleration in the horizontal and vertical directions detected by the acceleration sensor of the drone to obtain the actual heading angle is:
[0091] Decompose the Earth's magnetic field into components in the x and y directions parallel to the horizontal plane and a component in the z direction perpendicular to the horizontal plane;
[0092] The component in the x direction is shown in formula (6),
[0093]
[0094] Among them, H x Represents the component in the x direction, X M represents the component of the magnetic compass in the x direction, Z M represents the component of the magnetic compass in the z direction, represents the pitch angle based on the acceleration sensor, as shown in formula (7),
[0095]
[0096] Among them, A x ,A y ,A z are the accelerations in the x, y, and z directions respectively;
[0097] The component in the y direction is shown in formula (8),
[0098]
[0099] Among them, H y represents the component in the y direction, and θ represents the tilt angle based on the acceleration sensor, as shown in formula (9),
[0100]
[0101] The actual heading angle is calculated based on the x-direction component and the y-direction component, as shown in formula (10):
[0102]
[0103] Where β represents the actual heading angle.
[0104] In this solution, the electronic compass identifies the magnetic north pole, but the electronic compass must remain horizontal. However, it is difficult for the drone to remain horizontal during flight, and there will be an angle between it and the horizontal ground. Therefore, an acceleration sensor is used to compensate for this. The true heading angle can be calculated based on the acceleration in the xyz directions to ensure the accuracy of the magnetic north pole identification. At the same time, the actual heading angle can be calculated to quickly adjust the drone's flight direction to prevent the planned path from deviating and failing to fully cover the farmland.
[0105] In a specific embodiment, the flight angle of the drone is adjusted so that the actual heading angle is consistent with the reference heading angle, and at the actual edge of the farmland, the reference heading angle is adjusted to rotate 90 degrees toward the inside of the farmland to achieve round-trip farmland path planning, including:
[0106] S51, set the two perpendicular sides of the minimum bounding rectangle to be Y1=K1*X1+b and Y2=K2*X2+b, where K1 represents the slope of one side of the rectangle, K2 represents the slope of the other vertical side; X1, Y1 represent the horizontal and vertical coordinates of the side, b is a constant, X2, Y2 represent the horizontal and vertical coordinates of the other vertical side;
[0107] S52, set the flight direction corresponding to the reference heading angle to be parallel to one side of the rectangle, that is, parallel to the slope direction corresponding to Y1=K1*X1+b; calculate the actual heading angle according to the current actual coordinate value of the UAV and formula (10); if the current reference heading angle α and the actual heading angle β are different, adjust the flight direction of the UAV and return to the direction corresponding to the reference heading angle; if the two values are equal, the UAV maintains the direction corresponding to the current actual heading angle;
[0108] S53. When the UAV reaches the edge of the farmland, the reference heading angle is rotated 90 degrees toward the inside of the farmland. At this time, the flight direction is parallel to the vertical edge, that is, parallel to the slope direction corresponding to Y2=K2*X2+b. When the UAV flight reaches the preset flight time, the current reference heading angle is rotated 90 degrees toward the inside of the farmland, and is parallel to the slope direction corresponding to Y1=K1*X1+b again, and flies in the opposite direction.
[0109] In this scheme, the three-dimensional magnetic component obtained from the three-dimensional magnetometer of the electronic compass and the acceleration component obtained from the acceleration sensor are brought into the above formulas (6), (7) and (8) to calculate the real heading angle of the drone during navigation. Taking the drone flying counterclockwise along the farmland as an example, the virtual path planning is as follows: Figure 6 As shown, the actual heading angle is calculated according to formula (10), the reference heading angle is compared with the preset heading angle, and the flight direction of the UAV is adjusted to be consistent with the flight direction corresponding to the reference heading angle;
[0110] When the drone touches the boundary of a farmland, it changes the reference heading angle and turns 90 degrees toward the inside of the farmland, 90 degrees perpendicular to the original flight direction. After flying for a preset time, it updates the reference heading angle and turns 90 degrees toward the inside of the farmland, flying in the opposite direction of the original flight direction, forming a "round-trip" path planning. The actual path planning is as follows: Figure 7 shown.
[0111] The drone flies along the planned rectangular edge, forming a round-trip farmland path planning, ensuring that every corner of the farmland can be accurately covered without omission, solving the problem of path planning for plant protection drones during irregular operations.
[0112] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for irregular farmland path planning for plant protection UAVs based on convex hull algorithm, characterized in that: include: S1: Obtain a coordinate dataset of farmland boundary points, and use a density clustering algorithm to denoise the coordinate dataset to obtain a denoised dataset; S2: Introduce the convex hull algorithm and use it to traverse all coordinates in the denoised dataset, find multiple convex hull points, connect all convex hull points, and generate the minimum circumscribed rectangle. The specific steps are as follows: S21, randomly dividing the denoised data set into n groups, each group containing m farmland boundary points; S22, selecting the farmland boundary point O with the smallest x-coordinate and y-coordinate in the denoised data set as a reference point, and calculating the polar angles between all other farmland boundary points and the farmland boundary point; the x-coordinate and y-coordinate are coordinates in a longitude and latitude coordinate system; S23. Sort the farmland boundary points in each group in ascending order of polar angle. If two farmland boundary points have the same polar angle, sort them in ascending order of distance from the farmland boundary points to the reference point to form a point set. S24. Randomly select a farmland boundary point A in a group as a preset convex hull point, construct a vector OA, randomly select a detection point i in the same group, construct a vector Oi, calculate the cross product of vector OA and Oi, and determine whether the cross product is positive or negative: If the result is positive, point i is a non-convex hull point, and point A is still the current convex hull point. Point A and the reference point form a vector and participate in the vector cross product calculation of the next farmland boundary point. If the result is negative, then point A is not a convex hull point. Point i is set as a new convex hull point. This new convex hull point and the reference point form a vector, which is then used in the vector cross product calculation of the next farmland boundary point. This continues until all farmland boundary points in the same group are traversed, and the final convex hull point is used as the convex hull point in the randomly selected group. S25, traverse the sorted point sets of the remaining groups in sequence to obtain all convex hull points including the reference point, connect two adjacent convex hull points in sequence to generate a minimum circumscribed rectangle that encloses the remaining non-convex hull points of the farmland boundary points; and randomly selecting one side of the minimum circumscribed rectangle to set a reference heading angle; S3: Introducing the Yolov7-tiny model and randomly selecting a corner of the minimum bounding rectangle, using the Yolov7-tiny model to perform real-time edge detection with the corner of the minimum bounding rectangle as the starting point to find the actual edge of the farmland; S4: Calculate the tilt compensation of the drone during movement according to the acceleration in the horizontal and vertical directions detected by the acceleration sensor of the drone to obtain the actual heading angle; S5: Adjust the flight angle of the drone so that the actual heading angle is consistent with the reference heading angle, and at the same time adjust the reference heading angle at the actual edge of the farmland to rotate 90 degrees toward the inside of the farmland to achieve round-trip farmland path planning.
2. The method for irregular farmland path planning of a plant protection UAV based on a convex hull algorithm according to claim 1, characterized in that: The convex hull algorithm is the Graham scan method.
3. The irregular farmland path planning method for a plant protection UAV based on a convex hull algorithm according to claim 1 is characterized in that: The tilt compensation during the UAV's motion is calculated based on the horizontal and vertical accelerations detected by the UAV's accelerometer to obtain the actual heading angle, including: Decompose the Earth's magnetic field into components in the x and y directions parallel to the horizontal plane and a component in the z direction perpendicular to the horizontal plane; The component in the x direction is shown in formula (1), (1) in, represents the component in the x direction, represents the component of the magnetic compass in the x direction, represents the component of the magnetic compass in the z direction, represents the pitch angle based on the acceleration sensor, as shown in formula (2), (2) in, are the accelerations in the x, y, and z directions respectively; The component in the y direction is shown in formula (3), (3) in, represents the component in the y direction, represents the tilt angle based on the acceleration sensor, as shown in formula (4), (4) The actual heading angle is calculated based on the x-direction component and the y-direction component, as shown in formula (5): (5) in, Indicates the actual heading angle.
4. The method for irregular farmland path planning of a plant protection UAV based on a convex hull algorithm according to claim 3, characterized in that: Adjusting the flight angle of the drone so that the actual heading angle is consistent with the reference heading angle, and at the actual edge of the farmland, adjusting the reference heading angle 90 degrees toward the inside of the farmland to achieve round-trip farmland path planning, including: S51, set the two perpendicular sides of the minimum bounding rectangle to be and ,in , , represents the slope of a side of the rectangle, represents the slope of the other vertical side; Represents the horizontal and vertical coordinates of one side of the rectangle, b is a constant, Indicates the horizontal and vertical coordinates of the other vertical side; S52, set the flight direction corresponding to the reference heading angle to be parallel to one side of the rectangle, that is, The corresponding slope direction is parallel; the actual heading angle is calculated according to the current actual coordinate value of the drone and formula (5). If the current reference heading angle and actual heading angle If the values of are different, the drone will adjust its flight direction and return to the direction corresponding to the reference heading angle. If the two values are equal, the drone will maintain the direction corresponding to the current actual heading angle. S53. When the UAV reaches the edge of the farmland, the reference heading angle is rotated 90 degrees toward the inside of the farmland. At this time, the flight direction is parallel to the vertical edge, that is, When the drone reaches the preset flight time, it will rotate the current reference heading angle 90 degrees to the inside of the farmland and re-align with the slope direction. The corresponding slope directions are parallel and fly in opposite directions.
5. The method for irregular farmland path planning of a plant protection UAV based on a convex hull algorithm according to claim 1, characterized in that: Denoising the coordinate dataset using a density clustering algorithm to obtain a denoised dataset, including: S11, randomly selecting a boundary point in the coordinate data set, and forming a neighborhood radius with the boundary point as the center of the circle; S12. Determine the number of boundary points within the neighborhood radius of the boundary point. If the number is less than the set density threshold, the boundary point is considered a noise point. If the number is greater than or equal to the set density threshold, mark the boundary point as a core point and expand it to form a cluster. When all boundary points in the neighborhood radius of the current point are traversed, stop expanding the cluster. S13. After all boundary points are marked, the points that do not belong to any cluster are noise points.
Citation Information
Patent Citations
Pesticide application robot farmland path planning method capable of combining visual sensor with laser sensor
CN109885063A
Unmanned aerial vehicle track and resource allocation joint optimization method for multi-carrier communication
CN110730031A