1 Introduction
PID control is simple in principle, highly adaptable, and easy to implement, making it a commonly used method for robot control. The core of PID control system design lies in determining the optimal solutions for its proportional gain Kp, integral constant Ti, and derivative constant Td. The selection of control parameters directly affects the response speed, the intensity of the adjustment deviation, and the accuracy of the humanoid robot control system.
For determining PID control parameters, there are mainly traditional parameter tuning methods and optimization methods combining intelligent algorithms. Traditional parameter tuning methods mainly include trial and error, empirical data methods, and extended critical proportional gain methods. However, applying traditional parameter tuning methods sometimes fails to achieve effective control. In recent years, with the development of intelligent algorithms, fuzzy algorithms, neural networks, and genetic algorithms have all been applied to PID parameter optimization.
Genetic algorithms are a novel, randomized search and optimization method that simulates biological evolution, featuring parallel computing, global convergence, and encoding operations. Due to their open algorithmic structure, ease of integration with various problems, and computational convenience, they have been successfully applied to solving a wide range of complex optimization problems. The characteristics of genetic algorithms make their application to PID parameter optimization feasible.
To address the problems in optimizing PID control parameters for humanoid robots, this paper proposes an adaptive genetic algorithm method for optimizing PID control parameters, leveraging the advantages of intelligent algorithms. Simulations were conducted in the ADAMS environment, yielding satisfactory results, demonstrating that the proposed method is feasible and effective.
2. PID control of humanoid robot joints
2.1 Conventional PID Control Principle
PID control, as the earliest practical control method, is the most mature control method in analog control systems. PID control adjusts proportionally based on the deviation between the setpoint and the actual value, and introduces integral and derivative components to improve the performance and quality of the control system. Its basic control flow is shown in Figure 1.
Figure 1 Schematic diagram of PID control process
In PID control, the selection of the three parameters Kp, Ti, and Td directly affects the quality of PID control. Therefore, the key design issue for PID control is always how to select these three parameters. Conventional PID controllers often fail to achieve ideal control results due to poor parameter settings, suboptimal performance, and poor adaptability to operating conditions, thus limiting the application of PID control.
Genetic algorithms are a randomized search method that draws inspiration from natural selection and inheritance mechanisms in biology. As a direct search method, they have virtually no restrictions on the fitness function, requiring neither continuity nor differentiability. Therefore, using genetic algorithms to adjust PID parameters is a good approach. However, standard genetic algorithms have some shortcomings in terms of linearity, and adaptive genetic algorithms are improvements made to address these shortcomings. Therefore, this paper uses an adaptive genetic algorithm to optimize PID parameters.
2.2 PID Parameter Optimization Based on Adaptive Genetic Algorithm
In the simulation control of humanoid robot walking, simply ensuring the stability of the robot's walking process is not enough. In order to improve the response speed and control accuracy of the control system, it is necessary to find the optimal PID control parameters of the humanoid robot control system to fully utilize the performance of the control system. The block diagram of the PID control system based on the genetic algorithm is shown in Figure 2.
Figure 2. Block diagram of PID control principle optimized by genetic algorithm
2.2.1 Adaptive Genetic Algorithm
The adaptive genetic algorithm improves upon the standard genetic algorithm in the following ways:
1) The crossover rate and mutation rate of individuals are automatically adjusted according to the fitness function and the number of generations. The AGA adaptive crossover rate and mutation rate are adjusted according to the following formula.
By adjusting these genetic operators, when the fitness of individuals in the population is poor, the maximum value of the crossover operator and the minimum value of the mutation operator are assigned to the individuals in the population to ensure that the algorithm can perform global search during the evolution process; when the fitness value of an individual is large (the individual is excellent), the crossover operator is continuously reduced and the mutation operator is increased as the number of iterations increases, thereby improving the local search capability of the algorithm.
2) Optimal individual retention strategy and new individual fitness judgment. By calculating the fitness value of the new individuals generated after crossover and mutation and comparing it with the fitness value of the original individuals, it is possible to effectively select better individuals.
The adaptive genetic algorithm, after being improved from the standard genetic algorithm, has the following advantages in addition to the advantages of the standard genetic algorithm:
1) Avoid premature convergence and improve global search capabilities;
2) To avoid oscillations during algorithm convergence and improve local search capabilities;
3) Make the genetic operators directional to improve the convergence of the genetic algorithm.
2.2.2 AGA Programming
In the AGA design process, a series of algorithm parameters are required, such as selection, crossover, mutation operators, and maximum number of iterations. Before writing the algorithm, its relevant parameters must be determined.
1) Determine the optimization parameters of the genetic algorithm
In genetic algorithm design, the algorithm genes and optimization parameters are not directly related. Therefore, the parameters that the algorithm needs to optimize are first determined: the proportional gain constant Kp, integral constant Ti, and derivative constant Td of the PID control parameters. Selecting the optimal control parameters ensures the control accuracy and response speed of the humanoid robot.
2) Genetic Algorithm Encoding
Encoding is the process of representing the solution to a problem using a code, thereby corresponding the problem's state space to the solution space of a genetic algorithm. Different encoding methods not only determine the form of chromosomes but also significantly influence the operational methods of genetic operators (selection, crossover, and mutation operators). Encoding methods vary depending on the optimization problem. The main encoding methods include: 0-1 encoding, sequential encoding, real number encoding, and integer encoding.
To ensure sufficient accuracy of the optimized parameters, this paper employs real-number encoding to encode the PID control parameters, with the corresponding chromosome form as follows:
3) Population initialization
The initial population is the starting point for the iterative optimization of the genetic algorithm. Its generation method mainly depends on the encoding method. This paper uses a random function to generate the initial population of the genetic algorithm.
4) Population size ps
In the optimization process of genetic algorithms, the determination of the population size p<sub> s</sub> has a significant impact on the algorithm's implementation. If the population size p <sub>s </sub> is too small, the population lacks diversity, leading to premature convergence in evolution. If the population size is too large, the computational convergence will be slower, affecting the efficiency of the genetic algorithm. In addition, the population size also affects other factors such as selection pressure and population diversity. Therefore, a reasonable population size is crucial for the algorithm. Through repeated experiments, this paper finally determined the population size to be p<sub> s</sub> = 20.
5) Fitness function
In Adaptive Genetic Algorithms (AGA), the fitness function is almost the sole criterion for evaluating the quality of individuals in the population. Selection, replication, crossover, and mutation of individuals are all closely related to the fitness function. There are generally two design methods for the fitness function: the first is the original fitness function, which directly uses the objective function as the fitness function for individuals; the second is the standard fitness function. Since the fitness function is usually required to be non-negative during the genetic algorithm's solution process, and a larger fitness function indicates better individuals in the population, the objective function usually needs to be transformed to obtain the standard fitness function.
In this paper, the humanoid robot control system mainly controls the joint torques of the humanoid robot. These torques drive the joint movement of the humanoid robot and ensure that the actual joint displacements output by the humanoid robot match the theoretical joint displacements. Therefore, this paper uses the maximum deviation between the actual and theoretical joint trajectories during the humanoid robot's walking process as the control objective function. The smaller the objective function, the higher the control accuracy. Since the fitness function requires a larger value, indicating a better individual robot, the objective function needs to be modified to correspond its minimum value to the maximum value of the fitness function. Specifically, this is achieved by subtracting the objective function from a larger number to obtain the fitness function value. The functional relationship is as follows:
6) Determination of genetic operators
The basic idea of genetic algorithms is survival of the fittest. It primarily uses selection, crossover, and mutation methods to eventually obtain the optimal individual as the number of generations increases. During the evolutionary process, the selection, crossover, and mutation operators have a significant impact on the algorithm's performance.
In the design of genetic algorithms, different selection strategies lead to varying degrees of selection pressure. Excessive selection pressure results in more replication of superior individuals, causing the algorithm to converge too quickly and ultimately leading to premature convergence. Conversely, insufficient pressure results in significant population diversity, causing the algorithm to converge too slowly. Common selection strategies include roulette wheel selection, ranking-based selection, and tournament selection.
This paper adopts a fitness ratio selection strategy for the fitness function of the algorithm, as shown in Equation 5-3. Furthermore, this method is modified by employing an elite retention strategy. In the later stages of the algorithm, the genes of the optimal individual are directly preserved. This method effectively avoids the possibility of losing the optimal individual in the later stages of the genetic algorithm.
7) Termination conditions determined
There are two common termination conditions for genetic algorithms. First, the algorithm terminates when the deviation between the actual value and the expected value is within the allowable tolerance range. Second, the maximum number of iterations is used as the termination condition, and the best individual in the last generation is output as the optimal solution. This paper adopts the second termination method and specifies a maximum of 20 iterations.
3. Simulation Study
3.1 Implementation of Genetic Algorithm in ADAMS
Based on the basic idea of optimizing PID parameters using the adaptive genetic algorithm, an AGA optimization program was written in VC++. Using the control toolbox provided by ADAMS, a control system based on the adaptive genetic PID algorithm was established, and simulation was performed to verify the correctness of the virtual prototype model.
A simulation flowchart combining AGA and ADAMS is constructed. During the optimization design process, ADAMS first initializes the interface, passing the optimization objective function, design variables, and range to the genetic algorithm. The genetic algorithm generates an initial population and submits the parameters to ADAMS for objective function calculation. The genetic algorithm calculates the fitness of individuals based on the objective function value. Then, a termination condition is determined. If the termination condition is not met, a new population is generated through genetic evolution, and a new fitness value is calculated. If the termination condition is met, the optimal solution and related parameters are submitted to ADAMS, and the optimization program terminates. (See Figure 3.)
Figure 3. Simulation flowchart of AGA in ADAMS
Introducing genetic algorithms into ADAMS allows for easy acquisition of fitness function values without needing to consider the mathematical model of the mechanical system in genetic algorithm optimization, thus simplifying the design process of genetic algorithms.
Based on the simulation flowchart, taking the control of the left knee joint trajectory of a humanoid robot as an example, an optimized algorithm control system is established and simulated.
First, design variables for optimization are established, namely variable_P, variable_I, and variable_D. Since the genetic algorithm has a strong global optimization capability, the ranges for variable_P, variable_I, and variable_D are determined to be [1, 2500], [1, 500], and [1, 2500], respectively. These three design variables are then associated with the PID control system to ensure the global search capability of the genetic algorithm.
Secondly, an optimization objective function is established. The absolute value of the difference between the actual joint trajectory and the theoretical joint trajectory is used as the design objective; the smaller the objective function value, the higher the control accuracy. Since the robot joint trajectory is a complex piecewise function, spline fitting is used to input the theoretical trajectory into ADAMS for convenience.
Finally, the optimization objective and design variables were determined using ADAMS' DesignEvaluationTools, and relevant optimization properties were set, such as display settings, output settings, and optimization parameter settings. The optimization algorithm in 'Optimizer…' was set to 'User1', and simulation was performed.
3.2 Post-processing of PID parameter optimization
The optimization results show that the PID control accuracy has been significantly improved. The AGA algorithm uses the maximum number of iterations as the termination condition. Although the convergence speed is relatively slow, the optimization results are accurate, indicating that the genetic algorithm has a strong global optimization ability.
Entering the ADAMS/PostProcessor module allows you to compare the AGA optimization simulation results with the simulation results from the SQP optimization module built into the ADAMS software. The upper part of Figure 4 shows the AGA optimization results, and the lower part shows the SQP optimization results. In both algorithms, the trend of control deviation over time is roughly the same, and the magnitude of the deviation is significantly reduced compared to before optimization, fully demonstrating the role of optimization design in the control system, as shown in Figure 4.
Figure 4 Comparison of Optimized Objective Function Values
Furthermore, by processing the objective function data and examining its maximum, minimum, and average deviation values during the control process, it can be seen that the control optimization using the genetic algorithm yields smaller maximum and average values for both the objective function than the results calculated using the SQP algorithm built into ADAMS, as shown in Table 1.
Table 1 Comparison of numerical values for each term in the objective function
The actual trajectory of the left knee joint angle movement of the humanoid robot after AGA optimization is compared with the theoretical trajectory before optimization. In the figure, the blue dashed line represents the actual trajectory of the joint angle, and the red solid line represents the theoretical trajectory of the joint angle. The simulation results are shown in Figures 5 and 6.
Figure 5. Optimization of the anterior joint theory and actual trajectory overlap.
Figure 6. Optimized joint theory and actual trajectory overlap
Comparing Figures 6 and 7, it can be seen that after optimization by the adaptive genetic algorithm, the control performance of the control system is greatly improved compared with that before optimization. The actual trajectory of the joint movement is closer to the theoretical trajectory, which ensures the stability and controllability of the humanoid robot's walking and improves the real-time response speed of the control system. This proves the correctness of the parameter optimization method of the PID control system based on the genetic algorithm.
4. Conclusion
To address the challenges in determining the parameters of a humanoid robot's PID control system, this paper proposes an optimization method based on an adaptive genetic algorithm. Three parameters are used as individuals in the genetic algorithm. The maximum deviation between the theoretical and actual joint trajectories of the humanoid robot is used as the objective function, with a corresponding fitness function. A fitness ratio selection strategy effectively avoids losing the optimal individual in the later stages of the genetic algorithm, ensuring the accuracy of parameter selection for the robot control system. Comparative analysis of ADAMS simulation results shows that the optimized humanoid robot control system exhibits significantly improved control accuracy and response speed, demonstrating that PID control based on the adaptive genetic algorithm can achieve superior results compared to traditional PID control.
References
[1] Jin Qi, Deng Zhijie. PID control principle and parameter tuning method [J]. Journal of Chongqing Institute of Technology, 2011(7):91-94.
[2] Yu Xiaomin, Yu Xiaokun, Geng Rui. Simulation study on PID controller parameter optimization algorithm [J]. Computer Simulation, 2008(5):212-215.
[3] Jiang Yuchun, Wu Hongyan. Parameter tuning of PID controller [J]. Laiwu Steel Technology, 2006(2):54-55.
[4] Zhu Ying, Zhu Jun. Various PID controls and their simulation comparison [J]. Industrial Control Computer, 2010(1):53-54.
[5] Niu Xiangjie, Wang Yujie, Tang Jian. Research on PID controller parameter optimization based on genetic algorithm [J]. Computer Simulation, 2010(11):180-182.
[6]WANGP, KWOKDP. Optimal design of PID process controllers based on genetic algorithms [J]. Control Eng Prac, 1994, 2 (4): 641-648.
[7] Yang Zhimin, Wang Xu, Zhuang Xianyi. A review of the application of genetic algorithms in the field of automatic control [J]. Information and Control, 2000, 29(4): 14-17.
[8] Zhang Kecun, Li Huanqin. Engineering Optimization Methods and Their Applications [M]. Xi'an: Xi'an Jiaotong University Press, 2007.
[9] Huang Yourui. Intelligent Optimization Algorithms and Their Applications [M]. Beijing: National Defense Industry Press, 2008.