## 2 System Modeling
### Legged Robot Modeling  
The hip and knee joints of the legged robot are the main research subjects. As shown in Figure 2, the reference coordinate system with origin point \(O_{0}\) is to be set at the center of the sun wheel of the decelerator in the hip joint. \(l_{1}\) is the straight-line distance between the center of the hip and the center of the knee, and \(l_{2}\) is the straight-line distance between the center of the knee joint and the end of the foot. \(\theta_{1}\) and \(\theta_{2}\) are the joint angles of the hip and knee joints (\(\theta_{1}>0,\theta_{2}<0\)). \(x_{0}\) is the horizontal distance of the foot end of the leg, and \(z_{0}\) is the vertical distance of the foot end of the leg. \(m_{1}\) and \(m_{2}\) are the masses of the thigh and calf parts, respectively. \(\tau_{1}\) and \(\tau_{2}\) represent the joint moments of the hip and knee joints, respectively. Based on the mobile base coordinate system, the foot-end position can be calculated as follows:  
\[ \begin{cases}x_{0}=-l_{1}sin(\theta_{1})-l_{2}sin(\theta_{1}+\theta_{2}),\\ z_{0}=-l_{1}cos(\theta_{1})-l_{2}cos(\theta_{1}+\theta_{2}).\end{cases}  \tag{1}\]  
According to the geometric characteristics of the simplified model, joint angles \(\theta_{1}\) and \(\theta_{2}\) can be obtained by the inverse kinematics of the leg:  
Figure 1: The composition of legged robots and the hybrid energy storage system. Batteries and supercapacitors are combined to drive the motors of the legged robot through two DC-AC inverters. \[ \begin{cases}\theta_{1}=\varphi-arctan(\frac{x}{2}),\\ \theta_{2}=arccos(\frac{l_{12}^{2}-l_{12}^{2}-l_{2}^{2}}{2l_{1}l_{2}})-\pi,\end{cases}  \tag{2}\]  
where \(\varphi\) is an angle solved by inverse kinematics, and \(l_{12}\) is the distance between the hip joint and the foot, defined as follows:  
\[ \begin{cases}\varphi=arccos(\frac{(l_{12}^{2}+l_{12}^{2}-l_{2}^{2})}{2l_{1}l_{ 12}}),\\ l_{12}=\sqrt{(l_{1}^{2}+l_{2}^{2})}.\end{cases}  \tag{3}\]  
According to Equation (1), the Jacobi matrix of the leg is calculated as  
\[J= \begin{bmatrix}-l_{1}cos(\theta_{1})-l_{2}cos(\theta_{1}+\theta_{2})&-l_{2} cos(\theta_{1}+\theta_{2})\\ l_{1}sin(\theta_{1}+l_{2}sin(\theta_{1}+\theta_{2})&l_{2}sin(\theta_{1}+\theta _{2})\end{bmatrix} . \tag{4}\]  
After solving for the kinematics of the leg, a dynamic model is developed to compute foot-end forces and joint moments. The Lagrange formula is used to express the energy storage of the leg and establish its dynamics for one complete motion cycle. Firstly, define a Lagrangian function \(L(q,\dot{q})\) based on the energy:  
\[L(q,q)=K(q,\dot{q})-P(q), \tag{5}\]  
where \(q\) is a set of independent coordinates called generalized coordinates to describe the bit shape of the system. \(K\) is the system kinetic energy, and \(P\) is the system's potential energy. Then, the equations of motion can be expressed in terms of Lagrangian functions. The torque \(\Gamma\) is calculated by Equation (6):  
\[\Gamma=\frac{d}{dt}\frac{\partial L}{\partial\dot{q}}-\frac{\partial L}{ \partial q}. \tag{6}\]  
The kinetic energy of the motor-driving legged robot is a quadratic function of the joint speed:  
\[ \begin{cases}K(q,\dot{q})=K_{1}(\theta,\dot{\theta})+K_{2}(\theta,\dot{\theta }),\\ K_{1}(\theta,\theta)=\frac{1}{2}m_{1}v_{1}^{2}+\frac{1}{2}ln_{1}\theta_{1}^{2},\\ K_{2}(\theta,\dot{\theta})=\frac{1}{2}m_{2}v_{2}^{2}+\frac{1}{2}ln_{2}(\theta_ {1}+\theta_{2})^{2},\end{cases}  \tag{7}\]  
Figure 2: Simplified model of the legged robot. The leg is simplified as a two-joint double-link system, and a frictional coordinate system for the single leg is established, with the hip joint as the origin. where \(In_{1}\) and \(In_{2}\) are the inertia tensor of the thigh and calf parts, respectively.