Introduction

Robots play an indispensable role as industrial production gradually advances towards intelligence and intelligent automation1. Over the past few decades, robot technology has developed vigorously, evolving from traditional industrial robots working independently to collaborative robots working alongside humans, and in the future, robots will be integrated into daily life2. Currently, the mainstream mobile robots are mostly rigid robots, which have attracted widespread attention due to their characteristics such as moving speed, load capacity, and the ability to complete tasks independently. Mobile robots can generally be divided into three categories: wheeled robots3, tracked robots4 and legged robots5. Although wheeled and tracked robots can complete tasks quickly on flat terrains, they are easily trapped in place in cluttered environments. It is noteworthy that the legs of humans and animals enable them to navigate complex terrains. Inspired by this, legged robots have been developed. Abhishek Kumar Kashyap and Dayal R. Parhi, among others, effectively optimized the gait stability and energy efficiency of robots on complex terrains through gait generation and control technologies6,7.These robots are usually made of metals and polymers, while these materials often render them cumbersome, limiting their flexibility. More importantly, their lack of pliability makes it difficult to adapt to complex environments, thereby reducing task completion efficiency. Besides, the rigidity of these robots may pose a danger to people due to their lack of compliance during human-robot interaction8,9. Consequently, researchers have gradually turned their attention to soft-bodied organisms, seeking inspiration from observing these creatures10. Soft robots have gradually developed with the continuous innovation of new intelligent materials11 and 3D printing technologies12. Inspired by the morphology of octopuses, Faheem Ahmed and colleagues proposed a multi-material bio-inspired soft octopus robot (Octobot). Using a combination of 3D printing technology, molding, and casting processes, the soft octopus robot was prepared and successfully demonstrated its capability to simulate the natural movements of octopuses13. Aniket Joshi et al. presented a novel tethered jellyfish robot with production and performance characteristics based on a novel soft pneumatic composite actuator. These soft actuators enable the vertical movement of the robot in the water through the expansion and contraction of compressed air14. Besides, a novel quadruped robot based on a dual-cavity pre-inflated pneumatic (DCPCP) soft actuator and a highly flexible torso was proposed by Yuja Li et al. A servomotor-driven asymmetric cross-tendon is used to drive the DCPCP soft leg, avoiding flexion and mimicking the gait of quadrupeds with the simplest drive and control strategies15. Abhishek Kumar Kashyap and Dayal R. Parhi, among others, proposed a hybrid algorithm for robot path planning, enabling effective obstacle avoidance and path planning in real-world environments. This optimized the navigation performance of robots in dynamic obstacle scenarios and multi-robot systems16,17,18. Yibin Wang et al. proposed a micro-robot capable of swimming rapidly in fluid environments, with its ability to swim upstream in tubular environments providing valuable insights for future biomedical applications19. Samuel Alves et al. introduced a multi-material soft robotic hand designed using finite element analysis (FEA), which was experimentally validated for its effectiveness in grasping objects of different shapes and sizes, reducing the trial-and-error process in design and manufacturing20. Qing Gao et al. proposed a 3D hand posture estimation method based on a monocular camera, combined with hand detection, to enable remote operation of a bionic dual-hand robot. Experimental results demonstrated the outstanding performance of this method on both public datasets and a real robotic teleoperation platform21.

Breakthroughs in sensor and vision technologies have also contributed to the advancement of robotics. Kenan Deng et al. proposed a multi-channel signal chatter detection method that combines filtered displacement, acceleration, and internal signals to detect low-frequency and high-frequency chatter, and validated the effectiveness of this method22. Jingyu Sun et al. designed a quadruped robot leg phase detection method using proprioceptive feedback, which can accurately estimate leg states without external sensors, and successfully validated it through hardware experiments in different scenarios23. The performance of path planning and navigation is crucial for intelligent robots in practical applications. Chaoyang Zhu proposed a new path planning and navigation method and conducted experimental validation. The experimental results showed that the method based on reinforcement learning and adaptive control achieved significant improvements in the path planning and navigation of intelligent robots24. In response to the growing customer demands and market competition in modern manufacturing enterprises, robotic manufacturing systems have proven to be an effective solution. Chen Zheng et al. proposed a KBE architecture to assist users in customizing robotic manufacturing systems. Through an ontology knowledge model and a multi-attribute decision model, the system infers and evaluates robotic system architectures, thereby reducing design costs and improving user customization efficiency25.

In contrast to rigid quadrupedal robots, soft-bodied quadrupedal robots made from flexible materials exhibit safer and softer characteristics when interacting with people or fragile objects, as well as better adaptability and energy-absorption features, which have provided a strong impetus for their development. The soft body means that soft robots have infinite degrees of freedom, giving them unlimited possibilities, while it is also these characteristics that make the motion control of soft robots more difficult. The soft robots are made of flexible materials, and their structure has large deformation characteristics, making it difficult to establish mathematical models. Furthermore, their drive modes are mostly pneumatic or hydraulic drives, both of which exhibit a high degree of nonlinearity26. Consequently, these challenges present difficulties for the accurate modeling and dynamic response tuning of soft robots. Several modeling methods commonly used for soft robots include the Piecewise Constant Curvature model (PCC), Cosserat Rods theory, machine learning models, etc27,28,29. The PCC is a modeling method that divides a curve into several segments of approximately constant curvature. However, the ideal PCC assumptions are difficult to satisfy, and the values derived from them are unstable. Cosserat Rods theory treats a bar as being composed of continuous rods, each of which can rotate along the centerline of the bar, yet it is only effective for elongated structures. Although machine learning model can be developed without considering a dynamics model, it requires a large amount of data to drive, and the collection and processing of such data consume significant resources30. In terms of control strategies, the main types include open-loop, closed-loop, and autonomous control. The PID controller, a prevalent type of feedback controller, is extensively utilized in the robotics ___domain due to its simplicity, flexibility, and robustness. Liu31 proposed an improved PID controller for the operational stability control of a buried pipeline maintenance robot. Abhishek32 applied the PID controller to the intricate gait control of humanoid robots. However, to the best of our knowledge, research on applying PID controllers to control the locomotion of quadruped soft robots is extremely limited. More importantly, the tuning method of PID parameters affects the stability, responsiveness, and accuracy of the control system. Common methods include empirical approaches and the Ziegler-Nichols method33, but these methods heavily rely on empirical values, leading to potential instabilities in control performance. Chen Zheng et al. proposed a hybrid offline programming method that combines CAD-based, vision-based, and CAD-vision interactive programming approaches, effectively addressing the challenge of automatic generation of welding programs for complex workpieces34. Yaohui Sun et al. proposed an event-triggered learning impedance control algorithm for lower limb rehabilitation exoskeleton robots, transforming the impedance control problem into an optimal control problem. They developed a neural network using reinforcement learning and verified the system’s stability through the Lyapunov method35.

This paper proposed a walking control algorithm for the soft quadruped robot by using genetic algorithms to optimize PID parameters. The research has successfully applied the conventional PID controller to the soft robot. Additionally, the proposed method can be implemented for the actual control of a soft quadruped robot. The remainder of this paper is organized as follows. The second section introduces the structure of the quadruped soft robot and establishes a mathematical model linking valve voltage to leg bending, which is used to control the walking of the soft robot. The third section describes the principles of the PID controller using genetic algorithms. The transfer function for the soft robot’s legs, based on system identification, serves as the objective function for the genetic algorithm. The process for optimizing the algorithm’s parameters is presented. This is followed by simulating the PID parameters tuning using genetic algorithms, the Z-N method and the particle swarm optimization(PSO) method. The fourth section first introduces the design of the experimental platform. Actual walking tracking experiments subsequently confirm the enhanced performance under genetic algorithm-based PID parameter tuning. Finally, the fifth section summarizes the research.

Structure and control model

Structure

To achieve the walking functionality of the soft robot, a four-legged structural design is utilized. As shown in Fig. 1a, the single-leg structure of the soft quadruped robot is designed to maintain structural stability and flexibility during motion. The hexaform structure with good strength, rigidity, and balance is adopted, allowing precise control during motion and strong resistance to external disturbances. Moreover, this structure enables strong resistance to external interference and also ensures a more uniform distribution of strain. The unique structural design optimizes the performance of flexible materials and sensors, which helps extend the soft robot’s lifespan. The soft quadruped robot is moved via pneumatic actuation, with pneumatic actuators covering the surface of the hexagonal structure. The pneumatic actuator is made of two layers of 0.24 mm thick plastic film and soft pneumatic tubes, sealed on both sides with a plastic sealing machine. The pneumatic tubes are arranged in a certain order within the plastic film, primarily to guide the gas entering the pneumatic actuator to each chamber, thereby causing the entire actuator to expand and deform, which in turn facilitates the walking capability of the robot. The overall structure of the soft quadruped robot shown in Fig. 1b includes the front and rear crossbars and the middle waist section. Each single leg is equipped with a clamping mechanism on its end face, which can slide on the crossbar to allow flexible adjustment of the distance between the front and rear legs to further adjust the robot’s overall center of gravity.

Fig. 1
figure 1

Components of the designed soft quadruped robot.

Soft materials allow for a high degree of deformation, enabling soft robotic legs to facilitate walking by bending. The angle of leg bending determines the walking gait. A Bend sensor is a device that covers a variable resistance layer on the surface of a flexible insulator, using the change in the sensor’s resistance value to measure the degree of bending. Thus, the bend sensor is attached to the leg of the soft robot. When the leg bends during walking, the sensor bends synchronously with the leg’s shape, causing a change in its resistance. The bend sensor shown in Fig. 1c has a resistance that varies proportionally with the bending degree and can measure bending in both directions. A pneumatic actuator valve drives the bending during walking and the actual degree of bending is monitored through the sensor’s resistance, thereby forming the walking closed-loop control for the quadruped soft robot.

Walking control model

The soft leg’s length varies upon bending, which makes kinematics modeling difficult. Therefore, we establish the control model for single-leg walking based on the geometrical analysis method. As shown in Fig. 2, the leg’s bending angles as θ, and the outer side’s bending arc length and radius as l1 and R1 respectively. Corresponding parameters for the leg’s inner side are l2 and R2; for the central axis, these are l0 and R0. The lateral distance between these positions is denoted as x. The relationship among parameters can be expressed as:

$$\left\{ {\begin{array}{*{20}{c}} {{l_0}=\frac{\pi }{{{{180}^ \circ }}}\theta {R_0}} \\ {{l_1}=\frac{\pi }{{{{180}^ \circ }}}\theta {R_1}} \\ {{l_2}=\frac{\pi }{{{{180}^ \circ }}}\theta {R_2}} \end{array}} \right.$$
(1)
$$\left\{ \begin{gathered} {R_1} - {R_2}=2x \hfill \\ {R_1}+{R_2}=2{R_0} \hfill \\ \end{gathered} \right.$$
(2)
$$\left\{ \begin{gathered} {l_1}={l_0}+\vartriangle l \hfill \\ {l_2}={l_0} - \vartriangle l \hfill \\ \end{gathered} \right.$$
(3)

Where l is the leg’s length variable after bending. Combining the above formulas, the relationship between the leg bending angle and length variable can be derived:

$$\theta =\frac{{{{180}^ \circ }}}{{\pi x}}\vartriangle l$$
(4)
Fig. 2
figure 2

Geometry of leg bending.

The deformation of the gas chamber results from the bending of the legs. Changes in height BE lead to alterations in the angles and and α ≈ β can be considered when the material stress error is ignored. Consequently, this facilitates the expression of lateral distance x in Eq. (6).

$$\begin{aligned} BC = & BF \cdot \cos \beta \\ \approx & BF \cdot \sqrt {1 - \sin ^{2} \alpha } \\ = & BF \cdot \sqrt {1 - \left( {\frac{{BE}}{{2BF}}} \right)^{2} } \\ \end{aligned}$$
(5)
$$x=\frac{1}{2}\left( {AB+BC+CD} \right)$$
(6)

The hexagonal length of the chamber is equal and constant, that is, AB = CD = l3, BF = EF = 2l3. By substituting Eq. (5) into Eq. (6), we derive the following expression:

$$\begin{gathered} x{\text{=}}\frac{1}{2}\left( {2{l_3}+2{l_3} \cdot \sqrt {1 - {{\left( {\frac{{{l_1} - {l_4}}}{{64{l_3}}}} \right)}^2}} } \right) \hfill \\ {\text{ =}}{l_3}\left( {1+\sqrt {1 - {{\left( {\frac{{{l_1} - {l_4}}}{{64{l_3}}}} \right)}^2}} } \right) \hfill \\ \end{gathered}$$
(7)

Where l4 is the total thickness of the gas chamber frames, which is a constant 20 mm. The outer side’s bending arc length 1 is much smaller than the length of 32 chambers. Therefore, Eq. (7) can be simplified as x = 2l3. substitute it into Eq. (4) we can get:

$$\theta =\frac{{{{180}^ \circ }}}{{2\pi {l_3}}}\vartriangle l$$
(8)

The valve voltage directly influences the length of the gas chamber, and their mapping relationship v is determined by the characteristics of the valve and can be obtained through valve calibration. Thus, we establish the walking control model which relates the valve voltage u to the bending angle θ in Eq. (9).

$$\theta =\frac{{{{180}^ \circ }}}{{2\pi {l_3}}} \cdot v(u)$$
(9)

When v becomes a linear function, the walking control model can be regarded as a linear relationship. That is, there is a linear relationship between the valve voltage and the bending angle of the soft actuator. Thus, we can obtain the corresponding transfer function based on system identification through actual experimentation. Taking the valve voltage as an input signal, measure the bending angle of the sensor as the valve voltage varies. The spatial state equation is expressed in Eq. (10), and the corresponding transfer function is Eq. (11).

$$\left\{ {\begin{array}{*{20}{c}} {dx/dt=Ax(t)+Bu(t)+Ke(t)} \\ {y(t)=Cx(t)+Du(t)+e(t)} \end{array}} \right.$$
(10)
$$G(s)=C{({\text{sI-A)}}^{ - 1}}B+D$$
(11)

Kinematic model

Traditional rigid robots typically use the D-H (Denavit-Hartenberg) coordinate method for kinematic analysis, determining the end-effector’s pose through joint variables. However, for soft robots made of flexible materials, the structure lacks distinct joints and parameters such as the bending angles of rigid joints, making it impossible to directly apply traditional methods. Therefore, the equivalent D-H method is introduced, specifically the Piecewise Constant Curvature (PCC) model. This method treats the soft leg as equivalent to multiple circular arcs with different curvatures. Each arc is represented by its arc length l, bending angle α, and rotation angle β. These virtual joint variables replace traditional joint variables, allowing the kinematic analysis of the soft robot to be performed through these three virtual variables.

Since all four legs of the robot are identical, only one leg is analyzed. The structure of the soft leg is modeled as a cylindrical segment, and a spatial coordinate system is established according to the right-hand rule at the center of the plane on the side with the connection device, as shown in Fig. 3.

Fig. 3
figure 3

Schematic diagram of the soft robot leg.

In the quadruped robot, one end of the connection device is attached to the robot’s body as the fixed surface, while the other end moves in space with changes in air pressure as the moving surface. In the initial state, the soft leg is vertical and without deformation. Under the action of the pneumatic actuator, the soft leg undergoes elongation and bending deformation. Taking bending as an example, the plane in which the arc of the bent soft leg lies is referred to as the bending plane. The angle between the fixed surface and the moving surface is the bending angleα, and the angle between the bending plane and the XOZ plane is the rotation angle β.

The initial length of the soft leg is l0, after bending it becomes l1, and at a certain moment, its length is lt. The bending radius is denoted as r, and the coordinates of the center point of the moving surface are O1(x, y, z), from which the following equations are derived.

$$r=\frac{{{l_t}}}{\alpha }$$
(12)
$${o_1}=\left( {\begin{array}{*{20}{c}} x \\ y \\ z \end{array}} \right)=\left( {\begin{array}{*{20}{c}} {(1 - \cos \alpha ) \cdot \cos \beta } \\ {(1 - \cos \alpha ) \cdot \sin \beta } \\ {\sin \alpha } \end{array}} \right) \cdot \frac{{{l_t}}}{\alpha }$$
(13)

In the constant curvature model, the position and orientation of the moving surface in space can be determined. Translating the center point O of the fixed surface to the center point O1 of the moving surface, the translation matrix is:

$${T_1}=\left( {\begin{array}{*{20}{c}} 1&0&0&{(1 - \cos \alpha ) \cdot \cos \beta \cdot \frac{{{l_t}}}{\alpha }} \\ 0&1&0&{(1 - \cos \alpha ) \cdot \sin \beta \cdot \frac{{{l_t}}}{\alpha }} \\ 0&0&1&{\sin \alpha \cdot \frac{{{l_t}}}{\alpha }} \\ 0&0&0&1 \end{array}} \right)$$
(14)

Rotating the coordinate system by β degrees around the Z-axis, the resulting rotation matrix R1 is:

$${R_1}=Rot(Z,\beta )=\left( {\begin{array}{*{20}{c}} {\cos \beta }&{ - \sin \beta }&0&0 \\ {\sin \beta }&{\cos \beta }&0&0 \\ 0&0&1&0 \\ 0&0&0&1 \end{array}} \right)$$
(15)

Rotating the coordinate system by α degrees around the Y1-axis, the resulting rotation matrix R2 is:

$${R_2}=Rot(Y,\alpha )=\left( {\begin{array}{*{20}{c}} {\cos \alpha }&0&{\sin \alpha }&0 \\ 0&1&0&0 \\ { - \sin \alpha }&0&{\cos \alpha }&0 \\ 0&0&0&1 \end{array}} \right)$$
(16)

Rotating the coordinate system by -β degrees around the Z1-axis, the resulting rotation matrix R3 is:

$${R_3}=Rot(Z, - \beta )=\left( {\begin{array}{*{20}{c}} {\cos \beta }&{\sin \beta }&0&0 \\ { - \sin \beta }&{\cos \beta }&0&0 \\ 0&0&1&0 \\ 0&0&0&1 \end{array}} \right)$$
(17)

By combining Eq. (3) to (6), the resulting transformation matrix T from the fixed surface to the moving surface coordinate system is:

$$T={T_1}{R_1}{R_2}{R_3}=\left( {\begin{array}{*{20}{c}} {{c^2}\beta c\alpha +{s^2}\beta }&{c\alpha s\beta c\beta - s\beta c\beta }&{s\alpha c\beta }&{(1 - c\alpha ) \cdot c\beta \cdot \frac{{{l_t}}}{\alpha }} \\ {c\alpha s\beta c\beta - s\beta c\beta }&{{s^2}\beta c\alpha +{c^2}\beta }&{s\alpha s\beta }&{(1 - c\alpha ) \cdot s\beta \cdot \frac{{{l_t}}}{\alpha }} \\ { - s\alpha c\beta }&{ - s\alpha s\beta }&{c\alpha }&{s\alpha \cdot \frac{{{l_t}}}{\alpha }} \\ 0&0&0&1 \end{array}} \right)$$
(18)

In the equation:,, and represent sinα, sinβ, cosα and cosβ respectively.

Through the single-leg kinematic expressions and the variation of virtual joint variables, the end position of the soft leg can be determined. Experimental measurements showed that the length of the cylindrical segment ranges from 110 mm to 194 mm. Since the virtual joint variables of the soft leg can be randomly generated, a statistical method is used to model and simulate the end position on the MATLAB platform. This method simplifies the research object and computational problem by simulating random numbers and their characteristics, thereby reducing computational complexity. By implementing MATLAB programming, the workspace of the foot-end position was obtained, and a 3D plot was generated to display the movement range and characteristics of the soft leg, as shown in Fig. 4.

Fig. 4
figure 4

Workspace of the foot-end.

PID optimization by genetic algorithm

PID controller

The PID controller is a widely used closed-loop feedback controller that achieves the desired system response by calculating the error. The parameters of the PID controller are crucial to the control system, as they directly affect the system’s stability, response speed, and accuracy. Traditional tuning methods, such as the Ziegler-Nichols (Z-N) method, often require repeated trials to find near-optimal parameters, making the process time-consuming and costly. The advantage of using genetic algorithms to optimize PID controller parameters lies in their powerful global search capability, which enables them to find the optimal solution across the entire parameter space, avoiding local optima. Additionally, the automated optimization process reduces the time and complexity of manual parameter tuning.The controller’s output is expressed as a linear combination of the proportional, integral, and derivative components of the error signal as shown in Eq. (19).

$$u(t)={K_p} \cdot e(t)+{K_i} \cdot \int {e(t)dt+{K_d}} \tfrac{{de(t)}}{{dt}}$$
(19)

The controller’s performance mainly depends on the settings of parameters Kp, Ki, and Kd. Kp, Ki, and Kd are three key parameters in a PID controller, representing proportional, integral, and derivative coefficients, respectively. The PID controller is a widely used feedback controller in industrial automation and control systems, which adjusts the system’s output to make it as close as possible to the desired target value.This paper applies the genetic algorithm to the design of the PID controller to automate the optimization of parameters, thereby enhancing the accuracy, stability, and response efficiency of various kinds of control performance simultaneously.

Optimization process by genetic algorithm

Genetic Algorithm, simulating the process of biological evolution, is popular in search and optimization problems36. Figure 5 illustrates the flow of this algorithm. The main steps of the optimization process include chromosome encoding for population initialization, calculating the fitness function, and performing genetic operations during each generation. Individuals are randomly distributed within the solution space. The optimal solution is determined by iteratively calculating the fitness function and performing genetic operations, which include selection, crossover, and mutation.

Fig. 5
figure 5

Flowchart of genetic algorithm.

  1. (1)

    population initialization.

An appropriate population size can balance the search range and execution speed of the algorithm. The i-th individual of the t-th generation in the population is defined as x. The population size n is set to 80. To avoid bias in the optimization process, we use a randomly generated method to determine the initial values of Kp, Ki, and Kd. This allows the entire parameter space to be covered, effectively preventing local optima. Each optimization runs for 60 generations, with the initial values of Kp, Ki, and Kd uniformly and randomly generated within their respective ranges. Based on empirical values from relevant literature and considering control theory and system characteristics, we initially set the parameter ranges for Kp, Ki, and Kd. To ensure system stability and avoid excessive adjustment, we selected smaller ranges. Preliminary experiments revealed that limiting Kp to 0 ≤ Kp ≤ 0.1, Ki to 0 ≤ Ki ≤ 0.03, and Kd to 0 ≤ Kd ≤ 0.06 resulted in a good system response. Real-coded encoding demonstrated better convergence characteristics and allowed arbitrary precision settings. Therefore, we used real-coded encoding for chromosome representation, with a precision of five decimal places.

  1. (2)

    fitness function design.

In this experimental design, strict requirements are placed on deviations during the process of tracking a predefined trajectory. The integral of the square of error (ISE), as a key performance indicator, is well-suited for systems that emphasize suppressing deviations during the transition process. At the same time, hardware disturbances in the control system of the soft robotic system are inevitable, affecting control performance. Therefore, the fitness function consists of dynamic performance indicators such as the integral of the square of error, overshoot, steady-state error, rise time, and peak time to comprehensively optimize the control system. This multi-dimensional optimization not only improves the robot’s motion accuracy, stability, and response speed but also enhances its adaptability and maneuverability in complex environments while maintaining energy efficiency and coordinated control of the flexible structure, thereby improving the performance and robustness of the soft quadruped robot in various tasks. Hence, the ISE and the dynamic performance of the system are chosen as components of the fitness function, which is expressed as follows:

$$\begin{gathered} f={\int_{0}^{\infty } {\left[ {e(t)} \right]} ^2}{\text{dt}}+{M_o} \cdot Max(0,OS)+ \hfill \\ {\text{ }}{M_e} \cdot SSE+{M_r} \cdot RT+{M_p} \cdot PT \hfill \\ \end{gathered}$$
(20)

Where f is the fitness value, e(t) is the difference between the set value and the process value, OS is the overshoot, SSE is the steady state error, RT is the rise time, and PT is the peak time. Mo is the weight for controlling the system’s overshoot, which refers to the part where the system’s response exceeds the target setpoint. Excessive overshoot can lead to instability or undesirable system responses. Me represents the weight for steady-state error, which is the difference between the system’s stable state and the target value. Mr is the weight for rise time, which measures the time it takes for the system to rise from the initial state to a range between 10% and 90% of the target value, reflecting the system’s response speed. Mp represents the weight for peak time, which is the time required for the system to reach its maximum response value, indicating the system’s speed and stability. After calculating the fitness value for each particle, we obtain the optimal particle.

  1. (3)

    Selection, Crossover and Mutation.

Selection, crossover, and mutation operations, as the core steps of the genetic algorithm, determine the search efficiency and the quality of the optimal solution. The tournament selection algorithm is simple to implement, with low computational complexity, making it particularly suitable for large-scale problems, effectively reducing computational overhead and improving algorithm efficiency. Additionally, the algorithm can preserve population diversity, avoiding a bias toward individuals with high fitness, thus preventing premature convergence or getting stuck in local optima. By adjusting the tournament size, selection pressure can be flexibly controlled, ensuring global search capability while accelerating algorithm convergence. Tournament selection is insensitive to fitness distribution, showing strong robustness, making it suitable for complex optimization problems. These features collectively give tournament selection significant advantages in both performance and efficiency.The tournament strategy, employed as the selection method during the iterative process, randomly chooses a subset of individuals from the t-th generation as contestants. Those individuals with the minimum fitness value advance to the (t + 1)-th generation. While the individual with the minimum fitness value is not selected, the elite strategy copies it directly to the next generation, thereby enhancing the global search ability of the algorithm. The hybrid crossover method matches the real number coding and simultaneously expands the search space of the current population. Applying this method in Eq. (21) notably increases the diversity of individuals. The Gaussian mutation, the operation used for mutation, involves a Gaussian random number centered around the current parameter value modifying the gene value of the individual as stated in Eq. (22). An appropriately chosen standard deviation σ facilitates the algorithm’s ability to jump out of the local optimum, enabling a more comprehensive and expedient discovery of the optimal solution.

$$\left\{ \begin{gathered} {y_1}^{{t+1}}=\alpha {x_1}^{t}+\left( {1 - \alpha } \right){x_2}^{t} \hfill \\ {y_2}^{t}=\alpha {x_2}^{t}+\left( {1 - \alpha } \right){x_1}^{t} \hfill \\ \end{gathered} \right.$$
(21)
$${x^{\prime t}}={x^t}+N\left( {0,{\sigma^2}} \right)$$
(22)
  1. (4)

    Parameter Optimization Process.

Initial Population Generation: A set of initial populations is randomly generated within the preset ranges, with each individual representing a combination of Kp, Ki, and Kd parameters.

Fitness Function Evaluation: The fitness value of each individual is calculated based on the system’s control performance (such as overshoot, steady-state error, peak time, and rise time). The fitness function penalizes cases of system instability or excessive overshoot, ensuring both steady-state and dynamic performance of the controller.

Selection, Crossover, and Mutation: In each generation, the best individuals are selected based on their fitness values for crossover and mutation, generating the next generation of populations. Crossover explores new solution spaces, while mutation increases population diversity, preventing local optima.

Iterative Optimization: This process is repeated for multiple generations until the optimal parameter combination is found. The final Kp, Ki, and Kd values are the global optimal solution obtained through iterative optimization over multiple generations.

Figure 6 illustrates the walking control principle diagram of the quadruped soft robot. The bending angle during the robot’s locomotion is measured by a bending sensor. The error between the measured value and the target value serves as the input for the Genetic Algorithm. The GA algorithm finds the optimal PID parameters kp ki kd that yield the best controller performance. Subsequently, the optimized PID controller adjusts the bending angle by modulating the voltage of the electrical proportional valve, enabling the soft robot to execute the predetermined gait.

Fig. 6
figure 6

Walking control diagram by optimized PID.

Optimization of PID simulation

GA-PID has strong global search capabilities. Compared to ZN and PSO, GA can better explore the entire search space, leading to more optimal PID parameters. Additionally, GA offers better adaptability, especially when dealing with highly flexible and nonlinear systems like soft robots, effectively addressing uncertainties and improving control performance. In contrast, ZN-PID is mainly suitable for linear systems and performs poorly in complex nonlinear systems. Its parameter tuning is unstable, which may lead to controller instability or poor response in challenging environments. While PSO-PID has good local search capabilities, it tends to get stuck in local optima in high-dimensional and multi-peak problems, and its global exploration ability is inferior to GA.

In this section, we simulated the effect of optimizing PID parameters using the genetic algorithm to demonstrate a comprehensive improvement performance of the optimized controller. The convergence curve of the genetic algorithm, as depicted in Fig. 7a, demonstrates a rapid approach to the minimum value, indicating that the PID parameters can be successfully optimized.

As shown in Fig. 7b,c, the evolution of individual parameters Kp​, Ki, and Kd ​over different generations using the genetic algorithm is demonstrated, leading to final convergence. In Fig. 7c, the color bar represents the generations, ranging from dark (early generations) to light (later generations). The blue and purple dots indicate individuals from early generations, while orange and red dots represent individuals from later generations. It can be observed that in the early stages, the individuals are scattered across the solution space, indicating that the algorithm is broadly exploring different parameter combinations for global search. As the generations progress, the individuals gradually cluster in a specific region, particularly within the range of the Kp​, Ki​, and Kd parameters. This shows that the algorithm is converging towards an optimal solution, reducing population diversity, and ultimately finding better PID parameter combinations, thereby enhancing the controller’s performance.

The step response of the system is shown in Fig. 7d, from which we can see that the GA-PID has a faster response, smaller overshoot, and faster convergence than the conventional PID and PSO-PID. Table 1 reveals that the rise time accelerated by 20.4% and 36.2%, the overshoot increased by 5.404% and 1.78%, the settling time improved by 19.6%. It is evident that the comprehensive performance of the GA-PID is superior to the PID controller tuned by the Z-N method and PSO method.

Fig. 7
figure 7

GA-PID Simulation.

Table 1 Performance comparison of GA-PID and PID.

Experimental validation and analysis

Construction of the control platform

The designed quadruped soft robot utilizes pneumatic actuation to move, with each leg being equipped with eight actuators. To precisely control these actuators, we developed a multi-channel air pressure control system. This system comprises an air pump, a pressure-reducing valve, and an electric proportional valve. The air pump has a rated exhaust pressure of 0.7 MPa, a flow rate of 100 L/min, and a power rating of 1100 W, which is sufficient for experimental needs. The pressure-reducing valve, an accessory of the air pump, operates between 0 and 0.6 MPa and consistently outputs air pressure at 0.2 MPa. The electric proportional valve receives a DC 0–10 V input signal and outputs between 0.001 and 0.5 MPa, with a maximum flow rate of 6 L/min. By adjusting the voltage signal, precise control over the air pressure is enabled, which facilitates the actuation of pneumatic actuators that bend the robot’s legs for walking. The experimental control platform is shown in Fig. 8. The constant voltage power supply provides 24 V DC for the electric proportional valve and PLC. The pressure-reducing valve outputs high-pressure gas within the range required by the experiment and the gas is sent to the electric proportional valve through the air duct. The output from the S7-1215 PLC and an analog output module transmit the PID controller’s signal to the electric proportional valve. Voltage changes control the air intake, which in turn alters the bending angle of the soft actuator, thereby enabling the robot’s leg to walk.

Fig. 8
figure 8

Experimental control platform.

Control model calibration

The relationship between valve voltage and air pressure in the electrical proportional valve exemplifies the valve’s characteristics. The voltage is directly proportional to the pressure within the voltage range of 0.2 V to 3 V. Within this range, seven distinct voltage values were chosen. For each setting, three sets of soft actuator angle data were collected and averaged as shown in Fig. 9. A model in Eq. (23) was fitted to describe the relationship between valve voltage and actuator bending angle.

$$y=40.67x+8.134$$
(23)
Fig. 9
figure 9

Calibration between valve voltage and actuator bending angle.

The resulting model, with a determination coefficient of 0.998, demonstrates a highly linear relationship between valve voltage and the bending angle of the soft actuator. This finding is consistent with the walking control model described in Section “Structure and control model”. Based on these empirical findings, we derived the corresponding transfer function using the principle of system identification through an actual experiment. The experiment includes three primary components: data collection, structure selection, and validation. A total of 4000 data samples were collected at a frequency of 50 Hz. The input signals were the valve voltages, and the output signals were the angles measured by the bending sensor at valve voltages of 1.5 V, −  1.5 V, 2.5 V, and − 2.5 V depicted in Fig. 10. The acquired data were divided into two sets for identification and validation. The model structure employed for system identification was the N4SID (Numerical algorithms for Subspace State Space System Identification) model37,38. The output curve, confirmed through multiple validations, achieved a good fit accuracy of 98.01%. The established transfer function is as follows.

$$G(s)=\frac{{ - 0.7852{s^2}+4.4297s+1.2101}}{{{s^3}+0.9028{s^2}+0.3712s+0.0360}}$$
(24)

The zero poles shown in Fig. 11 are all located in the left half plane of S, confirming the system’s stability. Because the fit accuracy exceeds 90% and the system is stable. the transfer function’s control performance can serve as the objective function for the genetic algorithm.

Fig. 10
figure 10

Data collection during system identification process.

Fig. 11
figure 11

Zero pole of the system.

Gait planning and control requirements

The soft quadruped robot model was designed using SolidWorks. Its components were fabricated via 3D printing technology and were subsequently assembled. To realize the dynamic walking of the soft quadruped robot, gait planning is essential. This process entails designing the movements and sequences of the four legs to alternately support, lift, and step, thereby facilitating forward movement and ensuring stability throughout the motion. We adopted a diagonal walking gait, as illustrated in Fig. 12a. The initial gait positions legs 1 and 4 at a 60° bend, while legs 2 and 3 are positioned at -30°. In the second phase, legs 1 and 4 remain unchanged, while legs 2 and 3 are adjusted to 0°. The third phase alters the positions of legs 1 and 4 to -30° and legs 2 and 3 to 60°. In the fourth phase, legs 1 and 4 are set at 0°, with legs 2 and 3 remaining unchanged. This sequence continues in a similar sequence to facilitate the robot’s walking motion. Figure 12b presents the designed continuous gait curves for the two sets of diagonal legs, which correspond to the designed gait. Figure 12c illustrates the actual walking gait, where the front leg is represented in white and the back leg in orange.

The control requirements are as follows: High precision tracking: The robot should maintain minimal error with the target path; Response speed: The system should quickly respond to trajectory changes, especially during sharp directional shifts; Stability: The control system should remain stable under external disturbances or environmental changes, avoiding significant oscillations or deviations; Robustness: The system should be capable of maintaining good performance under different tasks and environmental conditions.

Fig. 12
figure 12

Gait planning of the actual soft robot.

Comparative experimental analysis

After the theoretical gait planning was completed, the control of the quadruped soft robot was managed by three PID controllers. These controllers were tuned using a genetic algorithm (GA-PID), and the outcomes were subsequently compared with those from a traditionally tuned ZN-PID controller and PSO-PID. Figure 13a illustrates the local tracking trajectory of the controller. The GA-PID controller demonstrates a smaller overshoot and quickly keeps up with the set value during the tracking process, exhibiting a smaller steady-state error. Even when compared to the PSO optimization method, the GA-PID still shows improved performance. Figure 13b,c compares the error by three type controllers in the process of tracking angles of 60 degrees and 30 degrees. The GA-PID can quickly reach the set value during the initial process, while the ZN-PID and PSO-PID controller has a large delay. This is because the complex hardware control system introduces many kinds of delay effects in walking control. Delays arise from multiple sources, including the data acquisition card, which transmits bending sensor data back to the computer, and the slow inflation and deflation of the soft actuator. Consequently, the GA-PID provides superior real-time adjustment capabilities, which can improve the control performance.

The results of multiple experiments demonstrate that the GA-PID controller significantly enhances the soft robot’s walking control performance, as detailed in Table 2. Specifically, the speed increases from 5 mm/s with the ZN-PID controller to 8 mm/s using the GA-PID. Moreover, the implementation of the proposed method resulted in a decrease in the PID controller’s error rates from 8.1827 to 5.7763%. Additionally, there is a respective reduction in overshoot of 12.55% and 23.56% when compared to the ZN-PID controller during the tracking of 60° and 30° giants. Furthermore, the stabilization time is expedited by 6.5 s and 3.4 s respectively. Compared to the PSO tuning method, the GA-PID demonstrates superior control performance. It reduces the tracking error rate by 0.4079%, decreases overshoot by 8.4% and 1.34% during the tracking of 60° and 30° targets, respectively. Apperantly, it shortens the steady-state time by 34.8 s and 56.8 s, showing significant improvement in stability. Therefore, the global search capabilities of the genetic algorithm can rapidly fine-tune and optimize the parameters of the PID controller, offering significant time-saving over the Ziegler-Nichols method and PSO method. More importantly, three key metrics including error rate, overshoot, and response speed show significant improvement under the GA-PID controller in the practical control system. The control signal is shown in Fig. 14.

Fig. 13
figure 13

Tracking trajectory performance comparison.

Fig. 14
figure 14

Control signal.

Table 2 Walking control performance comparision.

In our experimental design, we conducted nearly 30 trials to ensure sufficient statistical support and reproducibility of the results. In each trial, we randomly generated initial parameters to account for system variability and ensure the robustness of the algorithm under different initial conditions. As shown in Fig. 15, the GA-PID algorithm has more concentrated errors, with a median close to zero and smaller fluctuations, demonstrating the most stable tracking performance. In contrast, the PID and PSO-PID algorithms show a wider error distribution with more outliers, especially PSO-PID, which exhibits larger positive errors in certain cases. Although the overall tracking performance of PID and PSO-PID is also good, their error fluctuations are larger under certain conditions, making them less stable than GA-PID.

Fig. 15
figure 15

Box plot of tracking error distribution.

Conclusion

This paper presents a simplified control model for a newly designed soft robot, leveraging a unique structural design and innovative sensor. More importantly, the primary contribution of this research is the practical application of genetic algorithms in designing a PID controller for the soft quadruped robot. This approach introduces a workable method to optimize the PID controller in the field of soft robot, thereby enhancing the robot’s locomotion capabilities. Additionally, the proposed method improves comprehensive controller performance by enhancing system responsiveness and reducing both steady-state and dynamic errors comparing to the particle swarm optimization and traditional method. The effectiveness of our method is well illustrated by both theoretical simulation and multiple experiments.

Soft robots have broad applications in fields such as healthcare, agriculture, and exploration, including medical surgical robots, environmental monitoring robots, and flexible gripper robots. Since soft robots often operate in complex and uncertain environments, the global search and adaptive capabilities of GA-PID can address various unknown challenges, enhancing control accuracy. However, there are still challenges in real-world scenarios: (1) Computational complexity: In dynamic environments, GA-PID may have a high computational load, particularly in real-time control, which could become a bottleneck; (2) Hardware implementation difficulty: Sensor noise, actuator response speed, and environmental changes may affect actual control performance; (3) Adapting to different types of soft robots: Different driving mechanisms (such as pneumatic, hydraulic, or shape memory alloys) may require adjustments to model parameters or optimization algorithms. Although this method has been proven effective in the laboratory, further adjustments may be needed for real-world applications to enhance its adaptability and robustness. Future work will focus on addressing these issues.