Construction method for fuzzy PID controller of unmanned ship
By constructing a fuzzy PID controller in an unmanned ship and optimizing model parameters and membership function using the spider bee optimization algorithm, the problem of strong parameter setting dependence in different environments of traditional PID controllers is solved, and the high adaptive heading control of the unmanned ship in complex environments is achieved.
Patent Information
- Application Number
- CN202510246576.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-04
- Publication Date
- 2025-04-15
AI Technical Summary
In the application of traditional PID controllers in unmanned ships, the parameter setting dependence is strong, making it difficult to achieve satisfactory control effects in different environments, resulting in delayed response, large overshoot and poor adaptability.
The construction method of the fuzzy PID controller is adopted, and the membership function of the fuzzy PID control model is optimized through the spider bee optimization algorithm, and the parameters of the PID controller are automatically adjusted to achieve high adaptive heading control.
The high adaptive heading control of unmanned ships in complex marine environments is realized, which reduces the dependence on experimental data and complex numerical simulations, and improves the control response speed and robustness.
Smart Images

Figure CN119828451A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of unmanned ship intelligent control, and in particular to a method for constructing an unmanned ship fuzzy PID controller. Background Art
[0002] The design of the heading controller has always been one of the core contents of the research on autonomous control technology of unmanned ships. Mathematical model is the basis for designing the heading controller, and system identification is one of the simplest and most effective methods to determine the model parameters, including least squares method, extended Kalman filter, neural network, spectral analysis and support vector machine method. In practical applications, in order to obtain a high-precision hull model, researchers often need to combine physical experiments, dynamic models, numerical simulations and data-driven methods to continuously correct the model so that it is as close to the real dynamic characteristics of the unmanned ship as possible. This makes the hull modeling dependent on a large amount of experimental data, and the complexity and cost of modeling are high.
[0003] In unmanned ship control systems, PID (proportional-integral-differential) controllers are widely used because of their simplicity, ease of use, and good real-time performance. However, the performance of traditional PID controllers is highly dependent on parameter settings, which need to be constantly adjusted in different environments. Traditional parameter tuning methods often fail to achieve satisfactory control effects, resulting in control system response delays, large overshoots, and poor adaptability. In order to improve the performance of PID controllers in unmanned ships, intelligent optimization algorithms have gradually been applied to PID parameter tuning in recent years. Intelligent optimization algorithms have good global optimization capabilities by simulating group behavior in nature. They can find the optimal solution in a multi-dimensional parameter space and improve the performance of the controller. They have been widely used in the field of engineering control and have shown good results in improving controller response speed, reducing system overshoot, and enhancing system robustness. However, when faced with high-dimensional parameter spaces, these algorithms may still fall into local optimality, converge slowly, and have problems with robustness that need to be improved, which limits their application in unmanned ships. Summary of the invention
[0004] The purpose of the present invention is to provide a method for constructing a fuzzy PID controller for an unmanned ship, thereby realizing highly adaptable heading control of the unmanned ship in a complex marine environment.
[0005] To achieve the above object, the technical solution adopted by the present invention is:
[0006] A method for constructing a fuzzy PID controller for an unmanned ship, the method comprising the following steps:
[0007] Step 1: According to the Ardupilot attitude sensor process, the transfer function of the unmanned ship is established as follows:
[0008]
[0009] Where G represents the transfer function from the target angle Angel to the actual angle Out; K is the transfer function that considers the hardware description layer HAL and the servo module Servo as a whole; K PID is the transfer function of the PID controller; P ctr is the transfer function of the proportional controller;
[0010] Setting a 4th-order Laplace model, the expression of the transfer function K that regards the hardware description layer and the servo module as a whole is:
[0011]
[0012] Among them, s is the Laplace operator, and A~I are the model parameters to be optimized;
[0013] Step 2: Set the parameter range of the model parameters A to I to be optimized, and obtain the target angle Angel and the actual angle Out from the heading log data. Substitute the target angle Angel into the unmanned ship transfer function G to obtain the predicted value O of the actual angle. p ; Calculate O p The mean square error of the actual angle Out is calculated by using the spider bee optimization algorithm for multiple iterations to continuously reduce the mean square error MSE, and the optimal values of the model parameters A~I to be optimized are determined with the minimum mean square error as the goal;
[0014] Step 3: After determining the optimal values of A~I, set the number of inputs of the fuzzy controller to 2, which are the error between the target posture and the actual posture and the differential of the error; set the number of outputs of the fuzzy controller to 3, which are the parameters K of the PID controller. P , K I and K D , using fuzzy control rules and initialized fuzzy membership function to establish a fuzzy controller, the fuzzy controller output parameter K P , K I and K D Import PID controller;
[0015] Step 4: Optimize the membership function of the fuzzy controller using the spider bee optimization algorithm, and evaluate the control effect using the time multiplied by the absolute value integral performance index of the error to obtain the optimal membership function;
[0016] Step 5. Determine the proportional coefficient, integral coefficient and differential coefficient of the PID controller according to the optimal membership function. The construction of the fuzzy PID controller is now completed. The fuzzy PID controller is used to control the heading of the unmanned ship and has the optimal heading control performance.
[0017] Furthermore, the process of the spider bee optimization algorithm includes:
[0018] In the search phase, a dynamic adaptive grouping strategy is introduced. The process of the dynamic adaptive grouping strategy is as follows: individuals with ordinal numbers less than k*N / 2 in the population are classified as G10, and G10 represents the number of individuals in this class; individuals with ordinal numbers between k*N / 2 and k*N are classified as G20; wherein k is a distance control factor;
[0019] Introduce a weighting coefficient α t To adjust the grouping ratio of each generation, the formula is:
[0020]
[0021] Among them, α t is the weighting coefficient; E i represents the development effect of the i-th generation population; E t represents the development effect of the t-th generation population, N is the size of the population; is the fitness of the nth individual in the tth generation, is the average fitness of the tth generation; the grouping ratio is defined as: G1 t =α t G10, G2 t =(1-α t )·G20, the update formula for the next position of the female wasp in the search phase is:
[0022]
[0023] in, are three randomly selected populations; r2 is a random number between 0 and 1; μ1 determines the constant movement through the current direction; the expression of μ2 is μ2=B*cos(2πl),
[0024]
[0025] Where, e is the exponential constant; l is a random integer between 1 and -2;
[0026] In the nesting stage, the dimension symmetric distance optimization is introduced. The process of the dimension symmetric distance optimization is: randomly select individuals from the developed individuals, calculate the midpoint F between the selected individual and the best individual in the current group, and then calculate the symmetric point of the selected individual relative to point F. The position of the symmetric point is considered to be the new individual g;
[0027] Randomly select individuals from the developed population, calculate the midpoint F between the selected individual and the best individual in the current population, and then calculate the symmetric point of individual i relative to point F. This position is considered to be the new individual g. The second update formula for nesting behavior is:
[0028]
[0029] in, is the updated position of the individual; is the position of the current iteration individual; is the position of the new individual generated; D i is the relative distance between the randomly selected individual and the best individual; D g is the relative distance between the new individual and the best individual.
[0030] Furthermore, the distance control factor k is replaced by the nonlinear time transformation weight w(t) in the following formula:
[0031]
[0032] Among them, t is the current iteration number, t max is the maximum number of iterations, and r7 is a random number uniformly distributed in [0,1].
[0033] Compared with the prior art, the present invention has the following beneficial effects:
[0034] (1) When only the heading log data of the unmanned ship is used, the method of the present invention can still effectively obtain a relatively accurate hull transfer function model. The spider bee optimization algorithm is used twice to respectively optimize the model parameters and the membership function of the fuzzy PID control model, thereby obtaining the optimal heading control performance. In addition, a high-precision hull model can be established based only on the heading log data, which reduces the dependence on experimental data and complex numerical simulations to a certain extent, and reduces the cost and difficulty of modeling.
[0035] (2) In the embodiment of the present invention, the improved spider bee optimization algorithm is preferably used. By introducing dynamic adaptive grouping strategy, dimensionally symmetric distance optimization and / or nonlinear time transformation weights, the global search capability and convergence speed are improved, providing a more reliable basis for high-dimensional parameter optimization in dynamic and complex unmanned ship control scenarios.
[0036] (3) When the PID controller parameters of the fuzzy PID controller are adjusted, the PID parameters are indirectly optimized by optimizing the membership function of the fuzzy controller, thereby reducing the reliance on experience and manual parameter adjustment while maintaining control accuracy. This helps to achieve better control response characteristics, reduce system overshoot, and enhance the robustness of the system to a certain extent in practical applications.
[0037] (4) The fuzzy controller has the advantages of simple principle, strong adaptability, fast response speed and strong anti-interference ability. However, the adjustment of its membership function is complicated and requires a lot of experience and skills. The present invention uses the improved spider bee optimization algorithm as the optimal algorithm to adjust the membership function of the fuzzy controller, which reduces the cost of manually setting parameters while ensuring accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A schematic diagram of a flow chart of a method for constructing a fuzzy PID controller for an unmanned ship according to an embodiment of the present invention;
[0039] Figure 2 This is the control flow chart of the attitude sensor of Ardupilot;
[0040] Figure 3 It is the schematic diagram of the membership function of the fuzzy controller;
[0041] Figure 4 It is the schematic diagram of fuzzy control rules of fuzzy controller;
[0042] Figure 5 It is the structural diagram of fuzzy PID controller;
[0043] Figure 6 This is a comparison chart of the results of different intelligent optimization algorithms after optimizing the optimization model parameters in K;
[0044] Figure 7 Error integral comparison chart after optimizing the membership function of fuzzy controller by different optimization algorithms;
[0045] Figure 8 The system response after optimization by the arithmetic optimization algorithm (AOA);
[0046] Fig. 9 This is the system response after optimization by the Crayfish Optimization Algorithm (COA);
[0047] Fig.10 The system response after optimization for the Marine Predator Algorithm (MPA);
[0048] Fig.11 The system response after optimization by the Spider Bee Optimization (SWO) algorithm;
[0049] Fig.12 System response after optimization using the Improved Spider Bee Optimization (ISWO) algorithm. DETAILED DESCRIPTION
[0050] The present invention is further described in detail below in conjunction with the accompanying drawings and embodiments, but this is not intended to limit the scope of protection of the present application.
[0051] like Figure 1 As shown, the present invention provides a method for constructing a fuzzy PID controller for an unmanned ship, which specifically includes the following steps:
[0052] Step 1: Establish the transfer function of the unmanned boat according to the Ardupilot attitude sensor process, and use the spider bee optimization algorithm to determine the model parameters.
[0053] The transfer function model is calculated using the Mason formula, which is as follows:
[0054]
[0055] Among them, P is the system model function; Δ is the characteristic polynomial of the system, and its calculation formula is:
[0056] Δ=1-ΣL a +ΣL b L c -ΣL d L e L f +…
[0057] where ΣL a is the sum of all different loop gains; ΣL b L c is the sum of all pairwise non-contact loop gains; ΣL d L e L f For all the non-contacting loops, take the sum of the gain products of three loops each time; and so on. n is the number of forward paths from the input node to the output node; P k is the total gain of the kth forward path from the input node to the output node; Δ k is the remainder of the kth forward path.
[0058] The control flow of Ardupilot's attitude sensor is as follows Figure 2 As shown, the input is the target angle Angel, and the angular velocity is obtained through the proportional controller P. The transfer function of the proportional controller is regarded as a whole and set to P ctr ; N(s) is noise; the transfer function of the PID controller is set to K PID; The transfer function of the acceleration sensor H1 is set to K1; then the hardware description layer (HAL) converts the target acceleration into the corresponding PWM wave, outputs it to the servo module (Servo) and outputs the actual angle, and regards the hardware description layer (HAL) and the servo module (Servo) as a whole, and sets the transfer function to K; the transfer function of the angle sensor H2 is set to K2, the angle sensor H2 collects the actual angle Out, and obtains the angular velocity through the proportional controller P with the target angle Angel, and then it is processed by the PID controller with the noise N(s) and the angular velocity collected by the acceleration sensor H1 and acts on the hardware description layer.
[0059] Let N(s) = 0, K1 = K2 = 1, and the transfer function G from the target angle Angel to the actual angle Out is as follows:
[0060]
[0061] Where G represents the transfer function from the target angle Angel to the actual angle Out; K is the transfer function that considers the hardware description layer HAL and the servo module Servo as a whole; K PID is the transfer function of the PID controller; P ctr is the transfer function of the proportional controller;
[0062] The control structure of the PID controller is as follows:
[0063]
[0064] Among them, K P is the proportionality coefficient; K I is the integral coefficient; K D are differential coefficients, and the three coefficients of the PID controller are preset values; s is the Laplace operator.
[0065] Setting a 4th-order Laplace model, the expression of the transfer function K that regards the hardware description layer and the servo module as a whole is:
[0066]
[0067] Among them, s is the Laplace operator, and A~I are the model parameters to be optimized.
[0068] Figure 5 Here, num(s) and den(s) represent the numerator and denominator of K respectively.
[0069] Step 2: Use the spider bee optimization algorithm to determine the model parameters A~I to be optimized, set the range of nine parameters, and the algorithm optimization dimension of the spider bee optimization algorithm is 9 dimensions. Obtain the target angle Angel and the actual angle Out from the heading log data, substitute the target angle Angel into the unmanned ship transfer function G, and obtain the predicted value O of the actual angle. p ; Calculate O p The mean square error of the actual angle Out is calculated by using the spider bee optimization algorithm for multiple iterations to continuously reduce the mean square error MSE, and the optimal values of the model parameters A~I to be optimized are determined with the minimum mean square error as the goal. The expression of mean square error (MSE) is as follows:
[0070]
[0071] Where n is the total number of samples, y i is the true value of the i-th sample, that is, the actual angle Out; is the predicted value of the i-th sample, that is, the predicted value O p .
[0072] Step 3: After determining the optimal values of A~I, set the number of inputs of the fuzzy controller to 2, which are the error between the target posture and the actual posture and the differential of the error; set the number of outputs of the fuzzy control to 3, which are the parameters K of the PID controller. P , K I and K D The fuzzy controller is established by using the fuzzy control rules and the initialized fuzzy membership function. The parameter K output by the fuzzy controller is P , K I and K D Import the PID controller.
[0073] The output formula of the PID controller is as follows:
[0074]
[0075] Where u(t) is the output signal of the PID controller; e(t) is the error between the target posture and the actual posture; K P is the proportionality coefficient; K I is the integral coefficient; K D is the differential coefficient and t is the time.
[0076] The membership function of the fuzzy controller in this embodiment is as follows: Figure 3As shown in the figure, each input and output has 7 isosceles triangle membership functions (ENB, ENM, ENS, EZ, EPS, EPM, EPB). After the membership function is optimized, the center point and range of the membership function are adjusted. The input and output of the fuzzy controller have a total of 35 membership functions, which are determined by the center point and its range. The 35 membership functions after optimization are not necessarily the same. The same membership function is set initially. The fuzzy control rules of the fuzzy controller are as follows: Figure 4 shown.
[0077] The structure of fuzzy PID controller is as follows: Figure 5 As shown, the membership function and the fuzzy control rules can be implemented according to the existing technology.
[0078] Step 4: Use the spider bee optimization algorithm to optimize the membership function of the fuzzy controller, and use the time multiplied by the absolute value integral of the error performance index to evaluate the control effect and obtain the optimal membership function.
[0079] In this embodiment, the improved spider bee optimization algorithm is used to optimize the membership function of the fuzzy controller. The preset input of the system and the actual output of the system are passed through the Sum1 module to obtain the system error e(t)( Figure 5 ), the control effect is evaluated by using the time multiplied by the absolute value of the error integral performance index, and multiple iterations are performed to continuously reduce ITAE. The expression of the time multiplied by the absolute value of the error integral performance index (ITAE) is as follows:
[0080]
[0081] Where t is time and e(t) is the system error.
[0082] The improved spider bee optimization algorithm introduces dynamic adaptive grouping strategy, dimensionally symmetric distance optimization and nonlinear time transformation weight. The spider bee optimization algorithm simulates the behavior of spider bees in nature, including hunting and nesting behavior and mating behavior, wherein the hunting and nesting behavior is divided into three stages: search stage, tracking escape stage, and nesting stage.
[0083] The general process of improving the spider bee optimization algorithm is:
[0084] S1: Generation of initial population: The input and output of the fuzzy PID controller have a total of 5 variables, each variable has a total of 7 membership functions, each membership function is set to a symmetrical triangular wave, and the distance from the symmetry axis is set to the dimension of the population to be optimized, that is, the dimension of the spider bee is 35. Set the number of populations to 100, and initialize the population matrix as follows:
[0085]
[0086] Where t represents the generation index; i represents the population index (i=1, 2, ..., 100); N is the number of populations; D is the size of the dimension; is a vector of 35-dimensional random initialization numbers between 0 and 1; Represents one solution in each generation; SW Pop is the initialization population; H and L represent the upper and lower limits of the parameters respectively.
[0087] S2: In the main loop, if the random number [0,1] is less than the given crossover probability (TR), the population enters hunting and nesting behavior, which is divided into searching phase, fleeing phase and nesting phase; otherwise, it enters mating behavior.
[0088] S3: After the female spider lays an egg in the host's abdomen, it closes the nest to make the nest inconspicuous. This means that the role of this female wasp in the optimization process is almost complete, and then the S2 step is repeated until the main loop ends and the optimal position of the population is saved, that is, the optimal value range of the membership function.
[0089] In the search phase, the female wasp randomly searches for the best spider egg-laying point, and its position update rate is constant, as shown in the following formula:
[0090]
[0091] in, For the populations participating in the cycle; is the population after position update; is a randomly selected population; μ1 determines the constant motion through the current direction, and the formula is as follows:
[0092] μ1=|rn|*r1 (9)
[0093] Among them, r1 is a random number between 0 and 1, and rn is a random number generated based on a normal distribution.
[0094] As the spider escapes from the female bee, the distance between them increases. As the distance increases, the behavior pattern changes from predation to searching. The mathematical formula for this behavior is as follows:
[0095]
[0096] μ2=B*cos(2πl) (11)
[0097]
[0098] Among them, r2 is a random number between 0 and 1; is a randomly selected population; l is a random integer between 1 and -2; H and L represent the upper and lower limits of the parameters respectively.
[0099] The next position of the female wasp during the search phase is as follows:
[0100]
[0101] Among them, r3 and r4 are random numbers between 0 and 1.
[0102] In the search phase, a dynamic adaptive grouping strategy is introduced to classify individuals with ordinal numbers less than k*N / 2 in the population as G10, and G10 represents the number of individuals in this class. Individuals with ordinal numbers between k*N / 2 and k*N are classified as G20.
[0103] Here k is the distance control factor, expressed as:
[0104]
[0105] Among them, t is the current iteration number, t max is the maximum number of iterations.
[0106] Introduce a weighting coefficient α t To adjust the grouping ratio of each generation, the formula is as follows:
[0107]
[0108] Among them, E i represents the development effect of the i-th generation population; E t Represents the development effect of the t-th generation population; the formula is as follows:
[0109]
[0110] Where N is the size of the population, is the fitness of the nth individual in the tth generation, is the average fitness of this generation. The grouping ratio is defined as: G1 t =α t G10, G2 t =(1-α t )·G20, the improved formula (13) is:
[0111]
[0112] The tracking and escaping phase shows two trends: one is the wasp position adjustment and prey pursuit; the other is the simulation of prey escape through the distance factor, which increases with the increase of iteration. The first trend is shown below:
[0113]
[0114] Among them, r5 is a random number between 0 and 1; C is the distance control factor that determines the speed of the wasp, and the expression is as follows:
[0115]
[0116] Among them, t and t max are the current iteration number and the maximum iteration number, and r6 is a random number between 0 and 1.
[0117] The second trend is that when a spider moves away from a female bee, the distance between the female bee and the spider gradually increases, as shown in the following formula:
[0118]
[0119] in, is a vector with normal distribution between k and -k, expressed as follows:
[0120]
[0121] The formula for the tracking escape phase is summarized as follows:
[0122]
[0123] Here r3 and r4 are the same as mentioned above.
[0124] In the nesting stage, two formulas are used to simulate different nesting behaviors. The first formula is as follows:
[0125]
[0126] in, represents the optimal solution; l is a random integer between 1 and -2.
[0127] The second formula is as follows:
[0128]
[0129] Here, r3 is the same as mentioned above; γ is the number generated by the Levy function; a, b, and c are the indices of three solutions randomly selected from the population; U is a binary vector expressed as:
[0130]
[0131] Here, r4 and r5 are the same as those mentioned above. The formula for the nesting phase is summarized as follows:
[0132]
[0133] Here r3 and r4 are the same as mentioned above.
[0134] In the nesting stage, the dimension symmetric distance optimization is introduced, and individuals are randomly selected from the developed individuals. The midpoint F between the selected individual and the best individual in the current group is calculated, and then the symmetric point of individual i relative to point F is calculated. This position is considered to be the new individual g. The formula is as follows:
[0135]
[0136] Among them, F j is the midpoint between the selected individual and the best individual in the current population; is the position of a randomly selected individual in the population; is the best individual position in the current group; is the position of the current iteration individual; is the position of the new individual generated; η is the coefficient for controlling the disturbance intensity; sint is the standard sine function; formula (23) is improved as follows:
[0137]
[0138] Among them, D i is the relative distance between the randomly selected individual and the best individual, D g is the relative distance between the new individual and the best individual, and the formula is as follows:
[0139]
[0140] During the mating behavior, new spider wasp eggs are generated according to the following formula:
[0141]
[0142] Crossover means that in the solution SW i t and The uniform crossover operator applied between them has a probability called the crossover rate (CR); and SW i t are two vectors representing male and female spider bees respectively.
[0143] Male spider wasps are generated differently from female wasps according to the following formula:
[0144]
[0145] Among them, β and β1 are two numbers randomly generated according to normal distribution, e is an exponential constant, and The expression is as follows:
[0146]
[0147] Where a, b, c are the indices of three solutions randomly selected from the population, and a≠i≠b≠c.
[0148] The nonlinear time transformation weight is introduced to replace the exploration weight k. The formula of the nonlinear time transformation weight w is as follows:
[0149]
[0150] Where t is the current iteration number, t max is the maximum number of iterations, and r7 is a random number between 0 and 1.
[0151] Figure 6 This is a comparison chart of the results of different intelligent optimization algorithms after optimizing the optimization model parameters in K. The parameters of the model to be optimized in K are also optimized using the improved spider bee algorithm, and the results are as follows: Figure 6 As shown in the figure, compared with the original algorithm (SWO), the improved spider bee algorithm (ISWO) not only improves the performance, but also significantly accelerates the convergence speed and improves the response speed. Compared with the emerging optimization algorithms in the past five years, such as the arithmetic optimization algorithm (AOA), the crayfish optimization algorithm (COA) and the marine predator algorithm (MPA), it has obvious advantages in optimization performance and convergence speed. The mean square error of this embodiment is controlled at about 12.34.
[0152] Figure 7 The error integral comparison chart after optimizing the membership function of the fuzzy controller by different optimization algorithms. The input and output ranges of the fuzzy controller are set to [-300,300]. The input of the model is a unit step signal that jumps at 1s. The sampling frequency of the fuzzy PID controller is 400Hz, and the simulation time is 10 seconds. Compared with the original algorithm, the improved spider bee algorithm has improved performance and significantly accelerated convergence speed. Compared with the emerging optimization algorithms in the past five years, the optimization performance is the best and the convergence speed is fast, and the error integral value is controlled at about 0.004.
[0153] Figures 8 to 12 The results of system response after optimization by different optimization algorithms are shown in Figure 1. The orange line represents the unit step signal that jumps at 1 second, and the blue line represents the system response output. Compared with the other four algorithms, the improved spider bee optimization algorithm has a faster system response speed, reduced overshoot and time to reach stability, no steady-state error, and can achieve the most accurate control response.
[0154] The above embodiments are only for illustrating the technical concept and features of the present invention, and their purpose is to enable people familiar with the technology to understand the content of the present invention and implement it accordingly, and they cannot be used to limit the protection scope of the present invention. Any equivalent changes or modifications made according to the spirit of the present invention should be included in the protection scope of the present invention.
[0155] Any matters not described in the present invention are applicable to the prior art.
Claims
1. A method for constructing a fuzzy PID controller for an unmanned ship, characterized in that: The construction method comprises the following steps: Step 1: According to the Ardupilot attitude sensor process, the transfer function of the unmanned ship is established as follows: Where G represents the transfer function from the target angle Angel to the actual angle Out; K is the transfer function that considers the hardware description layer HAL and the servo module Servo as a whole; K PID is the transfer function of the PID controller; P ctr is the transfer function of the proportional controller; Setting a 4th-order Laplace model, the expression of the transfer function K that regards the hardware description layer and the servo module as a whole is: Among them, s is the Laplace operator, and A~I are the model parameters to be optimized; Step 2: Set the parameter range of the model parameters A to I to be optimized, and obtain the target angle Angel and the actual angle Out from the heading log data. Substitute the target angle Angel into the unmanned ship transfer function G to obtain the predicted value O of the actual angle. p ; Calculate O p The mean square error of the actual angle Out is calculated by using the spider bee optimization algorithm for multiple iterations to continuously reduce the mean square error MSE, and the optimal values of the model parameters A~I to be optimized are determined with the minimum mean square error as the goal; Step 3: After determining the optimal values of A~I, set the number of inputs of the fuzzy controller to 2, which are the error between the target posture and the actual posture and the differential of the error; set the number of outputs of the fuzzy controller to 3, which are the parameters K of the PID controller. P , K I and K D , the fuzzy controller is established by using the fuzzy control rules and the initialized fuzzy membership function. The parameter K output by the fuzzy controller is P , K I and K D Import PID controller; Step 4: Optimize the membership function of the fuzzy controller using the spider bee optimization algorithm, and evaluate the control effect using the time multiplied by the absolute value integral performance index of the error to obtain the optimal membership function; Step 5. Determine the proportional coefficient, integral coefficient and differential coefficient of the PID controller according to the optimal membership function. The construction of the fuzzy PID controller is now completed. The fuzzy PID controller is used to control the heading of the unmanned ship and has the optimal heading control performance.
2. The construction method according to claim 1, characterized in that: The process of the spider bee optimization algorithm includes: In the search phase, a dynamic adaptive grouping strategy is introduced. The process of the dynamic adaptive grouping strategy is as follows: individuals with ordinal numbers less than k*N / 2 in the population are classified as G10, and G10 represents the number of individuals in this class; individuals with ordinal numbers between k*N / 2 and k*N are classified as G20; wherein k is a distance control factor; Introduce a weighting coefficient α t To adjust the grouping ratio of each generation, the formula is: Among them, α t is the weighting coefficient; E i represents the development effect of the i-th generation population; E t represents the development effect of the t-th generation population, N is the size of the population; is the fitness of the nth individual in the tth generation, is the average fitness of the tth generation; the grouping ratio is defined as: G1 t =α t G10, G2 t =(1-α t )·G20, the update formula for the next position of the female wasp in the search phase is: in, are three randomly selected populations; r2 is a random number between 0 and 1; μ1 determines the constant movement through the current direction; the expression of μ2 is μ2=B*cos(2πl), Where, e is the exponential constant; l is a random integer between 1 and -2; In the nesting stage, the dimension symmetric distance optimization is introduced. The process of the dimension symmetric distance optimization is: randomly select individuals from the developed individuals, calculate the midpoint F between the selected individual and the best individual in the current group, and then calculate the symmetric point of the selected individual relative to point F. The position of the symmetric point is considered to be the new individual g; Randomly select individuals from the developed population, calculate the midpoint F between the selected individual and the best individual in the current population, and then calculate the symmetric point of individual i relative to point F. This position is considered to be the new individual g. The second update formula for nesting behavior is: in, is the updated position of the individual; is the position of the current iteration individual; is the position of the new individual generated; D i is the relative distance between the randomly selected individual and the best individual; D g is the relative distance between the new individual and the best individual.
3. The construction method according to claim 2, characterized in that: The distance control factor k is replaced by the nonlinear time transformation weight w(t) in the following formula: Among them, t is the current iteration number, t max is the maximum number of iterations, and r7 is a random number uniformly distributed in [0,1].