Plant protection unmanned aerial vehicle spraying control method based on drift risk
By using a spraying prediction model based on a time-mode sparse attention mechanism and an LSTM network, combined with an outer-loop and inner-loop nonlinear model predictive controller, the problem of spray drift of agricultural drones under complex terrain and wind conditions was solved, achieving accurate settling and precise control of the sprayed material.
Patent Information
- Application Number
- CN202511706258.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-20
- Publication Date
- 2026-02-24
AI Technical Summary
Under complex terrain and changing wind conditions, agricultural drones pose a risk of spraying drift, making it difficult to achieve accurate spraying control, resulting in uneven distribution of sprayed materials, environmental pollution, and damage to non-target crops.
A spraying prediction model based on time-mode sparse attention mechanism and LSTM network is adopted, combined with an outer-loop and inner-loop nonlinear model predictive controller to collect and optimize multi-source data in real time, dynamically update UAV spraying data and flight data, and achieve accurate settling of sprayed materials through iterative optimization and controller feedback.
It reduces spray drift caused by wind field information interference, improves the uniformity of spray coverage in the area to be sprayed, reduces spray waste and impact on non-spray areas, and improves spray accuracy.
Smart Images

Figure CN121559866A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of agricultural drones, and relates to, but is not limited to, a method for controlling the spraying of agricultural drones based on drift risk. Background Technology
[0002] As a key technology in precision agriculture, agricultural drone spraying enhances droplet penetration by using rotors to press down airflow and employs low-altitude, low-volume spraying, effectively improving the utilization rate of sprayed materials and reducing the amount of chemical sprays used, which is of great significance for improving agricultural production efficiency. However, when operating in complex terrain areas such as mountains and hills, the undulating terrain and surface obstruction can easily lead to uneven wind field distribution, seriously affecting the flight stability of drones and the accuracy of spraying trajectories. This not only results in uneven distribution of sprayed materials on target crops and reduced agricultural control effects, but also causes a large amount of sprayed materials to drift to non-target areas, causing environmental pollution, endangering human and animal safety, and damaging non-target crops.
[0003] In related technologies, when controlling agricultural drones for spraying, the focus is usually on improving the tracking accuracy of the preset flight path. Regarding the problem of spray drift, current agricultural drone spraying control methods rely on the analysis of single factors or simplified models, which are difficult to accurately reflect the complex settlement situation under the coupled effects of multiple dynamic factors in actual operations, leading to a discrepancy between the predicted results and the actual drift distribution.
[0004] With the increasing complexity of plant protection operations, especially in mountainous and hilly areas with significant topographic relief, drone spraying is simultaneously affected by multiple factors such as terrain disturbance, wind field changes, and flight attitude, further increasing the difficulty of accurate prediction and control. Therefore, establishing a method for predicting pesticide sedimentation distribution that can comprehensively reflect the coupled effects of multiple factors, and on this basis, achieving real-time control of the application process to improve the spraying accuracy and reduce the risk of pesticide drift in complex environments, has become an urgent technical problem to be solved. Summary of the Invention
[0005] In view of this, the embodiments of this application provide a spraying control method for agricultural drones based on drift risk, which at least solves the problem that the sprayed material has a drift risk under complex terrain and changing wind field conditions, making it impossible to achieve accurate spraying control of agricultural drones.
[0006] The technical solution of this application embodiment is implemented as follows: In a first aspect, embodiments of this application provide a method for controlling the spraying of agricultural drones based on drift risk, including: Multi-source sequence data of the area to be sprayed is collected in real time and preprocessed. The multi-source sequence data includes environmental data, UAV flight data, and UAV spraying data. The preprocessed multi-source sequence data is input into a trained spraying prediction model for prediction to obtain the deposition distribution data of the sprayed material. The spraying prediction model is constructed based on a temporal pattern sparse attention mechanism and an LSTM network. The deposition distribution data, UAV flight data, UAV spraying data, and acquired wind field information are input into an outer-loop nonlinear model predictive controller. Based on a set optimization objective function, the constructed UAV dynamics model is iteratively optimized until the error between the deposition distribution data and the desired deposition distribution data satisfies the optimization objective function and is minimized. The desired UAV position sequence is then output. The dynamics model is constructed based on the current wind field information and UAV flight data. Based on the desired UAV position sequence, the UAV spraying process is tracked and controlled by an inner-loop nonlinear model predictive controller, which adjusts the UAV flight data and the UAV spraying data in real time until the current spraying effect satisfies the desired deposition distribution data.
[0007] The beneficial effects of the technical solutions provided in this application include at least the following: An outer-loop nonlinear model predictive controller controls a spraying prediction model to predict the spraying effect of the sprayed material based on environmental data, spraying data, and flight data, obtaining sedimentation distribution data. The outer-loop nonlinear model predictive controller dynamically updates the drone spraying data and calculates the drone's desired position sequence through iterative optimization. The updated drone spraying data improves the uneven or inaccurate spraying effect caused by wind field interference, making the predicted distribution of the sprayed material as close as possible to the desired distribution. Based on the drone spraying data and the desired position sequence output by the outer-loop nonlinear model predictive controller, an inner-loop nonlinear model predictive controller controls the drone's flight data to ensure the drone arrives at the desired position sequence, reducing the problem of drone flight position deviation caused by wind field interference. By cyclically controlling the drone spraying data and flight data using the inner-loop and outer-loop nonlinear model predictive controllers, the sprayed material from the drone accurately settles into the designated spraying area, reducing waste and the impact of the sprayed material on areas outside the designated spraying area. Attached Figure Description
[0008] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort, wherein: Figure 1A schematic flowchart illustrating a method for controlling agricultural drone spraying based on drift risk, provided in an embodiment of this application; Figure 2 This is a schematic diagram of the framework of a plant protection drone spraying control method based on drift risk, provided in an embodiment of this application. Detailed Implementation
[0009] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. The following embodiments are used to illustrate this application, but are not intended to limit the scope of this application. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0010] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0011] It should be noted that the terms "first, second, and third" used in the embodiments of this application are merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, and third" can be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0012] It will be understood by those skilled in the art that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which the embodiments of this application pertain. It should also be understood that terms such as those defined in general dictionaries should be understood to have a meaning consistent with their meaning in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined as herein.
[0013] This application provides a method for controlling the spraying of agricultural drones based on drift risk. Figure 1 A flowchart illustrating a method for controlling agricultural drone spraying based on drift risk, as provided in this application embodiment, is shown below. Figure 1 As shown, the method includes at least the following steps: Step S110: Collect multi-source sequence data of the area to be sprayed in real time and perform preprocessing; wherein, the multi-source sequence data includes: environmental data, UAV flight data and UAV spraying data.
[0014] Environmental data, especially wind field information, is crucial for assessing the impact of external disturbances on the spraying effectiveness of drones. For example, excessively high wind speeds can cause spray drift, resulting in ineffective spraying outside the designated area or missed areas within the designated area. Angular shifts in wind direction can cause the spraying range to deviate from the intended spraying area, reducing the effective coverage of the sprayed area.
[0015] Therefore, environmental data may lead to the drift and improper settling of sprayed materials. By collecting and analyzing environmental data in real time, it is possible to predict the settling distribution of sprayed materials, thereby providing key input for subsequent optimization and adjustment of UAV flight data and UAV spraying data to compensate for wind field effects and ensure the accuracy of sprayed material settling.
[0016] Drone flight data is the basis for calculating the real-time flight status of drones and adjusting their actual flight trajectories. The stability of the drone's flight trajectory, the uniformity of its flight speed, and the stability of its attitude angles can affect the uniformity of the sprayed material coverage in the spraying area.
[0017] Drone spraying data determines the spraying angle and the actual amount of sprayed material per unit area. Drone spraying data also affects factors such as the angle at which the sprayed material settles on the surface of the crops in the area to be sprayed, thus affecting the actual effect of the sprayed material.
[0018] The three types of data in the above multi-source sequence data provide data support for the subsequent construction of spraying prediction models to evaluate spraying effects, as well as for real-time optimization of UAV control commands.
[0019] When preprocessing multi-source sequence data, the minimum-maximum normalization method is used to linearly transform each type of data in environmental data, UAV flight data, and UAV spraying data to a unit interval, resulting in normalized multi-source sequence data. Then, the correlation between features is removed by principal component analysis algorithm to obtain preprocessed multi-source sequence data.
[0020] Step S120: Input the preprocessed multi-source sequence data into the trained spraying prediction model for prediction to obtain the sedimentation distribution data of the sprayed material; wherein, the spraying prediction model is constructed based on the temporal pattern sparse attention mechanism and LSTM network.
[0021] To predict the spraying effect of drones by obtaining the sedimentation distribution or distance from the spraying area.
[0022] Based on the temporal pattern sparse attention mechanism, feature extraction is performed on current environmental data, UAV flight data, and UAV spraying data to obtain weighted key vectors. Using the gating mechanism of the LSTM network in the spraying prediction model, the temporal dependencies of the weighted key vectors are calculated to obtain time-series features. Based on these time-series features, the deposition distribution data of the sprayed material is obtained through the LSTM network.
[0023] The collected environmental data, drone flight data, and drone spraying data are input into the spraying prediction model. The spraying prediction model predicts the deposition distribution data of the sprayed material at the next moment based on the current environmental data, drone flight data, and drone spraying data.
[0024] Step S130: Input the settlement distribution data, UAV flight data, UAV spraying data, and acquired wind field information into the outer loop nonlinear model prediction controller. Iteratively optimize the constructed UAV dynamic model based on the set optimization objective function until the error between the settlement distribution data and the expected settlement distribution data satisfies the optimization objective function and minimizes it. Output the expected position sequence of the UAV. The dynamic model is constructed based on the wind field information and UAV flight data at the current moment.
[0025] The drone flight data and drone spraying data input from the outer loop are obtained by detecting the drone's status through different sensors. The acquired wind field information is calculated and predicted based on the detected wind field information at the current moment to obtain the wind field information for the next moment.
[0026] The outer-loop nonlinear model predictive controller optimizes the drone spraying data, controls the drone to spray based on the optimized drone spraying data, and outputs the expected drone position sequence for the next moment.
[0027] The outer-loop nonlinear model predictive controller iteratively optimizes to find the UAV's expected position sequence that minimizes the error between the predicted subsidence distribution data and the expected distribution data. This sequence constitutes the UAV's expected flight trajectory at multiple future moments.
[0028] To achieve the goal of minimizing the aforementioned error, the outer-loop nonlinear model predictive controller performs the following optimizations. Since the wind field changes dynamically, the wind field information at the next moment will affect the spraying effect. Therefore, when solving for the desired UAV position sequence, the outer-loop nonlinear model predictive controller incorporates the wind field information at the next moment, optimizing the objective function while being constrained by UAV dynamics, to obtain the optimal UAV spraying data in real time. This completes one cycle for the current moment and begins the cycle for the next moment.
[0029] After this loop is completed, the outer loop nonlinear model predictive controller outputs the expected position sequence of the UAV at the next moment, which assists the inner loop nonlinear model predictive controller in compensating for the interference of wind field information on the UAV spraying at the next moment.
[0030] The desired drone position sequence can be the desired drone positions at one or more future times. If there are multiple times, the earliest set of drone positions among these times can be selected as the desired drone positions. In other words, the desired drone position for the next time moment is selected from the sequence of desired drone positions at multiple times. This desired drone position for the next time moment is then used as the input to the inner-loop nonlinear model predictive controller for the next iteration.
[0031] Step S140: Based on the expected position sequence of the UAV, the spraying process of the UAV is tracked and controlled by the inner loop nonlinear model predictive controller, and the flight data and spraying data of the UAV are adjusted in real time until the current spraying effect meets the expected settlement distribution data.
[0032] The drone's flight trajectory is tracked by an inner-loop nonlinear model predictive controller, ensuring that the drone's trajectory matches the desired drone position sequence output by the outer-loop nonlinear model predictive controller. During this process, the drone spraying data from the previous loop remains unchanged.
[0033] The inner-loop nonlinear model predictive controller first guides the drone to a suitable position, which is the expected position of the drone at the next moment corresponding to the aforementioned expected position sequence. Based on the drone being in the suitable position, the controller then controls the spraying data, enabling the drone to determine its control commands according to the suitable position and appropriate spraying data. Spraying according to these control commands achieves the desired effect, completing one control cycle.
[0034] During the operation of the inner-loop nonlinear model predictive controller, the current drone flight data and drone spraying data are detected in real time, and the drone flight data and drone spraying data are fed back to the outer-loop nonlinear model predictive controller for the next round of prediction and optimization, correcting the drone spraying drift and reducing spraying drift caused by wind field or other environmental factors.
[0035] This application presents a drone spraying control method based on drift risk. An outer-loop nonlinear model predictive controller controls a spraying prediction model to predict the spraying effect of the sprayed material based on environmental data, spraying data, and flight data, obtaining sedimentation distribution data. The outer-loop nonlinear model predictive controller dynamically updates the drone spraying data and calculates the drone's desired position sequence through iterative optimization. The updated drone spraying data improves the uneven or inaccurate spraying effect caused by wind interference, making the predicted distribution of the sprayed material as close as possible to the desired distribution. Based on the drone spraying data and the desired position sequence output by the outer-loop nonlinear model predictive controller, an inner-loop nonlinear model predictive controller controls the drone's flight data to ensure the drone arrives at a position that matches the desired position sequence. This reduces the problem of drone flight position deviation caused by wind interference. By cyclically controlling the drone spraying data and flight data using the inner-loop and outer-loop nonlinear model predictive controllers, the sprayed material is accurately deposited into the designated spraying area, reducing waste and the impact of the sprayed material on areas outside the designated spraying area.
[0036] In some embodiments, the trained spraying prediction model is obtained through the following steps: Step S101: Based on a three-dimensional lidar sensor, the actual sedimentation distribution data of the sprayed material in the area to be sprayed is obtained by measuring the coordinates of the area to be sprayed in space.
[0037] A 3D lidar mounted on a drone performs a panoramic scan of the area to be sprayed, measuring the emission and reception times of the laser pulses. Based on the time difference between emission and reception times, and the emission angle of the laser beam from the 3D lidar sensor, the coordinates of the sprayed particles in three-dimensional space are calculated, resulting in a 3D point cloud. For example, a 3D lidar is a 3D laser detection and ranging sensor.
[0038] The 3D point cloud is projected onto a 2D horizontal plane to generate a 2D scatter plot of the sprayed material. Based on the 2D scatter plot, the mean and standard deviation of the sprayed material distribution are calculated to obtain the true settlement distribution data of the sprayed material.
[0039] Step S102: Obtain historical multi-source sequence data, combine it with the actual settlement distribution data, and construct a sample pair set ( , ;in, This represents the K types of information acquired at time t, including historical environmental data, drone flight data, drone spraying data, and wind field information; This represents the J settlement distribution data acquired at time t, including the average value of the actual sprayed settlement distribution under given conditions. and standard deviation .
[0040] Step S103: Preprocess the data in the sample set and divide it into training set and test set according to time order.
[0041] The preprocessed data are arranged in chronological order, and the first 80% of the data sorted by time is used as the training set, while the last 20% of the data sorted by time is used as the test set.
[0042] Step S104: Construct the initial model based on the temporal pattern sparse attention mechanism and LSTM network.
[0043] Step S105: Input the preprocessed training set into the initial model for iterative training, and input the preprocessed test set into the trained model for prediction until the predicted settlement distribution data meets the actual settlement distribution data, thereby obtaining the trained spraying prediction model.
[0044] In some embodiments, the "environmental data" in step S110 includes terrain height, vegetation height, and wind field information; in step S110, "real-time acquisition of multi-source sequence data of the area to be sprayed and preprocessing" includes: Step S1101: Detect the terrain height using a GPS sensor; measure the height difference between the top of the vegetation and the drone using a lidar to obtain the vegetation height; detect the wind speed and direction using an anemometer to obtain the wind field information. Step S1102: The drone's flight data and spraying data are collected in real time using various sensors mounted on the drone itself; the drone's flight data includes the drone's current position, flight speed, flight altitude, yaw angle, pitch angle, and yaw rate; the drone's spraying data includes spraying angle and spraying pressure. Step S1103: Normalize the multi-source sequence data and remove feature correlations using principal component analysis algorithm to obtain preprocessed multi-source sequence data.
[0045] In some embodiments, step S1103, "normalizing the multi-source sequence data and removing feature correlations using principal component analysis to obtain preprocessed multi-source sequence data," includes... Step S11031: Using the minimum-maximum normalization method, analyze the K types of information in the multi-source sequence data acquired at time t. Normalization is performed to obtain normalized multi-source sequence data. ; Among them, the normalized multi-source sequence data The calculation is shown in formula (1): Formula (1); in, represent K-type information, Representing K types of information The minimum value, Representing K types of information The maximum value.
[0046] Step S11032, for the normalized multi-source sequence data After sorting, we obtain a t×K dimensional matrix Z, where each row of matrix Z represents a sample at time t, and each column of matrix Z represents one of the K types of features; Step S11033: By calculating the covariance matrix Σ of the matrix Z, the correlation between the K types of information affecting the deposition distribution of the sprayed material is analyzed; the dimension of the covariance matrix Σ is K×K. The covariance matrix Σ is calculated as shown in formula (2): Formula (2); in, It is the transpose of matrix Z, where n represents the total number of samples in the multi-source sequence data.
[0047] Step S11034: Perform eigenvalue decomposition on the covariance matrix Σ to obtain K eigenvalues and K eigenvectors; arrange the eigenvalues and eigenvectors in descending order of their importance to the sedimentation distribution of the sprayed material. Step S11035: Based on a preset threshold, determine the top ε main feature values that affect the sedimentation distribution of the sprayed material from the K feature values; select the feature vectors corresponding to the ε main feature values to form a K×ε dimensional principal component matrix P; Step S11036: Dimensionality reduction of matrix Z using the principal component matrix P eliminates features unrelated to the deposition distribution of the sprayed material while retaining features related to the deposition distribution of the sprayed material, resulting in preprocessed multi-source sequence data. , B is t× A dimensional feature matrix.
[0048] In step S120, the execution flow of the temporal pattern sparse attention mechanism includes: Step S1201: Based on a preset time interval, select a subset of key points corresponding to multiple key time points from the preprocessed multi-source sequence data; the key time points represent time points that are highly correlated with the sedimentation distribution of the sprayed material. Step S1202: Perform a linear transformation on the subset of key points to generate a query matrix Q, a key matrix M, and a value matrix V; calculate the attention score Fa between the query matrix Q and the key matrix M; The attention score Fa between the query matrix Q and the key matrix M is calculated as shown in formula (3): Formula (3); in, For activation function, It is the dimension of the key matrix M.
[0049] Step S1203: Based on the attention score Fa, perform a weighted summation on the value matrix V to generate a key feature vector C related to the settlement distribution.
[0050] The calculation of the key feature vector C related to the settlement distribution is shown in formula (4): Formula (4); The key feature vector C is the output of the temporal pattern sparse attention mechanism. Using the key feature vector C as input to an LSTM network, the spray distribution of the sprayed material is predicted at multiple time points, yielding the mean and standard deviation of the sprayed material deposition distribution at these future time points.
[0051] In step S130, "the settlement distribution data, UAV flight data, UAV spraying data, and acquired wind field information are input into the outer-loop nonlinear model prediction controller, and the constructed UAV dynamics model is iteratively optimized based on the set optimization objective function until the error between the settlement distribution data and the expected settlement distribution data satisfies the optimization objective function to be minimized, and the expected UAV position sequence is output," including: Step S1301: Obtain the expected sedimentation distribution data of the sprayed material; Step S1302: Based on the optimization objective function, calculate the first error between the settlement distribution data and the expected settlement distribution data; Step S1303: Based on the outer loop nonlinear model predictive controller, when the first error does not satisfy the optimization objective function minimization, based on the settlement distribution data, the UAV position sequence that satisfies the constructed UAV dynamics model is solved in reverse. Step S1304: Based on the outer loop nonlinear model prediction controller, control the UAV position sequence to be input into the spraying prediction model, predict new settlement distribution data again, and return to the step of calculating the first error; Step S1305: Output the UAV's expected position sequence until the first error satisfies the optimization objective function minimization.
[0052] Figure 2 A schematic diagram illustrating the framework of a plant protection drone spraying control method based on drift risk, as provided in this application embodiment, is shown below. Figure 2 As shown, the vegetation height is calculated by measuring the height difference between the top of the vegetation and the drone using lidar. Wind speed and direction are obtained using a wind speed sensor, and terrain height is measured using a GPS sensor. The latitude, longitude, and altitude information of the area to be sprayed are obtained through Bessel geodetic coordinate transformation, providing three-dimensional coordinate information for the drone's flight trajectory planning. The latitude and longitude values of the spraying area are converted to Cartesian coordinates using the Miller projection method. The resulting Cartesian coordinates represent the spraying area corresponding to the expected deposition distribution data of the sprayed material.
[0053] Optimize the objective function using the Wasserstein distance function The function is calculated as shown in formula (5): Formula (5); in, This represents the distance metric between point m in the expected settlement distribution data A and point n in the settlement distribution data E. This represents taking the minimum value. This represents the distance metric used to move the sediment at midpoint m in A to midpoint n in E. is the set of all joint distributions with the desired sediment distribution data A and the sediment distribution data E as their marginal distributions.
[0054] In some embodiments, the UAV dynamics model is constructed using difference equations based on the UAV position, flight speed, yaw angle, pitch angle, yaw rate and wind field information collected at time t, under the constraints of the UAV speed range, acceleration range and pitch angle range.
[0055] The UAV dynamics model can calculate the UAV's position at multiple future times based on multiple data points from the current moment. These data points include the UAV's position, flight speed, yaw angle, pitch angle, yaw rate, and wind field information. Assuming the current time is t, and the next time point for the UAV is t+1, the UAV's position at time t+1 is... The position of the UAV at time t+1 is calculated as shown in formula (6): Formula (6); in, This represents the drone's position at the current time t; u represents the drone's number. This represents the time interval from time t to time t+1. Represents the flight speed at the current time t; Represents yaw angle, Represents the pitch angle; This represents the wind speed at time t.
[0056] When the prediction step size is N, the drone positions at times t+2, ..., t+N are calculated sequentially to obtain the drone position sequence for the next N times. The expected UAV position sequence output by the outer-loop nonlinear model predictive controller is represented as follows: Wherein, the expected position of the drone at a certain moment k .
[0057] When calculating the dynamics model of the UAV, the yaw angle at time t+1 The calculation is shown in formula (7): Formula (7); in, This represents the time interval from time t to time t+1. The yaw angle represents time t; This represents the yaw rate at time t.
[0058] In addition, the operation of drones is subject to dynamic constraints, including the drone's speed range, acceleration range, and pitch angle range. The range is The range of acceleration a is Pitch angle The range is .
[0059] In some embodiments, step S140, "based on the expected position sequence of the UAV, tracking and controlling the UAV spraying process using an inner-loop nonlinear model predictive controller," includes: Step S1401: Based on the UAV status data and the wind field information, calculate the predicted UAV position sequence for the next preset time period using the UAV dynamics model; Step S1402: Based on the trajectory objective function of the predictive controller using the inner-loop nonlinear model, calculate the second error between the UAV's expected position sequence and the UAV's predicted position sequence; Step S1403: Under the condition of satisfying the speed and acceleration constraints of the UAV, with the goal of minimizing the second error, the trajectory objective function is iteratively solved by a sequential quadratic programming algorithm to generate UAV control commands. Step S1404: Send the UAV control command to the UAV to drive the UAV to adjust its flight data in real time.
[0060] In some embodiments, step S1401, "based on the UAV status data and the wind field information, calculating the predicted UAV position sequence for the next preset time period using the UAV dynamics model," includes: Based on the wind field information for the current time period, the wind field information for the next preset time period is calculated using a Gaussian process model; the wind field information includes wind direction and wind speed.
[0061] Since wind direction in wind field information is periodic and wind speed is smooth, a composite kernel function constructed using periodic kernel and radial basis function kernel is used to train a Gaussian process model to predict the wind field information at the next moment. The prediction results are then input into the outer loop nonlinear model predictive controller to compensate for the interference of wind field information on the deposition distribution of spraying and the flight trajectory of UAVs.
[0062] The current UAV location sequence and the wind field information are input into the UAV dynamics model to obtain the predicted UAV location sequence for the next preset time period.
[0063] In some embodiments, step S1402, "calculating the second error between the UAV's expected position sequence and the UAV's predicted position sequence based on the trajectory objective function of the inner-loop nonlinear model predictive controller," includes: Step S14021: Calculate the deviation between the expected position sequence of the UAV and the predicted position sequence of the UAV to obtain the trajectory tracking error; Step S14022: Based on the current UAV control commands and their weight matrix, calculate the weighted sum of squares of the control inputs to obtain the control cost; Step S14023: Determine the second error based on the trajectory tracking error and the control cost.
[0064] The inner-loop nonlinear model predictive controller receives the UAV's expected position sequence output from the outer-loop nonlinear model predictive controller. Based on the detected UAV flight data and the calculated wind field information for the next time moment, the inner-loop nonlinear model predictive controller recursively generates the UAV's predicted position sequence for the next preset time period using the UAV dynamics model. Wherein, the predicted position of the UAV at time k is represented as .
[0065] For example, the predicted position of the drone at the next moment can be obtained from the predicted position sequence of the drone in the next preset time period, and the deviation between the expected position of the drone at the next moment and the predicted position of the drone at the next moment can be calculated to obtain the trajectory tracking error.
[0066] The desired UAV position sequence output by the controller is predicted using an outer-loop nonlinear model. And the expected position of the drone at a certain moment k. UAV predicted location sequence The predicted location of the drone at a certain moment k The trajectory objective function is constructed using UAV dynamic constraints. The calculation is shown in formula (8): Formula (8); in, Represents tracking error; Represents the cost of controlling input; To set weights.
[0067] Tracking error The calculation is shown in formula (9): Formula (9); The cost of controlling input The calculation is shown in formula (10): in, The predicted location of the drone at time k. It is the expected position of the drone at time k.
[0068] Formula (10); in, It is the control input at time k; yes R is the transpose of the matrix; R is the weight matrix, used to adjust the relative importance of different control inputs.
[0069] In each control cycle, the inner-loop nonlinear model predictive controller, based on the predicted UAV position sequence and the UAV desired position sequence, employs a sequential quadratic programming algorithm to solve for the optimal UAV flight data for the next time step, while minimizing the trajectory objective function and satisfying the UAV dynamic constraints. Based on this optimal flight data, the UAV control commands are determined. Following these control commands, the UAV flies to its desired position at the next time step.
[0070] The outer-loop and inner-loop nonlinear model predictive controllers use the real-time feedback of the UAV's new state as the current state for the next control cycle. They repeatedly predict the UAV's flight trajectory and update its flight data, ensuring the UAV reaches its desired position corresponding to the desired position sequence. Upon reaching the desired position, the outer-loop controller acquires the UAV's current state and predicts the spray material's settling distribution data for the next moment. Based on the deviation between the desired distribution data and the settling distribution data, the outer-loop controller updates the spraying data, ensuring that the settling distribution data obtained from the next moment's flight and spraying data matches the desired distribution. This completes one cycle. The outer-loop controller then feeds back the desired UAV position sequence obtained in this cycle to the inner-loop controller for the next cycle, forming a closed loop.
[0071] It should be noted that, in the embodiments of this application, if the above-mentioned agricultural drone spraying control method based on drift risk is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, or the part that contributes to the related technology, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, mobile hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this application are not limited to any specific hardware and software combination.
[0072] Correspondingly, embodiments of this application provide a computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the steps in any of the above-described methods for controlling agricultural drone spraying based on drift risk. Correspondingly, embodiments of this application also provide a computer program product, which, when executed by a processor of an electronic device, is used to implement the steps in any of the above-described methods for controlling agricultural drone spraying based on drift risk.
[0073] It should be understood that the phrase "one embodiment" or "an embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of this application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of this application, the sequence numbers of the above-described processes do not imply a sequential order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application. The sequence numbers of the above-described embodiments are merely descriptive and do not represent the superiority or inferiority of the embodiments.
[0074] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0075] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0076] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; they may be located in one place or distributed across multiple network units; some or all of the units may be selected to achieve the purpose of the embodiments of this application according to actual needs. In addition, each functional unit in the embodiments of this application may be fully integrated into one processing unit, or each unit may be a separate unit, or two or more units may be integrated into one unit; the integrated unit may be implemented in hardware or in the form of hardware plus software functional units.
[0077] The methods disclosed in the several method embodiments provided in this application can be arbitrarily combined to obtain new method embodiments without conflict. The features disclosed in the several method or device embodiments provided in this application can be arbitrarily combined to obtain new method embodiments or device embodiments without conflict.
[0078] The above description is merely an embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for controlling the spraying of agricultural drones based on drift risk, characterized in that, include: Real-time acquisition and preprocessing of multi-source sequence data of the area to be sprayed; wherein, the multi-source sequence data includes: environmental data, UAV flight data and UAV spraying data; The preprocessed multi-source sequence data is input into the trained spraying prediction model for prediction to obtain the deposition distribution data of the sprayed material; wherein, the spraying prediction model is constructed based on the temporal pattern sparse attention mechanism and LSTM network; The settlement distribution data, UAV flight data, UAV spraying data, and acquired wind field information are input into the outer-loop nonlinear model predictive controller. Based on the set optimization objective function, the constructed UAV dynamic model is iteratively optimized until the error between the settlement distribution data and the expected settlement distribution data satisfies the optimization objective function and minimizes it. The expected position sequence of the UAV is then output. The dynamic model is constructed based on the wind field information and UAV flight data at the current moment. Based on the expected position sequence of the UAV, the spraying process of the UAV is tracked and controlled by an inner-loop nonlinear model predictive controller, and the flight data and spraying data of the UAV are adjusted in real time until the current spraying effect meets the expected sedimentation distribution data.
2. The method according to claim 1, characterized in that, The environmental data includes terrain height, vegetation height, and wind field information; the real-time acquisition and preprocessing of multi-source sequence data of the area to be sprayed includes: The terrain height is detected by a GPS sensor; the vegetation height is obtained by measuring the height difference between the top of the vegetation and the drone using a lidar; and the wind field information is obtained by detecting wind speed and direction using an anemometer. The drone's flight data and spraying data are collected in real time by various sensors onboard the drone. The drone's flight data includes its current position, flight speed, flight altitude, yaw angle, pitch angle, and yaw rate. The drone's spraying data includes spraying angle and spraying pressure. The multi-source sequence data is normalized and principal component analysis is used to remove feature correlations to obtain preprocessed multi-source sequence data.
3. The method according to claim 1, characterized in that, The trained spraying prediction model was obtained through the following steps: Based on a three-dimensional lidar sensor, the actual sedimentation distribution data of the sprayed material in the area to be sprayed is obtained by measuring the coordinates of the area to be sprayed in space. Historical multi-source sequence data were acquired, combined with the actual settlement distribution data, and a sample pair set was constructed. , ;in, This represents the K types of information acquired at time t, including historical environmental data, drone flight data, drone spraying data, and wind field information; This represents the J settlement distribution data acquired at time t, including the average value of the actual sprayed settlement distribution under given conditions. and standard deviation ; The data in the sample set are preprocessed and divided into training set and test set according to time order; An initial model is constructed based on the temporal pattern sparse attention mechanism and LSTM network. The preprocessed training set is input into the initial model for iterative training, and the preprocessed test set is input into the trained model for prediction until the predicted settlement distribution data matches the actual settlement distribution data, thus obtaining the trained spraying prediction model.
4. The method according to claim 2, characterized in that, The process of normalizing the multi-source sequence data and removing feature correlations using principal component analysis to obtain preprocessed multi-source sequence data includes: The K types of information in the multi-source sequence data acquired at time t are processed using the minimum-maximum normalization method. Normalization is performed to obtain normalized multi-source sequence data. ; For the normalized multi-source sequence data After sorting, we obtain a t×K dimensional matrix Z, where each row of matrix Z represents a sample at time t, and each column of matrix Z represents one of the K types of features. By calculating the covariance matrix Σ of the matrix Z, the correlation between the K types of information affecting the deposition distribution of the sprayed material is analyzed; the dimension of the covariance matrix Σ is K×K. The covariance matrix Σ is subjected to eigenvalue decomposition to obtain K eigenvalues and K eigenvectors; the eigenvalues and eigenvectors are arranged in descending order of their importance to the sedimentation distribution of the sprayed material. Based on a preset threshold, the top ε main feature values affecting the sedimentation distribution of the sprayed material are determined from the K feature values; the feature vectors corresponding to the ε main feature values are selected to form a K×ε dimensional principal component matrix P; The matrix Z is dimensionality-reduced using the principal component matrix P to eliminate features unrelated to the sedimentation distribution of the sprayed material while retaining features related to the sedimentation distribution, resulting in preprocessed multi-source sequence data. , B is t× A dimensional feature matrix.
5. The method according to claim 3, characterized in that, The execution flow of the temporal pattern sparse attention mechanism includes: Based on a preset time interval, a subset of key points corresponding to multiple key time points is selected from the preprocessed multi-source sequence data; the key time points represent time points that are highly correlated with the sedimentation distribution of the sprayed material. Perform a linear transformation on the subset of key points to generate a query matrix Q, a key matrix M, and a value matrix V; calculate the attention score Fa between the query matrix Q and the key matrix M; Based on the attention score Fa, the value matrix V is weighted and summed to generate a key feature vector C related to the settlement distribution.
6. The method according to claim 2, characterized in that, The process involves inputting the settlement distribution data, UAV flight data, UAV spraying data, and acquired wind field information into an outer-loop nonlinear model predictive controller. Based on a set optimization objective function, the constructed UAV dynamics model is iteratively optimized until the error between the settlement distribution data and the desired settlement distribution data is minimized according to the optimization objective function. The desired UAV position sequence is then output, including: Obtain the expected sedimentation distribution data of the sprayed material; Based on the optimization objective function, the first error between the settlement distribution data and the expected settlement distribution data is calculated; Based on the outer loop nonlinear model predictive controller, when the first error does not satisfy the optimization objective function minimization, the UAV position sequence that satisfies the constructed UAV dynamics model is solved in reverse based on the settlement distribution data. Based on the outer loop nonlinear model prediction controller, the position sequence of the UAV is input into the spraying prediction model to predict new settlement distribution data again, and then the step of calculating the first error is returned. The expected position sequence of the UAV is output when the first error satisfies the optimization objective function minimization.
7. The method according to claim 1, characterized in that, The step of tracking and controlling the drone spraying process using an inner-loop nonlinear model predictive controller based on the expected position sequence of the drone includes: Based on the UAV status data and the wind field information, the predicted UAV position sequence for the next preset time period is calculated using the UAV dynamics model. Based on the trajectory objective function of the predictive controller using the inner-loop nonlinear model, a second error is calculated between the UAV's expected position sequence and the UAV's predicted position sequence. Under the conditions of satisfying the speed and acceleration constraints of the UAV, with the goal of minimizing the second error, the trajectory objective function is iteratively solved using a sequential quadratic programming algorithm to generate UAV control commands. The drone control commands are sent to the drone, driving it to adjust its flight data in real time.
8. The method according to claim 7, characterized in that, The step of calculating the predicted drone position sequence for the next preset time period based on the drone status data and the wind field information using the drone dynamics model includes: Based on the wind field information for the current time period, the wind field information for the next preset time period is calculated using a Gaussian process model; the wind field information includes wind direction and wind speed. The current UAV location sequence and the wind field information are input into the UAV dynamics model to obtain the predicted UAV location sequence for the next preset time period.
9. The method according to claim 7, characterized in that, The trajectory objective function of the predictive controller based on the inner-loop nonlinear model calculates a second error between the UAV's expected position sequence and the UAV's predicted position sequence, including: The deviation between the expected position sequence of the UAV and the predicted position sequence of the UAV is calculated to obtain the trajectory tracking error; Based on the current UAV control commands and their weight matrices, the weighted sum of squares of the control inputs is calculated to obtain the control cost; The second error is determined based on the trajectory tracking error and the control cost.
10. The method according to any one of claims 1 to 9, characterized in that, The UAV dynamics model is constructed using difference equations based on the UAV's position, flight speed, yaw angle, pitch angle, yaw rate, and wind field information collected at time t, under the constraints of the UAV's speed range, acceleration range, and pitch angle range.