Control method of motor in unmanned aerial vehicle
Through the combination of deep learning models and fuzzy control rules, the stability problem of drones when flying in complex airflow environments is solved, achieving more efficient motor control and better robustness.
Patent Information
- Application Number
- CN202510005833.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-03
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2045-01-03
AI Technical Summary
When existing UAV motor control methods fly in complex airflow environments, it is difficult to respond quickly to airflow disturbances, and lack the ability to accurately identify and predict airflow disturbances, resulting in poor flight stability.
The deep learning model is used to combine multi-dimensional input parameters (such as attitude acceleration, air pressure height change rate, etc.) to calculate the motor's target speed compensation value, and correct the PWM drive signal through fuzzy control rules, and adjust the weight parameters of the deep learning model in real time to optimize the control. Strategy.
It improves the environmental perception and control responsiveness of the drone in complex airflow environments, reduces motor speed fluctuations, extends the motor service life, and enhances the robustness and adaptability of the system.
Smart Images

Figure CN119396015A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of motor control, and in particular to a control method for a motor in a drone. Background Art
[0002] At present, drones generally use PID control algorithms to control the motor speed during actual flight. This control method collects attitude sensor data and combines it with preset PID parameters to calculate the motor's PWM control signal, thereby adjusting the motor speed to maintain the drone's flight attitude. At the same time, some improved solutions introduce adaptive control algorithms to improve control effects by adjusting control parameters in real time.
[0003] However, existing control methods have obvious shortcomings when facing complex airflow environments. First, the parameters of the traditional PID control method are relatively fixed, making it difficult to quickly respond to sudden airflow disturbances; second, although the adaptive control algorithm has improved the control effect to a certain extent, due to the lack of accurate identification and prediction capabilities of airflow disturbances, its adaptability and robustness are still insufficient; finally, existing technologies generally ignore the impact of air pressure changes on flight stability, resulting in unsatisfactory control effects at high altitudes or in environments with drastic changes in air pressure.
[0004] Therefore, there is an urgent need to provide a new UAV motor control method. Summary of the invention
[0005] The present application provides a control method for a motor in a drone to improve the flight stability of the drone in a complex airflow environment.
[0006] The present application provides a method for controlling a motor in a drone, comprising: Acquire the attitude data, air pressure altitude data and current speed data of the motor during the flight of the drone, wherein the attitude data includes pitch angle, roll angle and yaw angle; Based on the attitude data, the pitch acceleration, roll acceleration and yaw acceleration of the drone are calculated, and according to a preset threshold, it is determined whether the current drone is in an airflow disturbance state; When it is determined that the vehicle is in an airflow disturbance state, a target speed compensation value of the motor is calculated based on a pre-trained deep learning model, wherein the input parameters of the deep learning model include: pitch angular acceleration, roll angular acceleration, yaw angular acceleration, pressure altitude change rate, and current motor speed; According to the target speed compensation value, combined with the preset fuzzy control rule, a correction value of the PWM drive signal of the motor is calculated; The corrected PWM drive signal is applied to the motor, and the motor speed feedback information is collected in real time, and the weight parameters of the deep learning model are dynamically adjusted according to the feedback information.
[0007] Furthermore, the acquisition of the attitude data, the air pressure altitude data and the current speed data of the motor during the flight of the drone includes: The inertial measurement unit equipped with the drone collects pitch angle, roll angle and yaw angle in real time. The inertial measurement unit measures linear acceleration and angular velocity through accelerometers and gyroscopes and generates stable attitude data using data fusion algorithms. The ambient air pressure is obtained through the barometer and compensated with the real-time temperature data to calculate the pressure altitude. At the same time, the pressure altitude data is adjusted in real time based on the initial calibration value of the flight controller to adapt to different flight environments; The current speed data of the motor is collected through the Hall sensor or optical encoder of the motor, and the collected speed signal is filtered and interpolated to enhance the continuity and accuracy of the data; The collected data are synchronously integrated through the timestamp alignment method to generate a joint state vector of attitude, altitude and rotation speed.
[0008] Furthermore, the calculating of the pitch acceleration, the roll acceleration and the yaw acceleration of the drone based on the attitude data includes: The pitch angle, roll angle and yaw angle data are collected in real time through the inertial measurement unit to form time series data respectively, where the attitude angle data at each time point is sampled by the sensor and stored in the cache of the flight control system in chronological order; Based on the smoothed attitude angle time series data, the pitch angular velocity, roll angular velocity and yaw angular velocity are calculated by a first difference method, where the angular velocity of each time step is obtained by dividing the attitude angle change value between the current time step and the previous time step by the sampling time interval; The calculated angular velocity sequence is used to calculate the pitch angular acceleration, roll angular acceleration and yaw angular acceleration through the quadratic difference method, where the angular acceleration of each time step is obtained by dividing the angular velocity change between the current time step and the previous time step by the sampling time interval.
[0009] Furthermore, judging whether the current drone is in an airflow disturbance state according to a preset threshold value includes: Get the pitch angle acceleration 、Roll angular acceleration , yaw angular acceleration and the rate of change of pressure altitude ; For the pitch angular acceleration 、Roll angular acceleration , yaw angular acceleration Perform normalization to obtain the normalized pitch angle acceleration , normalized roll angular acceleration And the normalized yaw acceleration ; According to the following formula 1, the disturbance state index is calculated : ; in, , , and is the weighting coefficient; The calculated disturbance state index With preset threshold Compare, if satisfied , then it is judged that the UAV is in an airflow disturbance state.
[0010] Furthermore, the deep learning model includes an input layer, a first hidden layer, a second hidden layer, a third hidden layer and an output layer; The input layer is used to receive the pitch acceleration, roll acceleration, yaw acceleration, pressure altitude change rate and current motor speed data, and normalize the received data, specifically including unifying the dimensions and scaling the amplitudes of different input data to generate standardized feature data; The first hidden layer is used to receive the standardized feature data provided by the input layer, and to process the received standardized feature data of the pitch acceleration, the roll acceleration and the yaw acceleration through two parallel sub-networks; wherein the first sub-network is implemented by a convolutional neural network structure, and is used to extract features from the received standardized feature data of the pitch acceleration, the roll acceleration and the yaw acceleration, and generate local features describing the disturbance characteristics; the second sub-network is implemented by a recursive neural network structure, and is used to process the time series in the received standardized feature data of the pitch acceleration, the roll acceleration and the yaw acceleration, and capture the dynamic change characteristics, and generate time series features; The second hidden layer is used to receive the local features and time series features output by the first hidden layer, and fuse them with the standardized features of the pressure altitude change rate and the current motor speed to generate a fused feature vector; the second hidden layer is implemented by a fully connected network, and the weights of different features are dynamically allocated in combination with the attention mechanism; The third hidden layer is used to receive the fused feature vector and process the fused feature vector through a deep fully connected network, specifically including performing a high-dimensional nonlinear transformation on the fused feature vector to generate a preliminary prediction of the target speed compensation value; during the fusion process, the third hidden layer reduces the overfitting risk of the model through regularization technology and uses activation functions to improve the model's ability to express complex nonlinear relationships; The output layer receives the preliminary prediction from the third hidden layer, and performs correction in combination with the historical flight data to generate a target rotation speed compensation value.
[0011] Furthermore, the second hidden layer generates a fused feature vector through feature fusion and attention allocation mechanism according to the following formula 2: ; in, is the fused feature vector; Indicates Class features, including local features, time series features, pressure altitude change rate features and motor speed features; is the number of features that need to be fused; For the The dynamic weight of the class feature is calculated according to the following formula 3: ; in, For the The weight parameter matrix related to class features; is a static adjustment coefficient that is independent of the flight mode; It is the dynamic adjustment coefficient related to the flight mode; is the number of features that need to be fused; is the flight mode value, calculated according to the following formula 4: ; in, is the rate of change of pressure altitude; is the current motor speed; It is the maximum value of the motor speed in the historical data.
[0012] Furthermore, the third hidden layer optimizes the complex relationship between the fused features through high-dimensional nonlinear transformation, and specifically uses the following formula 5 to process the fused feature vector: ; in, represents the feature vector after high-dimensional nonlinear transformation, which is used to generate a preliminary target speed compensation value; Represents the total number of fused features passed from the second hidden layer to the third hidden layer; Representation and Fusion The associated nonlinear enhancement weights; is the output of the second hidden layer. Fusion features; is a coefficient related to the flight mission and environment; For the Fusion features and Fusion features The interaction weight coefficient of As the activation function, the following formula 6 is used: ; in, is the gain factor adjusted according to the current disturbance strength.
[0013] Furthermore, the size and number of convolution kernels of the first subnetwork in the first hidden layer are determined according to the flight characteristics of the UAV; at the same time, the coverage capability of the feature space is improved by increasing the number of convolution kernels, thereby enhancing the recognition of complex disturbance patterns.
[0014] Furthermore, the calculation of the correction value of the PWM drive signal of the motor based on the target speed compensation value and the preset fuzzy control rule includes: The speed error and error change rate are calculated through the target speed compensation value output by the deep learning model and the current motor speed feedback value, where the speed error is the difference between the target speed compensation value and the current feedback value, and the error change rate is the change in the speed error between consecutive time steps; The speed error and the error change rate are used as input parameters of the fuzzy control rule, and the input parameters are fuzzified based on a preset fuzzy membership function, wherein the fuzzy membership function is pre-designed according to the experimental data of the motor response and the actual requirements of the flight mission, and is divided into a plurality of fuzzy sets; Perform fuzzy reasoning on the fuzzified input according to the fuzzy control rule base; during the reasoning process, use the maximum-minimum synthesis method or weighted average method to comprehensively process the results of multiple rules to ensure the accuracy and stability of the control logic; The fuzzy inference result is defuzzified to generate an accurate PWM correction value, wherein the defuzzification method adopts the centroid method to determine the numerical output of the PWM correction value by calculating the centroid position of the fuzzy set; the PWM correction value represents the duty cycle adjustment amount of the motor PWM drive signal required under the current state.
[0015] Furthermore, the modified PWM drive signal is applied to the motor, and the motor speed feedback information is collected in real time, and the weight parameters of the deep learning model are dynamically adjusted according to the feedback information, including: The calculated corrected PWM drive signal is applied to the motor through the motor control unit of the drone to adjust the actual speed of the motor; The speed sensor installed on the motor collects the current speed feedback information of the motor in real time; The error between the actual motor speed feedback value and the target speed compensation value is calculated, and the error is used as an immediate reward signal for the deep learning model. The weight parameters of the model are dynamically adjusted through the reinforcement learning algorithm.
[0016] The beneficial effects of the technical solution provided by this application include: (1) By introducing a deep learning model and combining multi-dimensional input parameters (including attitude acceleration, pressure altitude change rate, etc.), it is possible to accurately predict and identify disturbance states in complex airflow environments, thereby improving the environmental perception capability of the UAV under adverse weather conditions. (2) The fuzzy control rule is used to correct the PWM drive signal, avoiding the limitation of fixed parameters in traditional PID control, making the control response smoother, effectively reducing the drastic speed fluctuation of the motor, and extending the service life of the motor. (3) By collecting motor speed feedback information in real time and dynamically adjusting the weight parameters of the deep learning model, the adaptive optimization of the control strategy is achieved, the robustness of the system is improved, and the UAV can better cope with airflow disturbances of different intensities. (4) By taking the pressure altitude data as one of the control parameters, the influence of the high-altitude environment on the motor performance is taken into account, the adaptability of the UAV at different altitudes is improved, and the practical application scenarios of the UAV are expanded. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 This is a flow chart of a method for controlling a motor in a drone provided in the first embodiment of the present application. DETAILED DESCRIPTION
[0018] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0019] The first embodiment of the present application provides a method for controlling a motor in a drone. Figure 1 , which is a schematic diagram of the first embodiment of the present application. Figure 1 A first embodiment of the present application provides a method for controlling a motor in a drone for detailed description.
[0020] Step S101: Acquire the attitude data, air pressure altitude data and current speed data of the motor during the flight of the drone, wherein the attitude data includes the pitch angle, the roll angle and the yaw angle.
[0021] In step S101, the drone first obtains various data during the flight process through multiple sensor modules integrated in the flight control system. These sensor modules include but are not limited to: an inertial measurement unit (IMU) for measuring attitude data, a barometer for detecting air pressure altitude, and an encoder or Hall sensor for real-time monitoring of motor speed.
[0022] The acquisition of attitude data is achieved through IMU, which usually contains accelerometers and gyroscopes to measure the linear acceleration and angular velocity of the drone respectively. Through the internal algorithm of IMU, the attitude angle information of the drone, including pitch angle, roll angle and yaw angle, can be calculated by fusion of accelerometer and gyroscope. These attitude data are usually further processed by Kalman filter or other data fusion algorithms to improve their accuracy and noise resistance.
[0023] The acquisition of pressure altitude data depends on the barometer installed on the drone. The barometer calculates the current flight altitude by detecting changes in ambient atmospheric pressure. Usually, the output value of the barometer is calibrated and filtered to eliminate errors caused by external factors such as temperature and airflow fluctuations, and output a stable pressure altitude value.
[0024] The current speed data of the motor can be obtained through the Hall sensor or optical encoder installed on the motor. The Hall sensor calculates the speed by detecting the change of the magnetic field inside the motor, while the optical encoder obtains the speed information through the encoding and decoding of the light signal. These speed data may contain a certain amount of jitter or noise, so they need to be filtered and averaged to provide a stable speed value.
[0025] The acquired attitude data, pressure altitude data and current motor speed data are transmitted to the data processing module through the communication bus in the UAV's flight control unit. This module is usually based on an embedded computing platform and uses a high-speed data interface to integrate multi-source data to ensure the synchronization of each data acquisition channel and the timeliness of the data.
[0026] In step S101, the key point is the accuracy of the sensor and the real-time nature of the data. This requires the reasonable selection of high-precision sensor components and appropriate preprocessing of the collected data to ensure the accurate collection and output of attitude data, pressure altitude data, and motor speed data.
[0027] Furthermore, the acquisition of the attitude data, the air pressure altitude data and the current speed data of the motor during the flight of the drone includes: The inertial measurement unit equipped with the drone collects pitch angle, roll angle and yaw angle in real time. The inertial measurement unit measures linear acceleration and angular velocity through accelerometers and gyroscopes and generates stable attitude data using data fusion algorithms. The ambient air pressure is obtained through the barometer and compensated with the real-time temperature data to calculate the pressure altitude. At the same time, the pressure altitude data is adjusted in real time based on the initial calibration value of the flight controller to adapt to different flight environments; The current speed data of the motor is collected through the Hall sensor or optical encoder of the motor, and the collected speed signal is filtered and interpolated to enhance the continuity and accuracy of the data; The collected data are synchronously integrated through the timestamp alignment method to generate a joint state vector of attitude, altitude and rotation speed.
[0028] In this embodiment, the step of obtaining the attitude data, pressure altitude data and current speed data of the motor during the flight of the drone is intended to provide accurate and real-time input for subsequent flight control and disturbance state judgment. Specifically, this process is achieved through the collaborative work of multiple sensors and data processing methods to ensure the integrity and consistency of the data.
[0029] First, the drone's attitude data is collected in real time through the inertial measurement unit (IMU) equipped with the drone. The inertial measurement unit includes a three-axis accelerometer and a three-axis gyroscope. The accelerometer is used to measure the linear acceleration of the drone in three-dimensional space, while the gyroscope is used to measure the three-dimensional angular velocity of the drone. In order to convert these discrete measurement data into pitch, roll, and yaw angles, the system uses data fusion algorithms such as Kalman filtering or complementary filtering algorithms. These algorithms combine the data from the accelerometer and gyroscope to compensate for sensor noise and drift, thereby generating stable and accurate attitude data.
[0030] Secondly, the ambient air pressure value is obtained through the barometer, and the measurement result of the barometer is compensated and corrected in combination with the real-time temperature sensor data. Since changes in ambient temperature may cause deviations in air pressure measurement, the air pressure data can be corrected according to temperature changes by using the temperature sensor inside the drone. In addition, in order to convert the air pressure data into air pressure altitude, the system uses the standard atmospheric pressure formula or an experience-based correction curve for calculation. At the same time, the flight controller will also make real-time adjustments to the air pressure altitude data based on the initial calibration value of the drone to ensure that the air pressure altitude data has good adaptability and accuracy in different flight environments. This adjustment is particularly important for dealing with severe airflow disturbances or rapid changes in altitude.
[0031] Next, the current speed data of the motor is collected through the Hall sensor or optical encoder installed on the motor. The Hall sensor generates a pulse signal by detecting the change of the magnetic field in the motor rotor, while the optical encoder obtains the speed data by reading the optical coding pattern on the rotor. To improve the continuity and accuracy of the speed data, the system filters the collected signals, such as using a low-pass filter to eliminate high-frequency noise. In addition, in order to ensure the time consistency of the signal under high dynamic conditions, the system uses interpolation processing to make up for the data gaps caused by sampling rate limitations or signal loss.
[0032] Finally, the collected attitude data, pressure altitude data, and motor speed data are synchronized and integrated through the timestamp alignment method. By adding an accurate time stamp to each data point, the data from different sensors can be compared and combined with the same time reference, thereby generating a joint state vector containing attitude, altitude, and speed information. This joint state vector, as a multi-dimensional feature description, provides complete and accurate input for subsequent flight control algorithms and deep learning models.
[0033] By combining multiple sensors and data processing methods, high standards in real-time, accuracy and consistency of the acquired data are ensured.
[0034] Step S102: Based on the attitude data, the pitch acceleration, roll acceleration and yaw acceleration of the drone are calculated, and it is determined whether the drone is currently in an airflow disturbance state according to a preset threshold.
[0035] In step S102, based on the attitude data obtained from step S101, specifically including the pitch angle, roll angle and yaw angle, the pitch acceleration, roll acceleration and yaw acceleration of the drone are calculated. To achieve this goal, it is necessary to first record and process the collected attitude data continuously over time. Specifically, the pitch angle, roll angle and yaw angle are the angle descriptions of the drone in the three-axis coordinate system, and these data will change over time.
[0036] In order to calculate the acceleration of these angles, it is first necessary to perform differential processing on the attitude angle data in the time dimension. This can be achieved in the following way: first, the attitude angle value is sampled at each time point, and then the angular velocity is calculated using the angle change in the discrete time interval. For example, the pitch angular velocity can be expressed as the difference between the pitch angle at the current time point and the previous time point divided by the time interval. Similarly, the roll angular velocity and yaw angular velocity can be calculated.
[0037] Next, the angular acceleration is calculated through a similar differential operation. For example, the pitch angular acceleration can be expressed as the change in pitch angular velocity at two consecutive time points divided by the time interval. The same method applies to the roll angular acceleration and the yaw angular acceleration. This calculation process needs to be based on high-precision timestamp records to ensure the accuracy of the calculation results.
[0038] After the calculation is completed, it is necessary to compare these angular acceleration data with the preset threshold to determine whether the current drone is in an airflow disturbance state. The preset threshold can be set based on experiments and flight data experience, and is usually a limit that reflects the range of acceleration changes under normal flight conditions. When a certain acceleration exceeds its corresponding threshold, it can be considered that the drone may be subject to airflow disturbance.
[0039] The judgment process can be realized through logical operations, such as comparing the pitch acceleration, roll acceleration and yaw acceleration with their thresholds respectively. If any value exceeds the threshold range, it triggers the sign of airflow disturbance state. Furthermore, by comprehensively analyzing the change trend of acceleration in the three directions, it can be judged whether the disturbance has obvious directionality or specific pattern.
[0040] The entire process needs to be completed by the UAV's flight control system, which includes an attitude data collection module, a processing module, and a disturbance state judgment module.
[0041] Furthermore, the calculating of the pitch acceleration, the roll acceleration and the yaw acceleration of the drone based on the attitude data includes: The pitch angle, roll angle and yaw angle data are collected in real time through the inertial measurement unit to form time series data respectively, where the attitude angle data at each time point is sampled by the sensor and stored in the cache of the flight control system in chronological order; Based on the smoothed attitude angle time series data, the pitch angular velocity, roll angular velocity and yaw angular velocity are calculated by a first difference method, where the angular velocity of each time step is obtained by dividing the attitude angle change value between the current time step and the previous time step by the sampling time interval; The calculated angular velocity sequence is used to calculate the pitch angular acceleration, roll angular acceleration and yaw angular acceleration through the quadratic difference method, where the angular acceleration of each time step is obtained by dividing the angular velocity change between the current time step and the previous time step by the sampling time interval.
[0042] In this embodiment, the inertial measurement unit is used to collect and process attitude data to calculate the pitch acceleration, roll acceleration and yaw acceleration. The process includes multiple steps of data collection, differential calculation and acceleration extraction to ensure the accuracy and real-time performance of the results.
[0043] First, the drone's inertial measurement unit collects data on pitch, roll, and yaw in real time. These data are generated by the accelerometer and gyroscope, representing the drone's instant attitude angle in three-dimensional space. The collected attitude angle data is stored in the flight control system's cache in the form of a time series. To ensure the temporal continuity and sequential consistency of the data, each data point is marked with a precise timestamp. These timestamps allow subsequent calculations to correctly identify the time intervals between the data. The storage of attitude angle data not only facilitates real-time processing, but also provides a basis for future dynamic analysis and flight status assessment.
[0044] Next, based on the time series data in the cache, the angular velocity of the drone is calculated by a first-order difference method. The first-order difference method is completed by calculating the attitude angle change value of adjacent time steps and dividing it by the sampling time interval. Specifically, for each time step, the angular velocity is the attitude angle of the current time step minus the attitude angle of the previous time step, and then divided by the time interval between the two samples. This method can capture the dynamic trend of attitude angle changes and generate time series of pitch angular velocity, roll angular velocity, and yaw angular velocity. These angular velocity sequences are an important basis for further calculation of acceleration. In order to reduce the error caused by sensor noise, the attitude angle data is usually smoothed before the difference, such as using a sliding average filter or a low-pass filter, so as to improve the stability of the angular velocity calculation.
[0045] After obtaining the angular velocity time series, the pitch acceleration, roll acceleration, and yaw acceleration are calculated using the quadratic difference method. The second-order difference method is implemented by calculating the angular velocity change value of adjacent time steps and dividing it by the sampling time interval. Specifically, the angular acceleration of each time step is the angular velocity of the current time step minus the angular velocity of the previous time step, and then divided by the time interval between the two samples. Such a calculation can accurately capture the rate of change of the attitude angular velocity, thereby providing the dynamic characteristics of the acceleration. In order to improve the robustness of the calculation, the angular velocity sequence can also be smoothed before the differential processing to reduce the influence of high-frequency noise caused by measurement errors or environmental interference.
[0046] Through the above process, the pitch acceleration, roll acceleration and yaw acceleration are finally generated. These acceleration data can accurately reflect the dynamic change characteristics of the current attitude of the UAV and provide key inputs for subsequent flight control and disturbance state judgment.
[0047] Furthermore, judging whether the current drone is in an airflow disturbance state according to a preset threshold value includes: Get the pitch angle acceleration 、Roll angular acceleration , yaw angular acceleration and the rate of change of pressure altitude ; For the pitch angular acceleration 、Roll angular acceleration , yaw angular acceleration Perform normalization to obtain the normalized pitch angle acceleration , normalized roll angular acceleration And the normalized yaw acceleration ; The purpose of normalization is to eliminate dimensional differences and balance the weights of different features in the calculation of the disturbance state. The normalization process uses the following formula: ; in, , , are the historical mean values of pitch, roll and yaw acceleration, , , They are the standard deviations of pitch, roll and yaw accelerations. These statistical parameters can be calculated from the data collected by the drone under stable flight conditions. According to the following formula 1, the disturbance state index is calculated : ; in, , , and is the weighting coefficient; The weight used to control the pitch acceleration. The reference value is 0.3. Used to control the weight of the roll angular acceleration. The reference value is 0.3. The weight used to control the yaw acceleration. The reference value is 0.2. The weight used to control the rate of change of pressure altitude. The reference value is 0.2.
[0048] The calculated disturbance state index With preset threshold Compare, if satisfied , then the drone is judged to be in a state of airflow disturbance. Threshold It is an empirical value set based on experiments and historical data, and usually reflects the boundary between the stable flight state and the disturbance state.
[0049] Step S103: When it is determined that the vehicle is in an airflow disturbance state, the target speed compensation value of the motor is calculated based on a pre-trained deep learning model, and the input parameters of the deep learning model include: pitch angular acceleration, roll angular acceleration, yaw angular acceleration, pressure altitude change rate and current motor speed.
[0050] In step S103, when the drone is in an airflow disturbance state, the pre-trained deep learning model is used to calculate the target speed compensation value of the motor. To achieve this process, it is first necessary to clarify the design and training steps of the deep learning model, then input the relevant data obtained in real time into the model, and finally output the target speed compensation value.
[0051] The deep learning model is trained with a large amount of flight data. Its core is a neural network structure that maps the relationship between input features and motor target speed compensation values. Input features include pitch acceleration, roll acceleration, yaw acceleration, pressure altitude change rate, and motor current speed. These data comprehensively reflect the current attitude of the drone and the state of environmental disturbance, and therefore provide sufficient information for compensation calculations.
[0052] In the process of model training, a large amount of flight test data needs to be collected first, especially sensor data and motor speed change data under various disturbance conditions. These data are labeled as training samples of the model, where the input is the above features and the output is the target speed compensation value of the motor. Training uses reinforcement learning algorithms, such as deep deterministic policy gradient (DDPG) or proximal policy optimization (PPO), with the goal of minimizing the attitude deviation or flight energy consumption of the drone. By iteratively optimizing the weight parameters of the neural network, a model that can dynamically respond to complex disturbances is finally obtained.
[0053] During operation, the real-time data obtained from step S101 and step S102 are input into the trained deep learning model. These data are first normalized to ensure that the input range is consistent with the model training to improve the accuracy and robustness of the calculation. The model will calculate the current target speed compensation value based on the input data, which represents the motor speed adjustment required to maintain the stability of the drone under airflow disturbance.
[0054] The calculation of the target speed compensation value is a process with high real-time requirements, so the inference efficiency of the model must be optimized, which can be achieved through lightweight neural networks or hardware accelerators (such as embedded GPUs or TPUs). In addition, to ensure the reliability of the model, an anomaly detection mechanism can be set to trigger a backup control strategy when the input data is abnormal or the model output is abnormal.
[0055] Through the above steps, the deep learning model maps the complex flight state of the drone into an accurate target speed compensation value.
[0056] Furthermore, the deep learning model includes an input layer, a first hidden layer, a second hidden layer, a third hidden layer and an output layer; The input layer is used to receive the pitch acceleration, roll acceleration, yaw acceleration, pressure altitude change rate and current motor speed data, and normalize the received data, specifically including unifying the dimensions and scaling the amplitudes of different input data to generate standardized feature data; The first hidden layer is used to receive the standardized feature data provided by the input layer, and to process the received standardized feature data of the pitch acceleration, the roll acceleration and the yaw acceleration through two parallel sub-networks; wherein the first sub-network is implemented by a convolutional neural network structure, and is used to extract features from the received standardized feature data of the pitch acceleration, the roll acceleration and the yaw acceleration, and generate local features describing the disturbance characteristics; the second sub-network is implemented by a recursive neural network structure, and is used to process the time series in the received standardized feature data of the pitch acceleration, the roll acceleration and the yaw acceleration, and capture the dynamic change characteristics, and generate time series features; The second hidden layer is used to receive the local features and time series features output by the first hidden layer, and fuse them with the standardized features of the pressure altitude change rate and the current motor speed to generate a fused feature vector; the second hidden layer is implemented by a fully connected network, and the weights of different features are dynamically allocated in combination with the attention mechanism; The third hidden layer is used to receive the fused feature vector and process the fused feature vector through a deep fully connected network, specifically including performing a high-dimensional nonlinear transformation on the fused feature vector to generate a preliminary prediction of the target speed compensation value; during the fusion process, the third hidden layer reduces the overfitting risk of the model through regularization technology and uses activation functions to improve the model's ability to express complex nonlinear relationships; The output layer receives the preliminary prediction from the third hidden layer, and performs correction in combination with the historical flight data to generate a target rotation speed compensation value.
[0057] In this embodiment, the flight data of the UAV is processed and analyzed through the multi-layer structure of the deep learning model to calculate the target speed compensation value of the motor. The model consists of an input layer, a first hidden layer, a second hidden layer, a third hidden layer and an output layer. The layers are interrelated and feature information is optimized layer by layer to ensure the accuracy and real-time performance of the final output result.
[0058] The input layer first receives a variety of real-time data from the drone, including pitch acceleration, roll acceleration, yaw acceleration, pressure altitude change rate, and current motor speed. These data have different dimensions and characteristics, so the input layer needs to normalize them. Specifically, the unit differences between different data are eliminated by dimensional unification, and the amplitude scaling method is used to adjust the data to a unified numerical range to generate standardized feature data. The normalized data has high stability and consistency, laying the foundation for the processing of subsequent layers.
[0059] The first hidden layer receives the standardized feature data generated by the input layer, and performs local pattern extraction and time series analysis on these features through two parallel sub-networks. The first sub-network adopts the convolutional neural network (CNN) structure, focusing on the standardized feature data of pitch acceleration, roll acceleration and yaw acceleration. The convolutional network extracts local features of the input data through the convolution kernel, captures the spatial pattern of the disturbance characteristics, and generates local feature vectors to describe the instantaneous state characteristics of the flight attitude. The second sub-network adopts the recurrent neural network (RNN) structure, focusing on processing the time series of these features. The recurrent network gradually processes the data within the time step through its cyclic structure, captures the dynamic change law of the pitch angle, roll angle and yaw acceleration, and generates a time series feature vector to reflect the change trend of the flight attitude.
[0060] The second hidden layer receives the local features and time series features output by the first hidden layer, and combines the standardized features of the pressure altitude change rate and the current motor speed to generate a high-dimensional fusion feature vector through feature fusion. Feature fusion uses a fully connected network structure to map various features to a unified high-dimensional feature space through linear and nonlinear transformations. In addition, the second hidden layer introduces an attention mechanism to dynamically adjust the weights according to the importance of the features to the target task. For example, time series features may be prioritized in a disturbed state, while local features are more focused during stable flight. The attention mechanism improves the adaptability of the model to complex flight environments by dynamically allocating weights.
[0061] The third hidden layer receives the fused feature vector and further processes it through a deep fully connected network. In this process, the third hidden layer performs a high-dimensional nonlinear transformation on the fused feature vector, capturing higher-order feature correlations by increasing the depth and complexity of the model. In addition, the third hidden layer uses regularization techniques, such as the Dropout method, to effectively reduce the risk of overfitting of the model, thereby improving the generalization ability for unknown flight scenarios. At the same time, the introduction of activation functions (such as ReLU or Swish) enhances the model's ability to express nonlinear relationships, ensuring that the output results can accurately reflect the current flight status.
[0062] The output layer receives the preliminary prediction results from the third hidden layer and corrects them with historical flight data to generate the final target speed compensation value. During the correction process, the output layer compares the current prediction value with the pattern in the historical flight data and dynamically adjusts the prediction results according to the specific flight mission and environmental conditions. This correction mechanism enables the model to adapt to changes in real time in complex flight environments and improve the accuracy and robustness of the output results.
[0063] The overall model optimizes the feature information layer by layer through standardization of the input layer, feature extraction of the first hidden layer, feature fusion and weight allocation of the second hidden layer, nonlinear transformation and regularization of the third hidden layer, and correction and output of the output layer, and finally generates a high-precision target speed compensation value.
[0064] Furthermore, the second hidden layer generates a fused feature vector through feature fusion and attention allocation mechanism according to the following formula 2: ; in, It is the fused feature vector, representing the comprehensive features formed by weighted fusion of multiple types of input features, and is used to describe the current state of the drone.
[0065] Indicates Class features, including local features, time series features, pressure altitude change rate features and motor speed features; is the number of features that need to be fused, for example is 4, and the features that need to be fused include local features, time series features, air pressure altitude change rate features, and motor speed features.
[0066] For the The dynamic weight of the class feature is calculated according to the following formula 3: ; in, For the The weight parameter matrix related to class features is obtained through offline training and dynamically adjusted according to the flight mode and disturbance state.
[0067] It is a static adjustment coefficient that is independent of the flight mode and is used to balance the basic contribution of the feature. The reference value can be set to 0.8.
[0068] This is a dynamic adjustment factor related to the flight mode, used to enhance the influence of specific features according to the current flight state. The reference value is usually 0.2, but it can be adjusted to 0.5 in a high-disturbance environment.
[0069] is the number of features that need to be fused, which is the same as in formula 2 above. ; is the flight mode value, calculated according to the following formula 4: ; in, The pressure altitude change rate indicates the current vertical motion state of the drone in meters per second. The value is calculated from the pressure altitude data collected in real time, for example, the difference between the current pressure altitude and the pressure altitude at the previous moment divided by the time interval.
[0070] The current motor speed in revolutions per second, which comes from the motor's Hall sensor or optical encoder.
[0071] The maximum value of the motor speed in the historical data is used to measure the difference between the current motor speed and the historical maximum value. This value is calculated from the flight log records of the drone and is usually set when the model is initialized.
[0072] Furthermore, the third hidden layer optimizes the complex relationship between the fused features through high-dimensional nonlinear transformation, and specifically uses the following formula 5 to process the fused feature vector: ; in, represents the feature vector after high-dimensional nonlinear transformation, which is used to generate a preliminary target speed compensation value; Represents the total number of fused features passed from the second hidden layer to the third hidden layer; Representation and Fusion The associated nonlinear enhancement weight is used to adjust the contribution of each feature to the final output. This parameter is dynamically optimized through offline training, with a typical initial value of 0.5 to 1.5, and is adjusted according to the needs of the flight mission. For example, when the disturbance is severe, the weight of the time series feature may be higher.
[0073] is the output of the second hidden layer. Fusion features; It is a coefficient related to the flight mission and environment, reflecting the specific requirements of the flight mission and environment, usually between 0.1 and 0.3. For example, in a complex flight environment, Can be increased to enhance the contribution of key features.
[0074] For the Fusion features and Fusion features The interaction weight coefficient reflects the relative importance of features. This parameter is determined through model training, and the initial value range is generally 0.1 to 0.5, which can be dynamically adjusted according to the specific flight mode.
[0075] As the activation function, the following formula 6 is used: ; in, The gain factor adjusted according to the current disturbance intensity determines the gradient change range of the activation function. This parameter is related to the current disturbance intensity. In a low disturbance environment, The value of is typically set to 1.0, but can be increased to 2.0 in high-perturbation environments to increase the model's sensitivity to the input data.
[0076] Furthermore, the size and number of convolution kernels of the first subnetwork in the first hidden layer are determined according to the flight characteristics of the UAV; at the same time, the coverage capability of the feature space is improved by increasing the number of convolution kernels, thereby enhancing the recognition of complex disturbance patterns.
[0077] In this embodiment, the first subnetwork of the first hidden layer processes the input standardized feature data through a convolutional neural network (CNN) structure to extract local disturbance patterns related to the flight characteristics of the UAV. In the implementation process, the design of the convolution kernel, including its size and number, directly determines the effect and computational efficiency of feature extraction. To ensure that the model can adapt to the dynamic characteristics of the UAV in a complex flight environment, the size and number of the convolution kernels are carefully set according to the specific flight characteristics of the UAV. At the same time, the model's coverage of the feature space is improved by appropriately increasing the number of convolution kernels, and the recognition ability of complex disturbance patterns is enhanced.
[0078] The size of the convolution kernel defines the range of its receptive field on the input feature map, that is, the local feature area that the convolution kernel can capture in each convolution operation. In order to adapt to the rapid dynamic changes of the drone, the size of the convolution kernel needs to be selected within a certain range to ensure that it can capture subtle disturbance features while maintaining the ability to perceive the overall flight state. For example, for the input pitch acceleration, roll acceleration, and yaw acceleration feature data, the size of the convolution kernel is usually selected as or to capture the disturbance patterns between different dimensions in space. Convolution kernels of these sizes can effectively balance the accuracy of local feature extraction and computational complexity to ensure real-time processing capabilities.
[0079] The number of convolution kernels directly determines the types and richness of features extracted by the model. Increasing the number of convolution kernels can improve the coverage of the feature space and thus capture more perturbation patterns. For example, the number of convolution kernels in the initial layer can be set to 32 or 64 to extract low-level perturbation features; in subsequent convolution layers, the number of convolution kernels can be gradually increased to 128 or higher to capture higher-level patterns. This hierarchical design enables the model to gradually build feature representations from simple to complex while retaining comprehensive coverage of key perturbation information.
[0080] To further improve the robustness of the convolution operation, the weights of the convolution kernels are optimized through offline training. During the training process, the model automatically adjusts the parameters of the convolution kernels according to the perturbation characteristics of the input data, so that each convolution kernel focuses on capturing a specific perturbation pattern. For example, in drone flight, specific convolution kernels may be optimized to be more sensitive to rapidly changing pitch accelerations, while other convolution kernels may focus on slowly changing roll accelerations.
[0081] In addition, to prevent overfitting, regularization techniques such as the Dropout method or weight penalty term are introduced after the convolution operation to ensure the generalization ability of the model in practical applications. By designing the size and number of convolution kernels and combining regularization techniques, the first subnetwork can fully extract local perturbation patterns in the input features and provide high-quality feature input for subsequent hidden layers.
[0082] The following is the reference implementation code of the deep learning model: import torch import torch.nn as nn import torch.nn.functional as F import math # Define a deep learning model class DroneMotorControlModel(nn.Module): def __init__(self, input_dim, hidden_dim, output_dim, num_features): """ Initialize the model structure, including the input layer, the first hidden layer, the second hidden layer, the third hidden layer and the output layer :param input_dim: input feature dimension :param hidden_dim: hidden layer dimension :param output_dim: output feature dimension :param num_features: number of features to be fused n """ super(DroneMotorControlModel, self).__init__() # Input layer: receives and normalizes input data self.input_layer = nn.BatchNorm1d(input_dim) # The first hidden layer: contains two parallel sub-networks # First subnetwork (convolutional network) self.conv1 = nn.Conv2d(in_channels=1, out_channels=32,kernel_size=(3, 3), padding=1) self.conv2 = nn.Conv2d(in_channels=32, out_channels=64,kernel_size=(3, 3), padding=1) self.pool = nn.MaxPool2d(kernel_size=(2, 2)) # Second subnetwork (recursive network) self.rnn = nn.LSTM(input_dim, hidden_dim, batch_first=True) # Second hidden layer: fuse feature vectors and apply attention mechanism self.fc_fusion = nn.Linear(hidden_dim + hidden_dim + 2,hidden_dim) self.attention_weights = nn.Parameter(torch.randn(num_features, 1)) # Dynamic weights # The third hidden layer: high-dimensional nonlinear transformation self.fc_non_linear = nn.Linear(hidden_dim, hidden_dim) self.gamma_weights = nn.Parameter(torch.randn(hidden_dim)) #nonlinear enhancement weights self.delta_weights = nn.Parameter(torch.randn(hidden_dim,hidden_dim)) # Feature interaction weights # Output layer: Correct target speed compensation value self.output_layer = nn.Linear(hidden_dim, output_dim) def forward(self, x, delta_h, omega_current, omega_max): """ Forward propagation process :param x: input data, including pitch acceleration, roll acceleration, yaw acceleration, etc. :param delta_h: pressure altitude change rate :param omega_current: current motor speed :param omega_max: historical maximum motor speed :return: The final output target speed compensation value """ # Input layer normalization x_normalized = self.input_layer(x) # First hidden layer: Convolutional network extracts local features x_conv = F.relu(self.conv1(x_normalized.unsqueeze(1))) x_conv = self.pool(F.relu(self.conv2(x_conv))).view(x.size(0), -1) # Flatten # First hidden layer: recursive network extracts time series features x_rnn, _ = self.rnn(x_normalized.unsqueeze(1)) x_rnn = x_rnn[:, -1, :] # Get the output of the last time step # The second hidden layer: Fusion of local features and temporal features m_i = delta_h / (1 + abs(delta_h)) + (omega_max - omega_current) / (1 + abs(omega_max - omega_current)) # Formula 4 x_fusion = torch.cat([x_conv, x_rnn, m_i.unsqueeze(1)], dim=1) attention_scores = F.softmax(torch.matmul(x_fusion,self.attention_weights), dim=0) # dynamic weights x_fused = torch.sum(attention_scores * x_fusion, dim=0) # fused feature vector # The third hidden layer: high-dimensional nonlinear transformation non_linear = self.fc_non_linear(x_fused) gamma_term = torch.sum(self.gamma_weights * (non_linear + 0.1* torch.pow(non_linear, 2))) delta_term = torch.sum(torch.matmul(non_linear, self.delta_weights) * non_linear) x_transformed = F.sigmoid(gamma_term + delta_term) # Formula 5 and Formula 6 # Output layer: Generate target speed compensation value output = self.output_layer(x_transformed.unsqueeze(0)) The key to training this deep learning model includes data preparation, model training, loss optimization, and model evaluation. The following are the main steps.
[0083] First, prepare a training data set, including data on pitch acceleration, roll acceleration, yaw acceleration, pressure altitude change rate, and current motor speed. These data are collected by sensors and paired with target speed compensation values as labels for supervised learning. Feature data needs to be normalized, dimensioned, and amplitude scaled, and time series features need to construct sliding windows to capture dynamic changes.
[0084] When initializing the model, use a reasonable weight randomization method, such as Xavier initialization, and determine hyperparameters, such as the number of neurons in each layer, learning rate, and initial value of attention mechanism weights.
[0085] During the training process, the mean square error (MSE) is selected as the loss function, and the Adam optimizer is used to dynamically adjust the learning rate. Each training is forward propagated and back propagated through the mini-batch data. The forward propagation calculates the loss and the back propagation optimizes the model weights. During training, the validation set is used to monitor the model performance in real time to ensure that the loss converges and there is no sign of overfitting. Regularization techniques such as Dropout layer and L2 regularization reduce the risk of overfitting.
[0086] After training is completed, the model performance is evaluated on the test set to verify the accuracy and stability of the model in predicting the target speed compensation value. Finally, the optimal weights are saved for subsequent deployment.
[0087] Through the above steps, the model training can be completed and its effectiveness and applicability in UAV motor control can be ensured.
[0088] Step S104: According to the target speed compensation value, in combination with a preset fuzzy control rule, a correction value of the PWM drive signal of the motor is calculated.
[0089] In step S104, a correction value of the PWM drive signal of the motor is calculated based on the target speed compensation value calculated from the deep learning model and in combination with a preset fuzzy control rule.
[0090] First, the core of fuzzy control rules lies in fuzzy logic rules defined based on empirical knowledge and expert systems, which are used to deal with the nonlinear relationship between the target speed compensation value and the current system state. These rules usually take the form of "if-then", for example, "if the pitch angle acceleration is large and the current speed is low, then the duty cycle of the PWM drive signal needs to be increased". The specific design of the rules depends on the observation and summary of the UAV dynamic characteristics in the experiment.
[0091] When applying fuzzy control rules, the input variables need to be fuzzified first. The target speed compensation value is divided into several fuzzy sets, such as "small", "medium", and "large", and each set is quantified by a membership function. The fuzzified input includes the target speed compensation value calculated by the deep learning model and possible other auxiliary variables (such as the rate of change of the current motor speed). The membership function can be in the form of a triangle, trapezoid, or Gaussian function, and its specific shape and range are calibrated by experimental data.
[0092] Next, the fuzzified input variables are substituted into the fuzzy rule base for reasoning. The reasoning process is based on fuzzy logic operations, such as minimum-maximum reasoning or weighted average reasoning, to integrate the results of multiple rules. After the reasoning is completed, the fuzzified output result is obtained, that is, the fuzzy description of the PWM drive signal correction value.
[0093] Finally, the fuzzified correction value needs to be converted into an actual numerical signal through a defuzzification method. Defuzzification usually uses the centroid method, that is, the final output of the correction value is determined by calculating the centroid position of the fuzzy membership function. This correction value represents the amount of adjustment that needs to be made to the duty cycle of the motor PWM drive signal under the current state.
[0094] The correction value obtained by defuzzification is superimposed on the basic PWM signal to generate the final corrected PWM drive signal. This signal can not only accurately compensate the motor speed according to the disturbance, but also respond to different flight state requirements by dynamically adjusting the duty cycle. In actual implementation, this process is usually run on an embedded flight control processor through a real-time algorithm to ensure efficiency and accuracy.
[0095] Furthermore, the calculation of the correction value of the PWM drive signal of the motor based on the target speed compensation value and the preset fuzzy control rule includes: The speed error and error change rate are calculated through the target speed compensation value output by the deep learning model and the current motor speed feedback value, where the speed error is the difference between the target speed compensation value and the current feedback value, and the error change rate is the change in the speed error between consecutive time steps; The speed error and the error change rate are used as input parameters of the fuzzy control rule, and the input parameters are fuzzified based on a preset fuzzy membership function, wherein the fuzzy membership function is pre-designed according to the experimental data of the motor response and the actual requirements of the flight mission, and is divided into a plurality of fuzzy sets; Perform fuzzy reasoning on the fuzzified input according to the fuzzy control rule base; during the reasoning process, use the maximum-minimum synthesis method or weighted average method to comprehensively process the results of multiple rules to ensure the accuracy and stability of the control logic; The fuzzy inference result is defuzzified to generate an accurate PWM correction value, wherein the defuzzification method adopts the centroid method to determine the numerical output of the PWM correction value by calculating the centroid position of the fuzzy set; the PWM correction value represents the duty cycle adjustment amount of the motor PWM drive signal required under the current state.
[0096] In this embodiment, by combining the target speed compensation value and the motor speed feedback value, the preset fuzzy control rules are used to dynamically calculate the correction value of the motor PWM drive signal, thereby achieving precise control of the motor speed and adapting to the disturbance requirements in a complex flight environment. The specific implementation process is carried out through the following steps to ensure the accuracy and real-time performance of the entire control logic.
[0097] First, the speed error and error change rate are calculated using the target speed compensation value output by the deep learning model and the current speed feedback value collected by the motor sensor. The speed error is the difference between the target speed compensation value and the actual feedback speed value, and is used to quantify the degree of deviation between the current speed and the ideal target. The error change rate indicates the rate of change of the speed error between consecutive time steps, reflecting the dynamic trend of the motor response. These two parameters provide basic input for subsequent fuzzy control and can fully characterize the static deviation and dynamic changes of the motor speed.
[0098] Next, the speed error and error change rate are input into the fuzzy processing module of the fuzzy control rule. Fuzzy processing converts precise input parameters into fuzzy sets through preset fuzzy membership functions. Fuzzy membership functions are pre-designed according to the actual response data of the motor and the flight mission requirements, and are usually divided into multiple fuzzy sets, such as "small", "medium" and "large". The specific division of these sets is determined by experimental data and system debugging. For example, the fuzzy set of speed error can be realized by segmented mapping of the error value range. When the range is [-10,10], the membership range of "small" is [-3,3], "medium" is [-7,7], and those beyond this range are classified as "large". Through fuzzy processing, the control system can enhance its adaptability to uncertainty and complex dynamic conditions.
[0099] After fuzzification, fuzzy reasoning is performed on the fuzzified input parameters according to the fuzzy control rule base. Fuzzy rules are predefined in the form of "if-then", for example, "if the speed error is large and the error change rate is small, then the PWM correction value should be increased". In the fuzzy reasoning process, the reasoning results of multiple rules are comprehensively processed through the maximum-minimum synthesis method or the weighted average method to ensure the accuracy and stability of the logic. For example, if multiple rules are triggered at the same time, the system performs weighted superposition on the output of the rules according to the membership of the input parameters to generate a comprehensive reasoning result.
[0100] The result of fuzzy reasoning is a fuzzy set, which needs to be converted into an accurate PWM correction value through defuzzification. Defuzzification uses the centroid method to determine the specific numerical output of the PWM correction value by calculating the centroid position of the fuzzy set. For example, if the fuzzy set contains multiple membership peaks, the centroid method generates a unique output value by weighted averaging the distribution of the membership function. The PWM correction value directly represents the duty cycle adjustment of the motor PWM drive signal in the current state, which is a real-time compensation for the target speed deviation.
[0101] Finally, the generated PWM correction value is superimposed on the existing PWM signal to form a corrected PWM drive signal. This signal acts on the motor in real time, making its speed gradually approach the target value, thereby achieving stable flight control.
[0102] Step S105: Apply the corrected PWM drive signal to the motor, collect motor speed feedback information in real time, and dynamically adjust the weight parameters of the deep learning model according to the feedback information.
[0103] In step S105, the corrected PWM drive signal calculated in step S104 is directly applied to the motor to drive the motor to run at the desired speed. This process requires the flight control system of the drone to convert the corrected signal into a drive pulse suitable for the motor, while ensuring accurate signal transmission and real-time execution.
[0104] The application of PWM drive signal is completed through the motor control circuit, and the corresponding PWM waveform is usually generated by an embedded microcontroller. The corrected PWM signal is transmitted to the motor driver chip through the hardware interface, and the driver chip converts it into the actual motor input current to adjust the motor speed. It should be noted that in order to ensure the stability and accuracy of the drive signal, the application of the signal needs to be processed by anti-interference, such as adding a filter circuit to prevent signal distortion caused by electromagnetic noise or hardware instability.
[0105] At the same time, in the process of applying PWM signals to drive the motor, it is necessary to collect the motor speed feedback information in real time. Speed feedback is usually achieved through Hall sensors, photoelectric encoders or other speed detectors. The collected speed data is transmitted to the flight control system through the communication bus and compared with the current target speed. The collection frequency of feedback information needs to be high enough to ensure that the system can sense the motor response in time and make necessary adjustments.
[0106] Based on the feedback information obtained in real time, the system dynamically adjusts the weight parameters of the deep learning model. This process is achieved through the online update strategy in reinforcement learning. Specifically, the model calculates the instant reward value based on the error between the speed feedback and the expected speed, and uses the reward value to adjust the model parameters to gradually optimize the output performance of the model. Online adjustment uses the gradient update method or other optimization algorithms to ensure that the model can adapt to new dynamic conditions and improve the accuracy of control under the changing flight state.
[0107] The entire process requires a high degree of coordination between the flight control system hardware and algorithm software. On the one hand, the hardware needs to provide sufficient computing power and real-time performance to ensure the accuracy and speed of PWM signal generation, application, and feedback information collection; on the other hand, the algorithm needs to efficiently process real-time data streams and maintain dynamic optimization of system performance through online updates.
[0108] In this way, the corrected PWM drive signal can effectively control the motor operation, while achieving closed-loop control and model optimization through the feedback loop.
[0109] Furthermore, the modified PWM drive signal is applied to the motor, and the motor speed feedback information is collected in real time, and the weight parameters of the deep learning model are dynamically adjusted according to the feedback information, including: The calculated corrected PWM drive signal is applied to the motor through the motor control unit of the drone to adjust the actual speed of the motor; The speed sensor installed on the motor collects the current speed feedback information of the motor in real time; The error between the actual motor speed feedback value and the target speed compensation value is calculated, and the error is used as an immediate reward signal for the deep learning model. The weight parameters of the model are dynamically adjusted through the reinforcement learning algorithm.
[0110] This embodiment applies the corrected PWM drive signal to the drone motor and uses the motor speed feedback information collected in real time to dynamically adjust the weight parameters of the deep learning model to achieve efficient and accurate motor control.
[0111] The calculated corrected PWM drive signal is applied to the motor. First, the signal conversion and execution must be completed through the drone's motor control unit. The corrected PWM signal is transmitted to the control unit in the form of a duty cycle to adjust the input current of the motor, thereby changing the actual speed of the motor. The control unit converts the PWM signal into a drive current that adapts to the motor, and directly affects the output power of the motor by adjusting the strength and time ratio of the input current. This process ensures that the PWM signal responds quickly and accurately to the motor speed, and is the core link of the entire motor control system.
[0112] During the operation of the motor, the speed sensor installed on the motor collects the current speed feedback information in real time. The speed sensor can use a Hall sensor or an optical encoder to generate a continuous pulse signal according to the position and motion state of the motor rotor. The flight control system converts the collected pulse signal into the motor speed value, and eliminates environmental noise and signal jitter through a filtering algorithm (such as a low-pass filter) to obtain stable real-time speed data. These feedback data accurately reflect the current operating status of the motor and provide reliable input for subsequent calculations and model optimization.
[0113] Based on the collected speed feedback information, the error between the actual motor speed and the target speed compensation value is calculated. This error quantifies the degree of deviation between the current motor output and the target state, and is an important indicator for evaluating the performance of the control system. The error calculation formula is the target speed compensation value minus the current feedback value, and its positive or negative magnitude directly reflects the direction in which the motor needs to accelerate or decelerate. At the same time, the system dynamically monitors the error and evaluates the motor's responsiveness by recording the historical change trend of the error.
[0114] The calculated error is used as the immediate reward signal of the deep learning model, and the weight parameters of the model are dynamically adjusted through the reinforcement learning algorithm. In the reinforcement learning framework, the smaller the error, the higher the reward value of the model, and vice versa. The model optimizes its objective function through this mechanism, thereby gradually adjusting the weight parameters of the neural network to adapt to the current flight state. The specific process of weight update is implemented through the back propagation algorithm, the error signal is transmitted to the hidden layer of the model, and the connection weights are adjusted layer by layer according to the network structure. This dynamic optimization process enhances the model's adaptive ability, enabling it to maintain stable control performance in complex flight environments.
[0115] The entire method forms a closed-loop control system through the adjustment of PWM signals, real-time collection of speed feedback and dynamic optimization of deep learning models, which effectively improves the accuracy and response speed of UAV motor control.
[0116] A second embodiment of the present application provides an electronic device, the electronic device comprising: processor; The memory is used to store a program, and when the program is read and executed by the processor, the program executes a method for controlling a motor in a drone provided in the first embodiment of the present application.
[0117] The third embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the program is executed by a processor, a method for controlling a motor in a drone provided in the first embodiment of the present application is executed.
[0118] Although the present application is disclosed as above in the form of a preferred embodiment, it is not intended to limit the present application. Any technical personnel in this field may make possible changes and modifications without departing from the spirit and scope of the present application. Therefore, the scope of protection of the present application shall be based on the scope defined by the claims of the present application.
Claims
1. A method for controlling a motor in a drone, characterized in that: include: Acquire the attitude data, air pressure altitude data and current speed data of the motor during the flight of the drone, wherein the attitude data includes pitch angle, roll angle and yaw angle; Based on the attitude data, the pitch acceleration, roll acceleration and yaw acceleration of the drone are calculated, and according to a preset threshold, it is determined whether the current drone is in an airflow disturbance state; When it is determined that the vehicle is in an airflow disturbance state, a target speed compensation value of the motor is calculated based on a pre-trained deep learning model, wherein the input parameters of the deep learning model include: pitch angular acceleration, roll angular acceleration, yaw angular acceleration, pressure altitude change rate, and current motor speed; According to the target speed compensation value, combined with the preset fuzzy control rule, a correction value of the PWM drive signal of the motor is calculated; The corrected PWM drive signal is applied to the motor, and the motor speed feedback information is collected in real time, and the weight parameters of the deep learning model are dynamically adjusted according to the feedback information.
2. The method for controlling a motor in a drone according to claim 1, characterized in that: The acquisition of the attitude data, the air pressure altitude data and the current speed data of the motor during the flight of the drone includes: The inertial measurement unit equipped with the drone collects pitch angle, roll angle and yaw angle in real time. The inertial measurement unit measures linear acceleration and angular velocity through accelerometers and gyroscopes and generates stable attitude data using data fusion algorithms. The ambient air pressure is obtained through the barometer and compensated with the real-time temperature data to calculate the pressure altitude. At the same time, the pressure altitude data is adjusted in real time based on the initial calibration value of the flight controller to adapt to different flight environments; The current speed data of the motor is collected through the Hall sensor or optical encoder of the motor, and the collected speed signal is filtered and interpolated to enhance the continuity and accuracy of the data; The collected data are synchronously integrated through the timestamp alignment method to generate a joint state vector of attitude, altitude and rotation speed.
3. The method for controlling a motor in a drone according to claim 1, characterized in that: The step of calculating the pitch acceleration, roll acceleration and yaw acceleration of the drone based on the attitude data includes: The pitch angle, roll angle and yaw angle data are collected in real time through the inertial measurement unit to form time series data respectively, where the attitude angle data at each time point is sampled by the sensor and stored in the cache of the flight control system in chronological order; Based on the smoothed attitude angle time series data, the pitch angular velocity, roll angular velocity and yaw angular velocity are calculated by a first difference method, where the angular velocity of each time step is obtained by dividing the attitude angle change value between the current time step and the previous time step by the sampling time interval; The calculated angular velocity sequence is used to calculate the pitch angular acceleration, roll angular acceleration and yaw angular acceleration through the quadratic difference method, where the angular acceleration of each time step is obtained by dividing the angular velocity change between the current time step and the previous time step by the sampling time interval.
4. The method for controlling a motor in a drone according to claim 1, characterized in that: The step of judging whether the current drone is in an airflow disturbance state according to a preset threshold value includes: Get the pitch angle acceleration 、Roll angular acceleration , yaw angular acceleration and the rate of change of pressure altitude ; For the pitch angular acceleration 、Roll angular acceleration , yaw angular acceleration Perform normalization to obtain the normalized pitch angle acceleration , normalized roll angular acceleration And the normalized yaw acceleration ; According to the following formula 1, the disturbance state index is calculated : ; in, , , and is the weighting coefficient; The calculated disturbance state index With preset threshold Compare, if satisfied , then it is judged that the UAV is in a state of airflow disturbance.
5. The method for controlling a motor in a drone according to claim 1, characterized in that: The deep learning model includes an input layer, a first hidden layer, a second hidden layer, a third hidden layer and an output layer; The input layer is used to receive the pitch acceleration, roll acceleration, yaw acceleration, pressure altitude change rate and current motor speed data, and normalize the received data, specifically including unifying the dimensions and scaling the amplitudes of different input data to generate standardized feature data; The first hidden layer is used to receive the standardized feature data provided by the input layer, and to process the received standardized feature data of the pitch acceleration, the roll acceleration and the yaw acceleration through two parallel sub-networks; wherein the first sub-network is implemented by a convolutional neural network structure, and is used to extract features from the received standardized feature data of the pitch acceleration, the roll acceleration and the yaw acceleration, and generate local features describing the disturbance characteristics; the second sub-network is implemented by a recursive neural network structure, and is used to process the time series in the received standardized feature data of the pitch acceleration, the roll acceleration and the yaw acceleration, and capture the dynamic change characteristics, and generate time series features; The second hidden layer is used to receive the local features and time series features output by the first hidden layer, and fuse them with the standardized features of the pressure altitude change rate and the current motor speed to generate a fused feature vector; the second hidden layer is implemented by a fully connected network, and the weights of different features are dynamically allocated in combination with the attention mechanism; The third hidden layer is used to receive the fused feature vector and process the fused feature vector through a deep fully connected network, specifically including performing a high-dimensional nonlinear transformation on the fused feature vector to generate a preliminary prediction of the target speed compensation value; during the fusion process, the third hidden layer reduces the overfitting risk of the model through regularization technology and uses activation functions to improve the model's ability to express complex nonlinear relationships; The output layer receives the preliminary prediction from the third hidden layer, and performs correction in combination with the historical flight data to generate a target rotation speed compensation value.
6. The method for controlling a motor in a drone according to claim 5, characterized in that: The second hidden layer generates a fused feature vector through feature fusion and attention allocation mechanism according to the following formula 2: ; in, is the fused feature vector; Indicates Class features, including local features, time series features, pressure altitude change rate features and motor speed features; is the number of features that need to be fused; For the The dynamic weight of the class feature is calculated according to the following formula 3: ; in, For the The weight parameter matrix related to class features; It is a static adjustment coefficient that is independent of the flight mode; Dynamic adjustment coefficient related to flight mode; is the number of features that need to be fused; is the flight mode value, calculated according to the following formula 4: ; in, is the rate of change of pressure altitude; is the current motor speed; It is the maximum value of the motor speed in the historical data.
7. The method for controlling a motor in a drone according to claim 6, characterized in that: The third hidden layer optimizes the complex relationship between fused features through high-dimensional nonlinear transformation, and specifically uses the following formula 5 to process the fused feature vector: ; in, represents the feature vector after high-dimensional nonlinear transformation, which is used to generate a preliminary target speed compensation value; Represents the total number of fused features passed from the second hidden layer to the third hidden layer; Representation and Fusion The associated nonlinear enhancement weights; is the output of the second hidden layer. Fusion features; is a coefficient related to the flight mission and environment; For the Fusion features and Fusion features The interaction weight coefficient of As the activation function, the following formula 6 is used: ; in, is a gain factor adjusted according to the current disturbance strength.
8. The method for controlling a motor in a drone according to claim 5, characterized in that: The size and number of convolution kernels of the first subnetwork in the first hidden layer are determined according to the flight characteristics of the UAV; at the same time, the coverage capability of the feature space is improved by increasing the number of convolution kernels, thereby enhancing the recognition of complex disturbance patterns.
9. The method for controlling a motor in a drone according to claim 1, characterized in that: The method of calculating the correction value of the PWM drive signal of the motor according to the target speed compensation value and combining the preset fuzzy control rule includes: The speed error and error change rate are calculated through the target speed compensation value output by the deep learning model and the current motor speed feedback value, where the speed error is the difference between the target speed compensation value and the current feedback value, and the error change rate is the change in the speed error between consecutive time steps; The speed error and the error change rate are used as input parameters of the fuzzy control rule, and the input parameters are fuzzified based on a preset fuzzy membership function, wherein the fuzzy membership function is pre-designed according to the experimental data of the motor response and the actual requirements of the flight mission, and is divided into a plurality of fuzzy sets; Perform fuzzy reasoning on the fuzzified input according to the fuzzy control rule base; during the reasoning process, use the maximum-minimum synthesis method or weighted average method to comprehensively process the results of multiple rules to ensure the accuracy and stability of the control logic; The fuzzy inference result is defuzzified to generate an accurate PWM correction value, wherein the defuzzification method adopts the centroid method to determine the numerical output of the PWM correction value by calculating the centroid position of the fuzzy set; the PWM correction value represents the duty cycle adjustment amount of the motor PWM drive signal required under the current state.
10. The method for controlling a motor in a drone according to claim 1, characterized in that: The modified PWM drive signal is applied to the motor, and the motor speed feedback information is collected in real time, and the weight parameters of the deep learning model are dynamically adjusted according to the feedback information, including: The calculated corrected PWM drive signal is applied to the motor through the motor control unit of the drone to adjust the actual speed of the motor; The speed sensor installed on the motor collects the current speed feedback information of the motor in real time; The error between the actual motor speed feedback value and the target speed compensation value is calculated, and the error is used as an immediate reward signal for the deep learning model. The weight parameters of the model are dynamically adjusted through the reinforcement learning algorithm.
Citation Information
Patent Citations
Unmanned aerial vehicle attitude control system
CN111367308A
Anti-interference rotating speed control method suitable for manned electric helicopter motor
CN115208258A
Highly fused navigation method and device, electronic equipment and storage medium
CN115900646A
Unmanned aerial vehicle navigation attitude prediction and motion compensation method and system based on deep learning
CN118819180A
Cited By
Aircraft control response data fitting method and system based on neural network and computer program product
CN120509227A
Aircraft control response data fitting method, system and computer program product based on neural network
CN120509227B