M.Sc. Thesis · 2022 · Humanoid Locomotion

Deep RL for walking control of a biped robot.

Teaching the Surena IV humanoid to walk in simulation by having reinforcement learning shape trajectories while classical kinematics handles the joints.

CAST, University of Tehran · Advisors: A. Yousefi-Koma, M. Shariat-Panahi

About this page. This is an English summary of my Master's thesis (University of Tehran, 2022); the full thesis is written in Persian. It covers the method, experiments, results, and limitations described in the original thesis.

The problem

A walking humanoid is high-dimensional, underactuated, and only touches the ground intermittently, so balance has to be actively maintained at every instant. Classical control solves this with reduced-order models and explicit balance criteria like the Zero-Moment Point, but each controller takes heavy, model-specific engineering. Reinforcement learning promises a model-light alternative, yet for a full-size humanoid the action space is large and balance is fragile, so naïve end-to-end learning struggles.

The main question is whether added structure can make RL more tractable for humanoid walking, instead of asking a network to learn joint-level coordination from scratch. The testbed is Surena IV, a full-size adult humanoid built at the Center of Advanced Systems and Technologies (CAST) at the University of Tehran. I simulated its URDF model in PyBullet and controlled twelve lower-body degrees of freedom (six per leg).

Surena IV humanoid robot in the PyBullet simulator
Surena IV in the PyBullet physics simulator, imported from its URDF model. The controller acts on the twelve lower-body joints: hip yaw/roll/pitch, knee pitch, and ankle pitch/roll on each leg.

Two control environments

I built two RL environments. The first is a baseline that commands the motors directly. The second reduces the action space by letting the agent shape trajectories, with classical inverse kinematics calculating the joint angles.

Environment 1 · Baseline

Direct motor control

The action type and number of joints can be changed while keeping the same reward.

policy → joint commands
(torque / position / velocity)
→ 10–12 actuators → simulator
Large action space

Environment 2 · Contribution

Hybrid trajectory control

The agent shapes trajectories, and analytic inverse kinematics produces the joint angles.

policy → Δ trajectory [Δx, Δy, Δz]
→ CoM & swing-foot paths
→ inverse kinematics → joints
Small action space

Instead of emitting ten-plus joint commands every step, the policy in Environment 2 outputs small increments [Δx, Δy, Δz] to the center-of-mass and swing-foot trajectories. The CoM path is built from an inverted-pendulum walking model (lateral sway set relative to the support foot, CoM height held near 0.7 m); the agent perturbs the CoM's x/y and the swing ankle's x/z, nudging the reference paths a classical planner would otherwise fix. A closed-form inverse-kinematics block for the Surena IV leg turns the desired pelvis and foot poses into joint angles, run separately for each leg from the pelvis/foot poses and the thigh, pelvis, and shank link lengths.

Two engineering details are important. A fixed offset vector reconciles the classical method's reference points with the ankle-link and pelvis centers of mass reported by PyBullet. This keeps feedback consistent with the planner's assumptions. The stance/swing hand-off is triggered by foot-contact forces. When force under the swing foot builds over several steps, the support foot switches, with a brief double-support phase in between. The Zero-Moment Point, computed from the same contact forces, is monitored against the support polygon for balance. The controller keeps the classical walking components, while the network learns a small set of trajectory parameters.

Baseline environment step function
Baseline (Env 1). Actions are mapped straight to motor commands (θ or τ) and applied in PyBullet, with no trajectory or kinematics block.
Architecture of the hybrid environment step function
Hybrid (Env 2). Actions become CoM/ankle trajectory increments, inverse kinematics maps them to joint angles, then PyBullet executes them.
CoM and swing-foot trajectories, side and top view
(b) Right-side view (a) Top view
What the agent shapes: the CoM and swing-foot trajectories (side view, left; top view, right).
Commanded versus achieved trajectories
(c) Left ankle (b) Right ankle (a) CoM & robot base
Commanded vs. achieved trajectories. Close tracking confirms the IK block realises what the agent asks for.

For the learning algorithm, I compared PPO, DDPG, TD3, and SAC, and chose PPO for its stability on high-dimensional continuous control. The reward is a weighted sum of interpretable, biomechanically-motivated terms: forward progress and velocity, survival time, and foot placement on the positive side; energy use, sideways drift, and upper-body tilt on the negative side. Any term can be zeroed out for ablation or wrapped in a shaping function, and there are dedicated sub-rewards for landing the swing foot flat and (optionally) for imitating a reference human gait.

Rather than ending an episode the moment the Zero-Moment Point leaves the support polygon, I treat that as a soft penalty in the reward, not a hard failure. The ZMP-in-polygon test is sufficient but not necessary for staying upright: a robot can briefly tip onto a foot edge and still recover, so a hard test would kill promising episodes early. Falls are detected from center-of-mass height instead.

PyBullet OpenAI Gym PyTorch Stable-Baselines · PPO Optuna Analytic IK ZMP balance

What I found

Why it still matters

In 2022, most work focused on end-to-end joint-level RL. This thesis instead kept classical structure in the controller and used RL to modify trajectories. Hybrid approaches that combine learning with model-based controllers and trajectory generators have since become more common in legged locomotion.

Extras

Below are additional figures from the thesis. The complete original (Persian) thesis is here, and the English summary PDF is here. The implementation, including custom Gym environments, trajectory generation, inverse kinematics, and training scripts, is on GitHub: github.com/RHnejad/gym-Surena.

The concepts behind it

Human walking alternates a stance phase (the foot supporting the body) with a swing phase (the foot in the air, advancing). The swing-foot trajectory the agent learns is exactly that swing motion.

The human gait cycle
Stance phase Swing phase
The human gait cycle, with the standard gait events.
Linear inverted pendulum model
The linear inverted-pendulum model, a point mass at height Zc, gives the CoM dynamics the hybrid trajectory builds on.

From the experiments

Frames of the robot walking in simulation
Frames from a training episode: the robot keeps its balance while moving forward.
The full observation space over one episode
Everything the agent observes over one episode: joint angles and velocities, center-of-mass position and velocity, pelvis orientation and angular velocity, and the contact force under each foot (the last two traces show the gait cycle).
Position-control learning curve
Position control. Reward climbs with occasional drops; PPO's clipping keeps it from diverging.
Torque-control learning curve
Torque control. Converges sooner, then plateaus.