## 4 The Control Algorithm for a Hydraulic Quadruped Robot  
### Centroid Control in Touchdown Stage  
Under the ideal conditions, while the robot moves in a pacing gait, the pitch angle and yaw angle of the trunk are zero, and the attitude angles can be measured by the IMU in real time. The control of hydraulic quadruped robots is easier when they are equipped with a set of virtual elements: a spring and damping. Those virtual actuators allow us to ignore the non-linearity due to the legs [41; 42]. Three sets of virtual elements can control the rolling angle, pitching angle and height of the trunk, respectively. For the sake of simplicity, we ignore the inertial force of the legs, hence the relationship between joint torque and generalized force acting on the trunk can be expressed as:  
\[\tau=-\mathbf{J}^{T}\mathbf{F} \tag{20}\]  
where \(\mathbf{\tau}=[\tau_{1}\ \tau_{2}\ \tau_{3}]^{\mathrm{T}}\) is the vector of joint output torque. \(\tau_{1}\), \(\tau_{2}\) and \(\tau_{3}\) represent rolling hip joint torque, pitching hip joint torque and pitching knee joint torque, respectively. \(\mathbf{F}=[F_{x}\ F_{y}\ F_{z}]^{\mathrm{T}}\) is the vector of generalized force. \(F_{x}\), \(F_{y}\) and \(F_{z}\) represent the virtual force of the landing leg acting on the robot trunk along x, y and z axes. According to the force analysis, the mapping of the moment of the landing leg acting on the robot trunk \(\mathbf{T}=[T_{x}\ T_{y}\ T_{z}]^{\mathrm{T}}\) to the joint torque is as follows:  
\[\left[ \begin{array}{c}T_{x}\\ T_{y}\\ T_{z}\end{array} \right]=\left[ \begin{array}{ccc}-1&0&0\\ 0&-c_{1}&-c_{1}\\ 0&s_{1}&s_{1}\end{array} \right]\left[ \begin{array}{c}\tau_{1}\\ \tau_{2}\\ \tau_{3}\end{array} \right] \tag{21}\]  
Combining Equations (11), (20) and (21), we get a set of simplified equations:  
\[\mathbf{F}\mathbf{T}=\left[ \begin{array}{c}\mathbf{F}\\ \mathbf{F}_{y}\\ \mathbf{F}_{z}\\ T_{x}\\ T_{y}\\ T_{z}\end{array} \right]=\left[ \begin{array}{c}0&-s_{23}/(l_{2}s_{3})&(l_{2} s_{2}+l_{3}s_{23})/(l_{2}l_{3}s_{3})\\ -c_{1}/(l_{1}+l_{2}c_{2}+l_{3}c_{23})&-s_{1}c_{23}/(l_{2}s_{3})&s_{1}(l_{2}c_{2 }+l_{3}c_{23})/(l_{2}l_{3}s_{3})\\ -s_{1}/(l_{1}+l_{2}c_{2}+l_{3}c_{23})&c_{1}c_{23}/(l_{2}s_{3})&-c_{1}(l_{2}c_{2 }+l_{3}c_{23})/(l_{2}l_{3}s_{3})\\ -1&0&0\\ 0&-c_{1}&-c_{1}\\ 0&s_{1}&s_{1}\end{array} \right]\left[ \begin{array}{c}\tau_{1}\\ \tau_{2}\\ \tau_{3}\end{array} \right] \tag{22}\]Let  
\[\mathbf{J}_{FT}=\left[ \begin{array}{cccc}0&-s_{23}/\left(l_{253}\right)&\left(l_{2 5}l_{2}+l_{3}s_{23}\right)/\left(l_{2}l_{353}\right)\\ -c_{1}/\left(l_{1}+l_{2}c_{2}+l_{3}c_{23}\right)&-s_{1}c_{23}/\left(l_{2}s_{3} \right)&s_{1}\left(l_{2}c_{2}+l_{3}c_{23}\right)/\left(l_{2}l_{35}s_{3}\right) \\ -s_{1}/\left(l_{1}+l_{2}c_{2}+l_{3}c_{23}\right)&c_{1}c_{23}/\left(l_{2}s_{3} \right)&-c_{1}(l_{2}c_{2}+l_{3}c_{23})/\left(l_{2}l_{353}\right)\\ -1&0&0\\ 0&-c_{1}&-c_{1}\\ 0&s_{1}&s_{1}\end{array} \right] \tag{23}\]  
The virtual force and moment of two landing legs acting on the robot trunk can be expressed as:  
\[\mathbf{F}\mathbf{T}_{FH}=\left[ \begin{array}{c}\mathbf{F}\mathbf{T}_{F}\\ \mathbf{F}\mathbf{T}_{H}\end{array} \right]=\left[ \begin{array}{c}\mathbf{F}_{F}\\ \mathbf{T}_{F}\\ \mathbf{F}_{H}\\ \mathbf{T}_{H}\end{array} \right]=\left[ \begin{array}{cc}\mathbf{J}_{FT_{F}}&\mathbf{0} _{6\times 3}\\ \mathbf{0}_{6\times 3}&\mathbf{J}_{FT_{H}}\end{array} \right]\left[ \begin{array}{c}\mathbf{ \tau}_{F}\\ \mathbf{\tau}_{H}\end{array} \right] \tag{24}\]  
where \(\mathbf{F}\mathbf{T}_{FH}=[F_{Fx}\,F_{Fy}\,F_{Fz}\,T_{Fx}\,T_{Fy}\,T_{Fz}\,F_{Hx}\,F_{Hy }\,F_{Hz}\,T_{Hx}\,T_{Hy}\,T_{Hz}]^{\mathsf{T}}\), in which, the subscript \(F\) denotes the foreleg, and the subscript \(H\) denotes the hind leg. The vector of virtual force and moment acting on the centroid of the trunk can be obtained by the vector of generalized force and torque, hence \(\mathbf{F}\mathbf{T}_{b}=[F_{bx}\,F_{by}\,F_{bz}\,T_{bx}\,T_{by}\,T_{bz}]^{\mathsf{T}}\) can be written as:  
\[\left\{