Gait Planning and Stability of a Biped Humanoid Robot

Biped humanoid robots, also known as humanoid robots, have attracted extensive research interest because of their human-like appearance and anthropomorphic motion capabilities. Over the past four decades, the field has advanced rapidly, and these robots are expected to play a significant role in future applications such as service, education, and entertainment. However, the fundamental challenge remains to achieve stable bipedal locomotion in unstructured environments. In my research, I designed and implemented a biped humanoid robot named ROBOT-Ⅰ, and conducted in-depth studies on its gait planning and stability control. This article presents the kinematic modeling, model-based gait planning and optimization, and sensor-based feedback stability control for an embodied robot.

The most significant feature of a biped humanoid robot is its ability to walk with a human-like gait, which gives it a distinct advantage in real-world environments. Nevertheless, to enable the many complex functions of a humanoid robot, it is essential to first guarantee walking stability. Therefore, research on gait planning and stability for biped humanoid robots is of great importance.

In my work, I focused on the model-based gait planning and optimization of the ROBOT-Ⅰ humanoid robot, as well as its stability control based on posture detection. Starting from the kinematic modeling of the biped humanoid robot, I performed gait planning and walking pattern generation. I also employed an inertial measurement unit (IMU) composed of a gyroscope and an accelerometer to detect the robot’s posture information, and introduced a feedback control unit that corrects the offline planned gait online, thereby improving the robot’s adaptability to the environment. Furthermore, considering that offline planning methods cannot modify the planning method itself in real time, I proposed an improved extreme-value optimization-based gait planning method. The ankle trajectory is obtained by polynomial fitting based on the key positions of the ankle joint during walking. Then, combined with the planned zero moment point (ZMP) trajectory and constraints on the hip joint, the hip trajectory is planned using an optimization approach. This yields the complete gait pattern over a full walking cycle. To improve the speed of online planning, I also made improvements to the optimization method. Simulation and experimental results demonstrate the feasibility and effectiveness of the proposed gait planning algorithm.

1. Design of the ROBOT-Ⅰ Biped Humanoid Robot

The design of a biped humanoid robot directly affects its control scheme and locomotion capability. ROBOT-Ⅰ was designed with a height of 45 cm and a mass of 1.7 kg. It can perform forward walking, backward walking, turning, side stepping, squatting, and single-leg standing, as well as extended functions such as dancing, playing soccer, and performing motion protection. In this section, I describe the overall design, degrees of freedom (DOF) configuration, actuator selection, sensors, and control system of the robot. These aspects form the physical basis for the kinematic and dynamic modeling presented later.

1.1 Overall Parameters and Degrees of Freedom

Table 1 lists the basic design parameters of ROBOT-Ⅰ. The robot is powered by an 8.4 V battery, and its main control unit is an LPC1768 microcontroller. The robot has a total of 17 degrees of freedom.

Parameter Value
Height 45 cm
Width 23.5 cm
Depth 14.5 cm
Mass 1.7 kg
Power supply 8.4 V DC
Degrees of freedom 17
Main controller LPC1768

The DOF configuration is crucial for reproducing human-like motions. ROBOT-Ⅰ has 3 DOF in each arm, 5 DOF in each leg, and 1 DOF in the neck. The leg DOFs are arranged as follows: two DOF at the hip (pitch and roll), one DOF at the knee (pitch), and two DOF at the ankle (pitch and roll). This configuration allows the robot to walk in three-dimensional space while maintaining balance. The joints are driven by custom-designed servo motors that provide high precision and are easy to control.

1.2 Actuator and Sensor Configuration

The driving modes for humanoid robots include hydraulic actuation, pneumatic artificial muscles, and servo motors. After comparing these options, I chose servo motors because of their low cost, ease of maintenance, precise control, and self-contained energy source. The servo motors are placed coaxially with the joints to simplify the mechanical structure and improve control accuracy. Each motor integrates a potentiometer that returns the joint angle, providing local feedback.

For posture sensing, ROBOT-Ⅰ is equipped with an MPU6050 sensor, which combines a tri-axial gyroscope and a tri-axial accelerometer in a single package. The advantage of this integrated solution is that there is no time skew between the gyroscope and accelerometer data. The gyroscope outputs angular velocity, while the accelerometer outputs linear acceleration. By fusing these data, I can obtain the orientation of the robot’s torso in real time.

1.3 Control System Architecture

The control system of ROBOT-Ⅰ is composed of four parts: the sensor layer, the main control layer, the coordination layer, and the bottom-level driver. Sensors collect both internal states and external information. The main control layer performs task scheduling and decision making based on the planned tasks and the real-time sensor data. The coordination layer handles communication between the main controller and the drivers. The bottom-level drivers execute the joint commands sent by the main controller and read joint angles from the sensors.

In the main control system, after the uC/OS real-time operating system starts, a main task is created. This task initializes the system and creates three sub-tasks: Task 1 handles task scheduling and battery monitoring, Task 2 executes actions such as walking and dancing, and Task 3 performs posture estimation and stability control. This multi-task architecture allows the robot to perform complex behaviors while maintaining stability.

2. Kinematic Modeling of ROBOT-Ⅰ

Kinematic modeling is the foundation for designing walking control strategies and analyzing stability. Biped walking is a hybrid process: it involves both continuous dynamics and discrete events, and it alternates between open-chain structures during single support and closed-chain structures during double support. Therefore, a mathematical representation that can encompass these different constraints is necessary.

I modeled ROBOT-Ⅰ as a rigid-link system. Given the robot’s DOF configuration, I abstracted the robot into an 11-link model. The links are connected by joints that rotate around a single axis. I assumed that all body parts are rigid and that the multiple rotation axes at a common joint intersect at a point. This abstraction is reasonable for a small humanoid robot and greatly simplifies the analysis.

2.1 Coordinate Frames and Link Parameters

I define a fixed reference frame $\{w\}$ attached to the ground, with its $x$-axis pointing forward, its $z$-axis pointing upward, and its $y$-axis determined by the right-hand rule. For each link, I attach a local coordinate frame following the Denavit–Hartenberg (DH) convention. Figure 2 illustrates the link model with the coordinate frames assigned to each link. The link parameters for the right leg are summarized in Table 2.

Link $i$ $a_{i-1}$ $\alpha_{i-1}$ $d_i$ $\theta_i$
1 0 0 0 $\theta_1$
2 $l_1$ $-90^\circ$ 0 $\theta_2$
3 $l_2$ 0 0 $\theta_3$
4 $l_3$ 0 0 $\theta_4$
5 $l_4$ $90^\circ$ 0 $\theta_5$

The general homogeneous transformation matrix from frame $i-1$ to frame $i$ is given by:

$$
\begin{bmatrix}
\cos\theta_i & -\sin\theta_i & 0 & a_{i-1} \\
\sin\theta_i \cos\alpha_{i-1} & \cos\theta_i \cos\alpha_{i-1} & -\sin\alpha_{i-1} & -d_i \sin\alpha_{i-1} \\
\sin\theta_i \sin\alpha_{i-1} & \cos\theta_i \sin\alpha_{i-1} & \cos\alpha_{i-1} & d_i \cos\alpha_{i-1} \\
0 & 0 & 0 & 1
\end{bmatrix}
$$

2.2 Forward Kinematics

Using the DH parameters, I derived the forward kinematics of the robot. The transformation from the base frame to the foot frame is obtained by multiplying the individual link transformations. For example, for the right leg, the transformation matrix $T_5^0$ is:

$$
T_5^0 = T_1^0 \cdot T_2^1 \cdot T_3^2 \cdot T_4^3 \cdot T_5^4
$$

Each $T_i^{i-1}$ is computed from the DH parameters. By expanding the product, I obtain the position and orientation of the foot with respect to the hip frame. During normal walking, I assume that the torso remains upright and that the foot remains flat on the ground. These assumptions simplify the kinematic analysis and are commonly used in bipedal walking.

2.3 Inverse Kinematics

Inverse kinematics is essential for converting a desired Cartesian trajectory into joint angle commands. The inverse kinematic problem can be divided into two subproblems: (1) given the pose of the support foot relative to the pelvis, find the support leg joint angles; and (2) given the pose of the swing foot relative to the pelvis, find the swing leg joint angles. Both subproblems share the same solution procedure. In the following, I describe the solution for the support leg.

Assuming that the robot’s waist remains horizontal during walking and the foot stays flat on the ground, I have:

$$
\theta_1 + \theta_5 = 0
$$

$$
\theta_2 + \theta_3 + \theta_4 = 0
$$

Given the desired pose ${}^0 T_5$ of the right foot in the waist frame, I multiply both sides of the forward kinematics equation by ${}^0 T_1^{-1}$ to obtain:

$$
T_5^1 = {}^0 T_1^{-1} \cdot {}^0 T_5
$$

Then, by comparing the elements of the resulting matrix, I can solve for the joint angles. For instance, the angle $\theta_1$ is obtained from the (2,1) element:

$$
\theta_1 = \arcsin\left(r_{21}\right)
$$

Similarly, the other joint angles are computed. The same procedure is applied to the left leg by replacing the link parameters. These analytical solutions are efficient and suitable for real-time control.

3. Gait Planning for Biped Humanoid Robots

Gait planning is the process of determining the joint angle trajectories that allow the robot to walk stably. The goal is to generate a walking pattern that satisfies both kinematic constraints and dynamic stability criteria. In this section, I first introduce the ZMP stability criterion, which is the most widely used stability measure for biped robots. Then, I describe a gait planning method based on the three-dimensional linear inverted pendulum model (3D-LIPM). Finally, I present an improved gait planning method based on extreme-value optimization.

3.1 ZMP Stability Criterion

The Zero Moment Point (ZMP) is defined as the point on the ground where the resultant moment of the robot’s gravity, inertia, and ground reaction forces is zero. If the ZMP lies strictly inside the convex hull of the support polygon, the robot is dynamically stable. If the ZMP lies outside this region, the robot may tip over. For biped walking, the ZMP criterion is a sufficient but not necessary condition for stability. It provides a convenient way to guide the gait design.

For a system of particles, the ZMP coordinates are computed as:

$$
x_{\mathrm{zmp}} = \frac{\sum_{i=1}^n m_i \left( (z_i – z_{\mathrm{zmp}}) \ddot{x}_i + (\ddot{z}_i + g) x_i \right)}{\sum_{i=1}^n m_i (\ddot{z}_i + g)}
$$

$$
y_{\mathrm{zmp}} = \frac{\sum_{i=1}^n m_i \left( (z_i – z_{\mathrm{zmp}}) \ddot{y}_i + (\ddot{z}_i + g) y_i \right)}{\sum_{i=1}^n m_i (\ddot{z}_i + g)}
$$

In practice, when using a simplified model, the robot is represented by a single concentrated mass at the center of mass (CoM). The ZMP is then related to the CoM acceleration by:

$$
x_{\mathrm{zmp}} = x_{\mathrm{com}} – \frac{z_{\mathrm{com}}}{g} \ddot{x}_{\mathrm{com}}
$$

$$
y_{\mathrm{zmp}} = y_{\mathrm{com}} – \frac{z_{\mathrm{com}}}{g} \ddot{y}_{\mathrm{com}}
$$

These equations are the basis for many gait generation algorithms.

3.2 Gait Planning Based on the 3D Linear Inverted Pendulum Model

The 3D-LIPM abstracts the robot as a point mass located at the CoM, connected to a massless leg that can telescope and pivot around the ground contact point. If the CoM is constrained to move on a horizontal plane, the dynamics become linear. This model captures the essential relationship between the CoM and the ZMP without needing to account for all link details.

In my implementation, I assumed the CoM height is constant during walking. The equations of motion are:

$$
\ddot{x}_{\mathrm{com}} = \frac{g}{z_{\mathrm{com}}} (x_{\mathrm{com}} – x_{\mathrm{zmp}})
$$

$$
\ddot{y}_{\mathrm{com}} = \frac{g}{z_{\mathrm{com}}} (y_{\mathrm{com}} – y_{\mathrm{zmp}})
$$

Given a desired ZMP trajectory, I solved these differential equations to obtain the CoM trajectory. The planning strategy is as follows: during single support, keep the ZMP at the origin of the support foot; during double support, smoothly move the ZMP from the rear foot origin to the front foot origin. By connecting these segments with appropriate boundary conditions, I generated a periodic walking pattern.

After obtaining the CoM trajectory, I used the inverse kinematic model to compute the joint angle trajectories. For a step height of 1.5 cm, a walking period of 0.8 s, and a step length of 4 cm, I calculated the joint angles and angular velocities. The resulting joint angle profiles are continuous and smooth, with no step discontinuities. The maximum angular velocity was below 3 rad/s, which is within the capability of the servomotors. This gait pattern was implemented and tested on ROBOT-Ⅰ. The robot was able to walk, but the walking was not very stable and occasionally led to falls. This motivated the development of a more robust gait planning method.

3.3 Improved Gait Planning via Extreme-Value Optimization

Offline gait planning has the limitation that it cannot modify the planning method itself in real time. To address this problem, I proposed an improved gait planning method based on extreme-value optimization. The idea is to first fit the ankle trajectory using polynomials, then combine the planned ZMP trajectory with hip constraints to optimize the hip trajectory.

For the swing leg, the ankle position $\left(x_h(t), z_h(t)\right)$ is represented by polynomials:

$$
x_h(t) = \sum_{i=0}^5 h_i^x t^i
$$

$$
z_h(t) = \sum_{i=0}^4 h_i^z t^i
$$

The polynomial coefficients are determined from the boundary conditions: the ankle starts at the initial position, reaches a maximum height at a specified time, and then lands at the final position. Additionally, I require that the vertical and horizontal velocities of the ankle at the start and the end be zero to reduce ground impact:

$$
\dot{x}_h(0) = 0, \quad \dot{x}_h(T) = 0
$$

$$
\dot{z}_h(0) = 0, \quad \dot{z}_h(T) = 0
$$

For the ZMP trajectory, I used the same strategy as in the previous section. Then, the hip trajectory is planned by solving an optimization problem. Let the left and right ankle trajectories be denoted by $\left(x_{hL}, z_{hL}\right)$ and $\left(x_{hR}, z_{hR}\right)$. The hip position $\left(x_k, z_k\right)$ must satisfy:

$$
x_k \in [x_{\min}, x_{\max}], \quad z_k \in [z_{\min}, z_{\max}]
$$

The objective is to minimize the difference between the actual ZMP computed from the robot model and the desired ZMP:

$$
\min \left| x_{\mathrm{zmp}}^{\mathrm{actual}} – x_{\mathrm{zmp}}^{\mathrm{desired}} \right|
$$

This optimization is performed at every sampling instant. Since the hip position is bounded, an efficient search can be conducted. I used gradient descent with a dynamically adjusted step size to speed up convergence. The search stops when the error between the actual and desired ZMP is within a tolerance.

I implemented this algorithm in simulation. The computed ZMP trajectory closely matches the desired ZMP trajectory, with a maximum error of 0.3236 cm, a minimum error of 0.0094 cm, a mean error of 0.1651 cm, and a variance of 0.011. These results demonstrate the feasibility of the proposed method. The optimization also runs fast enough to be used for online planning.

4. Stability Control Based on Posture Detection

Biped humanoid robots are inherently nonlinear and unstable systems. Even if a theoretically stable gait is planned, external disturbances and model errors can cause the robot to lose balance. Therefore, feedback control is necessary to improve the robot’s adaptability. In this section, I describe the attitude estimation method and the feedback controllers implemented on ROBOT-Ⅰ.

4.1 Attitude Representation and Estimation

The attitude of the robot is described by Euler angles: yaw $\psi$, pitch $\theta$, and roll $\phi$. The transformation from the world frame to the body frame can be expressed as a rotation matrix:

$$
R = R_z(\psi) R_y(\theta) R_x(\phi)
$$

The rotation matrix can also be computed from the gyroscope and accelerometer data. However, using Euler angles involves many trigonometric operations, which can slow down real-time computation. To avoid this issue and the singularity at pitch angles near ±90°, I used quaternion representation.

A quaternion is defined as:

$$
q = q_0 + q_1 i + q_2 j + q_3 k
$$

where $q_0^2 + q_1^2 + q_2^2 + q_3^2 = 1$. The rotation matrix in terms of quaternions is:

$$
R(q) =
\begin{bmatrix}
1 – 2(q_2^2 + q_3^2) & 2(q_1 q_2 – q_0 q_3) & 2(q_1 q_3 + q_0 q_2) \\
2(q_1 q_2 + q_0 q_3) & 1 – 2(q_1^2 + q_3^2) & 2(q_2 q_3 – q_0 q_1) \\
2(q_1 q_3 – q_0 q_2) & 2(q_2 q_3 + q_0 q_1) & 1 – 2(q_1^2 + q_2^2)
\end{bmatrix}
$$

The quaternion is updated by solving the differential equation:

$$
\dot{q} = \frac{1}{2} \Omega(\omega) q
$$

where $\Omega(\omega)$ is the skew-symmetric matrix of the angular velocity $\omega = (\omega_x, \omega_y, \omega_z)$:

$$
\Omega(\omega) =
\begin{bmatrix}
0 & -\omega_x & -\omega_y & -\omega_z \\
\omega_x & 0 & \omega_z & -\omega_y \\
\omega_y & -\omega_z & 0 & \omega_x \\
\omega_z & \omega_y & -\omega_x & 0
\end{bmatrix}
$$

I used a first-order Runge-Kutta method to integrate this equation in real time. The angular velocity is obtained from the gyroscope, while the accelerometer data are used to correct drift through a complementary filter. This approach provides accurate and computationally efficient attitude estimation.

4.2 Torso Posture Controller

The torso posture controller maintains the robot’s upper body upright during walking. Since the hip joints are close to the torso, adjusting the support leg’s hip angle is the most effective way to correct torso inclination. The control law is:

$$
\theta_{\mathrm{hip}} = K_{p1} ( \theta_{\mathrm{desired}} – \theta_{\mathrm{actual}} ) + K_{d1} ( \dot{\theta}_{\mathrm{desired}} – \dot{\theta}_{\mathrm{actual}} )
$$

where $\theta_{\mathrm{desired}}$ is the desired torso pitch angle, and $\theta_{\mathrm{actual}}$ is the measured torso pitch angle. The gains $K_{p1}$ and $K_{d1}$ are tuned experimentally. This controller significantly reduces the torso tilt error during walking.

4.3 ZMP Compensator

The ZMP compensator adjusts the ankle joint of the support leg to keep the actual ZMP close to the desired ZMP. Although ROBOT-Ⅰ does not have dedicated ZMP sensors, I computed the actual ZMP from the robot’s joint angles and posture data. The control law is:

$$
\theta_{\mathrm{ankle}} = K_{p2} ( x_{\mathrm{zmp}}^{\mathrm{desired}} – x_{\mathrm{zmp}}^{\mathrm{actual}} ) + K_{d2} ( \dot{x}_{\mathrm{zmp}}^{\mathrm{desired}} – \dot{x}_{\mathrm{zmp}}^{\mathrm{actual}} )
$$

This compensator is especially effective during the single support phase when the ZMP is near the edge of the stability region.

4.4 Experimental Results

I conducted walking experiments on ROBOT-Ⅰ to validate the feedback controllers. The torso pitch angle was recorded with and without the posture controller. Table 3 lists the statistical errors between the desired and actual torso pitch angles.

Condition Maximum error (rad) Mean error (rad) Variance
Before control 0.2156 0.0762 0.0043
After control 0.0702 0.0241 0.0003

Table 4 shows the ZMP errors with and without the ZMP compensator.

Error metric Before control After control
X direction max (cm) 1.2000 1.0000
X direction mean (cm) 0.4800 0.2900
X direction variance 0.1640 0.1277
Y direction max (cm) 3.8000 2.5000
Y direction mean (cm) 1.0200 0.6400
Y direction variance 1.1796 0.9804

These results indicate that the feedback controller effectively reduces posture deviations and keeps the ZMP closer to the desired trajectory. In addition, I tested the robot’s response to disturbances. When a small disturbance was applied, the robot could adjust its steps to regain balance. When a large disturbance was applied, the robot executed a protective fall and was able to stand up again. These experiments demonstrate that the embodied robot with posture feedback control has stronger environmental adaptability.

Conclusion

In this research, I designed and implemented the biped humanoid robot ROBOT-Ⅰ and studied its gait planning and stability control. I established the kinematic model of the robot, including forward and inverse kinematic solutions. Based on the ZMP stability criterion, I used a three-dimensional linear inverted pendulum model to generate a basic walking pattern. To overcome the limitations of offline planning, I proposed an improved extreme-value optimization-based gait planning method that fits the ankle trajectory with polynomials and optimizes the hip trajectory under constraints. The resulting gait ensures that the actual ZMP closely follows the planned one. Furthermore, I developed a posture detection system based on a gyroscope and accelerometer, and implemented a torso posture controller and a ZMP compensator. Experimental results show that the feedback control significantly improves the walking stability of the embodied robot and enhances its adaptability to external disturbances.

Future work will focus on extending the gait planning to more complex environments, such as stairs and uneven terrain, and incorporating visual perception to achieve higher levels of autonomy. The principles and methods presented in this article provide a solid foundation for further development of robust and versatile humanoid robots.

Scroll to Top