# Leg Trajectory Planning for Quadruped Robots with High-Speed Trot Gait
## 2 Materials and Methods
### Leg Trajectory Planning
#### 2.4.2. Swing Phase Trajectory Design  
The objective of the swing phase trajectory design is to protract the leg with enough ground clearance for avoiding obstacles and to have desirable swing leg retraction rate for reducing energy losses of running during touch down motion [24]. Consider that the leg is not affected by environmental forces so it can achieve higher speed and acceleration. Therefore, the period of the swing phase \(T_{sw}\) is defined as 0.25 s, calculated according to the maximum rotation speed of motors. Two schemes of the trajectory in the swing phase are proposed based on the spline curve and Bezier curve respectively. Scheme I: Trajectory design with spline curve  
The basic principle of this scheme is to minimize the maximum acceleration of legs as much as possible during the swing phase and ensure the continuity of position, speed, and acceleration. The planning trajectory is shown in Figure 11 with four increased velocities. In order to avoid the high order polynomial trajectory planning, the trajectory in the swing phase is divided into 0 to \(0.5T_{SW}\) and \(0.5T_{SW}\) to \(T_{SW}\) in the X direction. During 0 to \(0.5T_{SW}\), for guaranteeing the touch-down and leave-off points between the swing phase and stance phase have better smoothness, it is necessary to ensure the position, speed, and acceleration continuously, which are given by Equations (14), (15), and (16):  
\[S_{SW,x}\mathrm{l}_{SW=0}=S_{ST,x}\mathrm{l}_{\mathrm{s}=T_{ST}} \tag{14}\]  
\[\frac{\mathrm{d}S_{SW,x}}{\mathrm{d}t_{SW}}\mathrm{l}_{\mathrm{s}=0}=\frac{dS_ {ST,x}}{dt_{ST}}\mathrm{l}_{\mathrm{s}=T_{ST}} \tag{15}\]  
\[\frac{\mathrm{d}^{2}S_{SW,x}}{\mathrm{d}t_{SW}^{2}}\mathrm{l}_{\mathrm{s}=0}= \frac{\mathrm{d}^{2}S_{ST,x}}{\mathrm{d}t_{ST}^{2}}\mathrm{l}_{\mathrm{s}=T_{ ST}} \tag{16}\]  
Similarly, for ensuring the acceleration changes slightly and smoothly in the X direction and limiting the trajectory length of the swing phase to be appropriate, the time reaching zero velocity, \(T_{SW,V_{SW,x=0}}\), which is a variable parameter with \(V_{desire}\), should be limited by Equation (17):  
\[\frac{\mathrm{d}S_{SW,x}}{\mathrm{d}t_{SW}}\mathrm{l}_{\mathrm{s}_{SW}=T_{SW,V_{SW,x}-0}}=0 \tag{17}\]  
In the X direction, the trajectory is in the acceleration stage before \(0.5T_{SW}\), and then in the deceleration stage. At the time of \(0.5T_{SW}\), in order to ensure that the acceleration is small and continuous between the two stages, the acceleration and position should be zero, which are given by Equations (18) and (19):  
\[S_{SW,x}\mathrm{l}_{\mathrm{s}_{SW}=\frac{1}{2}T_{SW}}=0 \tag{18}\]  
\[\frac{\mathrm{d}^{2}S_{SW,x}}{\mathrm{d}t_{SW}^{2}}\mathrm{l}_{\mathrm{s}= \frac{1}{2}T_{SW}}=0 \tag{19}\]  
From Equations (14) to (19) above, the five-order spline curves in the direction of \(X\) can be fitted from 0 to \(0.5T_{SW}\), and the curves between \(0.5T_{SW}\) and \(T_{SW}\) are obtained symmetrically. The trajectory in the Y direction is also divided into two parts: 0 to \(0.5T_{SW}\) and \(0.5T_{SW}\) to \(T_{SW}\). It is also necessary to ensure that the position, velocity, and acceleration are continuous at the moment connecting the stance phase and swing phase in the part of 0 to \(0.5T_{SW}\), which are given by Equations (20)-(22):  
Figure 11: The spline curve trajectory.