A PID controller parameter setting method, system, device and storage medium
By introducing the elite reverse learning strategy and the Kalman filter PID controller into the Sparrow search algorithm, the PID parameters of the quad-rotor UAV are optimized, which solves the optimization accuracy and convergence speed problems in the PID controller parameter optimization, and significantly improves the Drone hovering stability and noise filtering effect.
Patent Information
- Application Number
- CN202210260209.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-16
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2042-03-16
AI Technical Summary
The Sparrow search algorithm has problems such as low optimization accuracy, slow convergence speed and easy to fall into local optimality in PID controller parameter optimization, which affects the hovering stability of the quad-rotor UAV.
The elite reverse learning strategy is used to improve the sparrow search algorithm, the Ki, Kd, and Kp parameters are optimized through the Kalman filter PID controller, and the fitness function values of the initial population and the reverse population are used for sorting to obtain the optimal PID parameters.
The robustness and response speed of the PID controller are improved, the global optimal parameters can be obtained, the dynamic performance and noise filtering effect of the hovering of the quad-rotor UAV are improved, and the stability of the system is enhanced.
Smart Images

Figure CN114637191B
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of automatic control technology, and in particular relates to a PID controller parameter setting method, system, device and storage medium. Background Art
[0002] After a long period of natural conditions and environmental tests, the building's exterior wall insulation layer has many problems, such as hollowing, falling off, cracks, and water seepage leading to mold in the exterior wall insulation system. However, high-altitude falling accidents of the building's exterior wall insulation system often occur, causing economic losses and casualties. It is very important to regularly detect defects in the building's exterior wall insulation layer. In today's society, the common method for detecting defects in the building's exterior wall insulation is manual detection, which usually uses manual sensors to detect the building's exterior wall insulation layer at close range. Although manual detection is flexible, it still has some disadvantages such as low detection efficiency and inability to detect for a long time. Too long detection will lead to inattention and missed detection. In addition, traditional manual detection methods have safety hazards and cannot meet the needs of exterior wall insulation layer detection. With the rapid development of mechanical engineering technology, intelligent technology and intelligent robot technology in the 21st century, the detection of building exterior insulation defects has gradually been replaced by intelligent robots. Among them, wall-climbing robots are used for detection. Wall-climbing robots have stable performance, reduce the safety hazards of manual detection, and can improve detection efficiency. However, wall-climbing robots have poor obstacle avoidance ability, slow movement speed and a relatively single working plane. With the rapid development of some sensor technologies, science and technology, and some intelligent algorithms in recent years, a wave of research on quadcopters has been set off at home and abroad, and quadcopters have gradually been used in the detection of defects in the external insulation layer of building exterior walls. Because quadcopters can carry infrared thermal imager sensors, have long battery life, small size, easy control, stable performance, strong environmental adaptability, and can point and hover for detection.
[0003] The hovering control of quad-rotor drones generally adopts the traditional PID control system. The traditional PID controller has the advantages of easy implementation, high reliability and strong anti-interference ability, and is widely used in fields such as automatic control. The quality of the PID controller depends on the parameters of the PID controller. The adjustment of PID parameters is inseparable from people's experience, and it is difficult to achieve the ideal value. The optimization of its parameters is particularly important. In addition, when the quad-rotor drone is hovering, it is affected by the noise generated by external interference and other reasons, resulting in problems such as the inability to hover stably for a long time. In recent years, swarm intelligence algorithms have developed rapidly and have been widely used in PID parameter optimization, achieving good results. Among them, the sparrow search algorithm proposed by Xue Jiankai et al. has the advantages of high solution accuracy, fast convergence speed and good stability in dealing with optimization problems. However, the sparrow search algorithm still has the disadvantages of low optimization accuracy, slow convergence speed, and easy to fall into local optimality. Summary of the invention
[0004] The purpose of the present invention is to provide a PID controller parameter tuning method, system, device and storage medium to solve the technical problems of the sparrow search algorithm in the prior art, such as low optimization accuracy, slow convergence speed, and easy to fall into local optimum.
[0005] A first aspect of the present invention provides a PID controller parameter tuning method, comprising the following steps:
[0006] Construct the initial population based on the sparrow search algorithm;
[0007] Constructing a reverse population based on an elite reverse learning strategy, obtaining the individuals in the initial population and the reverse population whose fitness is lower than a preset value as the final initial population;
[0008] Decoding the individuals in the initial population to obtain Kp, Ki, and Kd, and inputting them into the PID controller of the Kalman filter to obtain the fitness function value of each individual;
[0009] Sort the fitness function values of each individual, and take the position represented by the individual with the smallest fitness function value as the optimal position;
[0010] The three PID parameter values corresponding to the optimal position are taken as optimal PID parameters and output.
[0011] Optionally, the initial population is constructed based on the sparrow search algorithm in the following manner:
[0012] Initialize the population and set the input signal to be a sinusoidal input;
[0013] Set the fitness function, select the absolute value of the error between the input value and the output value multiplied by the weight integral over time;
[0014] Start optimization;
[0015] Initialize the parameters in the sparrow search algorithm, calculate the number of discoverers and the number of sparrows aware of danger;
[0016] Set the upper and lower boundaries to three-dimensional matrices.
[0017] Optionally, the initial population is obtained as follows:
[0018] Calculate the number of boundaries;
[0019] Construct a reverse population, multiply the number of populations by a zero-dimensional matrix to store the reverse population;
[0020] Determine whether the boundary number is equal to 1. If it is equal to 1, randomly generate all the initial population positions, and then find the reverse population, otherwise proceed to the next step;
[0021] Randomly generate the initial value of each dimension population and obtain the reverse population;
[0022] In order, take individuals from the initial population and the reverse population, and use the fitness function to calculate their fitness; select individuals with lower fitness and put them into the corresponding positions of the final initial population;
[0023] Get elite boundaries;
[0024] Updated elite reverse solution;
[0025] Get the initial population.
[0026] Optionally, the specific method of obtaining the fitness function value of each individual is as follows:
[0027] The sparrow individual decoded Kp, Ki, Kd are input into the Kalman filter PID controller, where the controlled object is the transfer function of the quadcopter when it is hovering;
[0028] Calculate the initial fitness value according to the fitness function.
[0029] Optionally, the sinusoidal input is sin(0.01*k).
[0030] Optionally, the fitness function formula is:
[0031]
[0032] Where: e(t) is the error between the input value and the output value; ω1 and ω2 are weights, both ranging from 0 to 1; u(t) is the control value; ω3 is the weight, and ω3>>ω1.
[0033] Optionally, the formula for obtaining the reverse population is: P = a + bp
[0034] Where: P is the reverse population, a and b are the upper and lower limits of the interval (a, b), and p is the original population.
[0035] A second aspect of the present invention provides a system for the above PID controller parameter tuning method, comprising:
[0036] An initial population construction module, used to construct the initial population based on the sparrow search algorithm;
[0037] Reverse population construction module, used to construct reverse population based on elite reverse learning strategy;
[0038] An initial population construction module is used to obtain individuals whose fitness is lower than a preset value in the initial population and the reverse population as the final initial population;
[0039] A fitness function value module is used to decode the individuals in the initial population to obtain Kp, Ki, and Kd, and input them into the PID controller of the Kalman filter to obtain the fitness function value of each individual;
[0040] A sorting module is used to sort the fitness function values of each individual, and take the position represented by the individual with the smallest fitness function value as the optimal position;
[0041] The output module is used to output the three PID parameter values corresponding to the optimal position as optimal PID parameters.
[0042] According to a third aspect of the present invention, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned PID controller parameter tuning method when executing the computer program.
[0043] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned PID controller parameter tuning method is implemented.
[0044] Compared with the prior art, the present invention has the following positive and beneficial effects:
[0045] The present invention uses the elite reverse learning strategy to improve the Ki, Kd, and Kp parameters of the PID controller of the SSA optimized Kalman filter, and applies the improved controller to the hovering of the quadcopter drone. It has the characteristics of strong robustness, fast system response speed, and good noise filtering effect, and can obtain the global optimal parameters. It has better dynamic and static performance and good noise filtering effect than the classic PID, KF-PID, and SSA-KF-PID, and has a great improvement and improvement. At the same time, it has a good effect in the hovering of the quadcopter drone. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The drawings constituting a part of the present application are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0047] Figure 1 The PID controller in the prior art adopts the PID principle diagram;
[0048] Figure 2 It is the principle diagram of KF-PID controller in the prior art;
[0049] Figure 3 It is the principle diagram of SSA-KF-PID controller in the prior art;
[0050] Figure 4 The improved SSA-KF-PID controller schematic diagram of the present invention;
[0051] Figure 5 It is a model diagram of a power unit system of a quad-rotor UAV in the prior art;
[0052] Figure 6 It is a fitting curve diagram of steady-state speed and throttle of the present invention;
[0053] Figure 7 A flow chart of a PID controller parameter tuning method provided by an embodiment of the present invention;
[0054] Figure 8 This is a flow chart of parameter tuning of the SSA optimized Kalman filter PID controller using an elite reverse learning strategy in the present invention;
[0055] Fig. 9 The present invention uses Matlab2019 to simulate the PID control simulation, the control simulation of the sparrow search algorithm, and the comparison chart of the simulation of the improved sparrow search algorithm;
[0056] Fig.10 for Fig. 9 Partial enlargement. DETAILED DESCRIPTION
[0057] The present invention will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.
[0058] The following detailed description is an exemplary description, which is intended to provide further detailed description of the present invention. Unless otherwise specified, all technical terms used in the present invention have the same meaning as those generally understood by those skilled in the art to which the present application belongs. The terms used in the present invention are only for describing specific embodiments, and are not intended to limit exemplary embodiments according to the present invention.
[0059] like Figure 1 As shown, Figure 1This is the PID principle diagram used by the PID controller in the prior art, which consists of a proportional unit P, an integral unit I and a differential unit D. Increasing P can reduce the static error of the system, but cannot eliminate the static error. It can speed up the response of the system. If the proportional coefficient is too large, it will cause overshoot and oscillation, and the system will become unstable. If it is too small, the system response will slow down. The integral link can eliminate the static error of the system. If the integral coefficient is too large, the system overshoot will increase or even oscillate. If it is too small, the effect on the system will be reduced. The differential link reflects the changing trend of the deviation signal. The differential link can reduce overshoot, overcome oscillation, speed up the response speed of the system, and reduce the adjustment time, thereby improving the dynamic performance of the system. If it is too large, the system will become unstable and easily introduce high-frequency noise. The differential link is sensitive to high-frequency interference and easily causes oscillation.
[0060] like Figure 2 As shown, Figure 2 This is a PID controller diagram of Kalman filtering in the prior art. A Kalman filter is added after the output of the controlled object of the traditional PID controller to reduce the measurement noise and control interference. The filtered value is fed back to the control system. Kalman filtering is an algorithm that uses the linear system state equation to optimally estimate the system state through the system input and output observation data. It is mainly composed of prediction equations and update equations. The prediction equation is:
[0061] Prior state estimate X(k|k-1)=AX(k-1|k-1)+BU(k)
[0062] Prior estimate covariance P(k|k-1)=AP(k-1|k-1)A T +Q
[0063] In the above formula, A is the state transfer matrix, B is the control input matrix, U(k) is the control quantity, and Q represents the covariance matrix of the process noise w. The update equation is:
[0064] The posterior state estimate X(k|k)=AX(k|k-1)+k g (k)(Y(k)-HX(k|k-1)
[0065] The optimal Kalman gain k g (k)=P(k|k-1)H T / (HP(k|k-1)H T +R)
[0066] Posterior covariance P(k|k)=(Ik g (k)h)P(k|k-1)
[0067] In the above formula, H is the measurement matrix and R represents the covariance matrix of the measurement noise v.
[0068] like Figure 3 As shown, Figure 3 For the existing SSA-KF-PID controller, the sparrow search algorithm is mainly used to optimize the PID parameters.
[0069] like Figure 4 As shown, Figure 4 The present invention is a PID controller parameter setting diagram for Kalman filtering based on an improved sparrow search algorithm based on an elite reverse learning strategy.
[0070] like Figure 5 As shown, Figure 5 The power system modeling process diagram of the prior art quadcopter drone is shown in Figure 1, and the power system model is obtained. The quadcopter drone power system model includes an electronic controller, a brushless DC motor, and a propeller. The 6S20A FOC speed regulator and 4006 motor are selected in the present invention. The battery uses a 6S-10000mah lithium polymer battery. The remote controller is Fushi FS-i6S, with 15*5.5 blades. After linearizing the quadcopter drone dynamics model, the transfer function of the quadcopter drone during hovering is obtained. The nonlinear model of the quadcopter drone is:
[0071]
[0072] Linearize the above equation to get the transfer function G of the system I (s) are as follows:
[0073]
[0074] Then combine the above formula with the power system model to obtain the transfer function G(s) during hovering.
[0075] like Figure 6 As shown, Figure 6 To seek Figure 5 Passing function parameter K through C R and ω b Combined with the throttle to find its value, and then according to the Beijing University of Aeronautics and Astronautics Reliability Flight Evaluation Website, the motor response time constant T is obtained. m Finally, the transfer function of the controlled object is:
[0076]
[0077] like Figure 7As shown, the first aspect of the present invention provides a PID controller parameter tuning method, including the steps of: S1 constructing an initial population based on a sparrow search algorithm; S2 constructing a reverse population based on an elite reverse learning strategy; S3 obtaining individuals in the initial population and the reverse population whose fitness is lower than a preset value as the final initial population; S4 decoding the individuals in the initial population to obtain Kp, Ki, and Kd, and inputting them into the Kalman filter PID controller to obtain the fitness function value of each individual; S5 sorting the fitness function value of each individual, and taking the position represented by the individual with the smallest fitness function value as the optimal position; S6 taking the three PID parameter values corresponding to the optimal position as the optimal PID parameters and outputting them.
[0078] The PID controller parameter tuning method of the present invention introduces an elite reverse learning strategy to improve the sparrow search algorithm to tune the PID controller parameters of the Kalman filter, writes code in the Matlab2019 environment and obtains the transfer function model of the quadrotor drone when hovering in the existing scheme, determines the transfer function parameters through experiments and existing technologies, and uses the transfer function as the controlled object of the PID controller of the Kalman filter.
[0079] The parameter setting method of the present invention adopts PID control algorithm to realize closed-loop control, and uses Kalman filter algorithm to filter out the noise generated by vibration and external interference during the hovering process of the quad-rotor unmanned aerial vehicle. The output value after filtering is fed back to the control system, and the elite reverse learning strategy is used to improve the initialization of the sparrow search algorithm, which increases the diversity of the population and improves the convergence speed of the algorithm. After the improvement, the optimal control parameters in the PID control process can be found quickly and accurately. Compared with traditional PID, SSA-KF-PID, and KF-PID, the improved method has strong robustness and fast system response speed, can obtain the globally optimal PID parameters, has better dynamic and static performance, has a great improvement and improvement, and makes the quad-rotor unmanned aerial vehicle more stable when hovering.
[0080] like Figure 8 As shown, Figure 8 This is a flow chart of the parameter setting of the PID controller using the elite reverse learning strategy to improve the SSA optimized Kalman filter. The specific steps of parameter setting of the present invention are described as follows:
[0081] Step 1: Population initialization operation; set the following parameters:
[0082] Population size, maximum number of iterations, upper bound ub, lower bound lb, and population dimension dim;
[0083] Step 2: Set the input signal to a sinusoidal signal, i.e., take sin(0.01*k);
[0084] Step 3: Set the fitness function, i.e., fobj function; select the absolute value of the error between the input value and the output value multiplied by the weight integral over time. In order to avoid excessive control amplitude, the u(t) term is introduced. In addition, on this basis, an overshoot term is additionally introduced to prevent overshoot. These two terms are used as the fitness function;
[0085] In this step, the fobj function is fobj=@(X)PID_controller(X, S), where there are two parameters S, and the sparrow individual represents the three PID parameters after decoding. The fitness function is:
[0086]
[0087] In formula 1: e(t) is the error between the input value and the output value; ω1 and ω2 are weights, both ranging from 0 to 1; u(t) is the control value; ω3 is the weight, and ω3>>ω1. As a specific embodiment of the present invention, the preferred values are: ω1=0.999, ω2=0.001, ω3=100.
[0088] Step 4: Start optimization;
[0089] Step 5: Initialize SSA parameters; the initialization parameters are as follows:
[0090] Warning value ST, proportion of discoverers PD, proportion of sparrows aware of danger SD;
[0091] Step 6: Calculate the number of discoverers PDNumber and the number of sparrows aware of danger SDnumber;
[0092] Step 7, set the upper boundary and the lower boundary to a three-dimensional matrix, that is, ub = ub.*ones(1, dim); lb = lb.*ones(1, dim);
[0093] Step 8: Population initialization based on elite reverse strategy. In this step, the specific steps for population initialization based on elite reverse learning strategy are as follows:
[0094] Step 1: Calculate the boundary number Boundary_no = size (ub, 2)
[0095] Step 2: Construct a reverse population by multiplying the number of populations by a dimensional zero matrix. The purpose is to store the reverse population, i.e. BackPositions = zeros (SearchAgents_no, dim);
[0096] Step 3: Determine whether the boundary number is equal to 1. If it is equal to 1, randomly generate all the initial population positions (PositionsF = rand (SearchAgents_no, dim). * (ub-lb) + lb), and then obtain the reverse population, otherwise execute step 4;
[0097] In this step, the reverse population formula is obtained as: P = a + bp (Formula 2);
[0098] In Formula 2: P is the reverse population, a and b are the upper and lower limits of the interval (a, b), and p is the original population.
[0099] Step 4: Randomly generate the initial value of each dimension population (PositionsF(:, i) = rand(SearchAgents_no, 1).*(ub_i-lb_i)+lb_i), and obtain the reverse population; the formula for obtaining the reverse population in this step is the same as (Formula 2);
[0100] Step 5: Get the elite population, take individuals from the initial population and the reverse population in order, and use the fitness function to calculate their fitness. Select individuals with lower fitness and put them into the corresponding positions of the final initial population.
[0101] Step 6: Get the elite boundary (lbT = min(XJY), ubT = max(XJY));
[0102] Step 7: Update the elite reverse solution; in this step, the formula for updating the elite reverse solution is:
[0103]
[0104] In formula 3: Reverse solution for the elites, is the elite population, K is a d-dimensional vector on (0, 1), is the dot product, α j =max(X i,j ), β j =min(X i,j ), α j and β j is a dynamic boundary.
[0105] step8: Get the initial population;
[0106] Step nine, decode Kp, Ki, Kd of individual sparrows;
[0107] Step 10: Input the fobj function into the Kalman filter PID controller:
[0108] Each time a sparrow is generated, the fobj function is used to assign values to the three PID parameters, which are the proportional Kp, the integral Ki and the differential Kd. Then, the transfer function, i.e. the controlled object, is entered when the quadcopter is hovering. Then, the fitness function value of the position of the sparrow group is calculated through the Kalman filter.
[0109] In this step, the transfer function of the controlled object is the transfer function of the quadcopter when it is hovering:
[0110]
[0111] In formula 4, τ is the response time constant of the brushless DC motor, K is related to the throttle, and m is the weight of the quadrotor drone (including the load). As a specific embodiment of the present invention, the preferred values are: τ = 0.0268, K = C R β+ω b , C R =5629,ω b =697, β=0.5 when hovering, and the mass of the quadrotor drone m=4.
[0112] Step 11, calculate the initial fitness value according to the fitness function, sort and obtain the global optimal fitness value GBestF and the global optimal position GBestX;
[0113] Step 12: If the maximum number of iterations is reached, proceed to step 13; if not, update the discoverer position, follower position, and sentinel position, and then proceed to step 9;
[0114] In this step, the discoverer position, the follower position, and the sentinel position are updated. The formulas are as follows:
[0115]
[0116] In Formula 5, i represents the number of iterations; j represents 1, 2, 3, i.e., the range of dimension d; iter max represents the maximum number of iterations, X i,j Indicates the position of the i-th sparrow in the j-th dimension; α∈(0,1] is a random number; Q is a normally distributed random number; R2 represents the warning value, ST represents the safety value; L represents a 1*3 matrix 3 is the size of d; when R2<ST, there are no predators in the surrounding environment, and the producer enters the search mode. If R2≥ST, some sparrows have discovered the predator and issued a warning to other sparrows in the population, and all sparrows quickly fly to other safe areas.
[0117]
[0118] In formula 6: X PIndicates the optimal position of the current finder; X worst Indicates the worst position in the current iteration group; A is a 1*3 matrix, where the elements of A are randomly selected from ±1, indicating the search direction, L is a 1*3 matrix with all 1s. When i>n / 2, it indicates that the i-th joiner has not obtained food and is in a hungry state. At this time, it needs to fly to other places to find food to obtain more energy.
[0119]
[0120] In formula 7: X best represents the current global best position, f i Indicates the current sparrow fitness; f g represents the global optimal position fitness; f w represents the global worst position fitness; β is the control step size parameter, a normally distributed random number with a mean of 0 and a variance of 1; k is a random number between -1 and 1; ε is the minimum constant to avoid the numerator being 0. i >f g This means that the sparrows are at the edge of the population and are very vulnerable to predators. i =f g The sparrow in the center of the flock is aware of the danger and moves closer to other sparrows to minimize the risk of being preyed upon. best It means that this location is the best location for the population and is very safe.
[0121] Step 13, border control;
[0122] Step 14, calculating the updated fitness function value, if the updated fitness function value is smaller than the optimal fitness function value before the update, then updating the fitness function value and the new sparrow position, otherwise, keep it unchanged;
[0123] Step 15, obtain the new sparrow position (X=X_new) and the new fitness function value (fitness=fitness_new);
[0124] Step 16: sort and update, obtain the optimal position, that is, the optimal three PID parameter values, and output the optimal PID parameters.
[0125] like Fig. 9 As shown, Fig. 9 The present invention uses matlab to simulate PID control simulation, KF-PID control simulation, SSA-KF-PID and improved SSA-KF-PID control simulation. The inputs are all sine sin (0.01*k). Fig.10 for Fig. 9Local enlarged image. Under the action of sinusoidal signal, according to the simulation results of four control modes in matlab, the traditional PID uses the empirical method to determine the three PID parameters as 0.3, 0.001, and 0.01 respectively. The Kalman filter PID controller uses the empirical method to obtain the three PID parameters as 0.2, 0.2, and 0.04 respectively. The parameters of the Kalman filter PID are directly adjusted by the sparrow search algorithm: 0.040856, 0.040856, and 0.040856. Finally, the parameters of the Kalman filter PID controller are adjusted by the sparrow search algorithm improved by the elite reverse learning strategy: 5, 4.8566, and 0.033236. Among them, the measurement noise and control noise introduced by the Kalman filter PID controller are both 1. Compared with KF-PID and PID, the improved SSA-KF-PID avoids the defects of the trial and error method that is time-consuming and difficult to obtain the optimal parameters, and realizes the fast and efficient adjustment of PID parameters and the obvious improvement of the input signal following effect. The improved SSA-KF-PID has better effect than SSA-KF-PID under the same population number and iteration number. In summary, the improved SSA-KF-PID controller filters out the influence of control interference and measurement noise on the control system, greatly improves the steady-state accuracy of the system, and significantly improves the control effect. In this embodiment, the control system includes a Kalman filter PID controller.
[0126] A second aspect of an embodiment of the present invention provides a system for the above PID controller parameter tuning method, comprising:
[0127] An initial population construction module, used to construct the initial population based on the sparrow search algorithm;
[0128] Reverse population construction module, used to construct reverse population based on elite reverse learning strategy;
[0129] An initial population construction module is used to obtain individuals whose fitness is lower than a preset value in the initial population and the reverse population as the final initial population;
[0130] A fitness function value module is used to decode the individuals in the initial population to obtain Kp, Ki, and Kd, and input them into the PID controller of the Kalman filter to obtain the fitness function value of each individual;
[0131] A sorting module is used to sort the fitness function values of each individual, and take the position represented by the individual with the smallest fitness function value as the optimal position;
[0132] The output module is used to output the three PID parameter values corresponding to the optimal position as optimal PID parameters.
[0133] According to a third aspect of an embodiment of the present invention, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned PID controller parameter tuning method when executing the computer program.
[0134] According to a fourth aspect of an embodiment of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the above-mentioned PID controller parameter tuning method is implemented.
[0135] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0136] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0137] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0138] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1The steps for the functions specified in one or more boxes.
[0139] It is known from common technical knowledge that the present invention can be implemented by other embodiments that do not deviate from its spirit or essential features. Therefore, the above disclosed embodiments are only illustrative in all respects and are not exclusive. All changes within the scope of the present invention or within the scope equivalent to the present invention are included in the present invention.
Claims
1. A PID controller parameter tuning method, characterized in that: The steps include: Construct the initial population based on the sparrow search algorithm; Constructing a reverse population based on an elite reverse learning strategy, obtaining the individuals in the initial population and the reverse population whose fitness is lower than a preset value as the final initial population; Decoding the individuals in the initial population to obtain Kp, Ki, and Kd, and inputting them into the PID controller of the Kalman filter to obtain the fitness function value of each individual; Sort the fitness function values of each individual, and take the position represented by the individual with the smallest fitness function value as the optimal position; The three PID parameter values corresponding to the optimal position are taken as optimal PID parameters and output.
2. The PID controller parameter tuning method according to claim 1, characterized in that: The initial population is constructed based on the sparrow search algorithm, and the specific method is as follows: Initialize the population and set the input signal to be a sinusoidal input; Set the fitness function, select the absolute value of the error between the input value and the output value multiplied by the weight integral over time; Start optimization; Initialize the parameters in the sparrow search algorithm, calculate the number of discoverers and the number of sparrows aware of danger; Set the upper and lower boundaries to three-dimensional matrices.
3. The PID controller parameter tuning method according to claim 1, characterized in that: The initial population is obtained as follows: Calculate the number of boundaries; Construct a reverse population, multiply the number of populations by a zero-dimensional matrix to store the reverse population; Determine whether the boundary number is equal to 1. If it is equal to 1, randomly generate all the initial population positions, and then find the reverse population, otherwise proceed to the next step; Randomly generate the initial value of each dimension population and obtain the reverse population; In order, individuals are taken from the initial population and the reverse population, and their fitness is calculated using the fitness function; Select individuals with lower fitness and put them into the corresponding positions of the final initial population; Get elite boundaries; Updated elite reverse solution; Get the initial population.
4. The PID controller parameter tuning method according to claim 1, characterized in that: The specific way to get the fitness function value of each individual is as follows: The sparrow individual decoded Kp, Ki, Kd are input into the Kalman filter PID controller, where the controlled object is the transfer function of the quadcopter when it is hovering; Calculate the initial fitness value according to the fitness function.
5. The PID controller parameter tuning method according to claim 2, characterized in that: The sinusoidal input is sin(0.01*k).
6. The PID controller parameter tuning method according to claim 3, characterized in that: The fitness function formula is: Where: e(t) is the error between the input value and the output value; ω1 and ω2 are weights, both ranging from 0 to 1; u(t) is the control value; ω3 is the weight, and ω3>>ω1.
7. The PID controller parameter tuning method according to claim 3, characterized in that: The formula for obtaining the reverse population is: P = a + bp Where: P is the reverse population, a and b are the upper and lower limits of the interval (a, b), and p is the original population.
8. A system for a PID controller parameter tuning method, characterized in that: include: An initial population construction module, used to construct the initial population based on the sparrow search algorithm; Reverse population construction module, used to construct reverse population based on elite reverse learning strategy; An initial population construction module is used to obtain individuals whose fitness is lower than a preset value in the initial population and the reverse population as the final initial population; A fitness function value module is used to decode the individuals in the initial population to obtain Kp, Ki, and Kd, and input them into the PID controller of the Kalman filter to obtain the fitness function value of each individual; A sorting module is used to sort the fitness function values of each individual, and take the position represented by the individual with the smallest fitness function value as the optimal position; The output module is used to output the three PID parameter values corresponding to the optimal position as optimal PID parameters.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the PID controller parameter tuning method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the PID controller parameter tuning method according to any one of claims 1 to 7 is implemented.
