One policy for all gaits and terrains, in simulation and on hardware.
Animals use many different gaits to locomote at different speeds across varying terrains. A longstanding question in biology and robotics is: which gait is best? This question is most often addressed from an energy-efficiency perspective on flat terrain, leaving open how the answer depends on terrain and on the criterion optimized. Here we show that gait optimality is determined jointly by terrain, performance metric, and velocity. We use deep reinforcement learning and networks of abstract oscillators, modeling spinal central pattern generators, to learn all 11 quadrupedal gaits across diverse challenging terrains, together with the locomotion style (base height, foot ground clearance, foot offsets) that each requires. A second policy then selects among them to optimize a user-specified criterion such as cost of transport, base stability, or joint smoothness. Across these performance metrics and within this repertoire, every gait is optimal under at least one terrain–metric–velocity combination. The framework adapts zero-shot to gait couplings and styles never seen during training, to terrains far beyond the training distribution, and to larger quadrupeds five times the training mass. With a single additional pitch-tracking reward term, the same gait couplings also support bipedal-mode locomotion. Our method provides a general and systematic way to produce expressive locomotion and to select the gait best suited to a given terrain and criterion.
A network of coupled oscillators, modeling the central pattern generators of the spinal cord, produces the rhythm of the four legs. Its states are mapped to task-space foot trajectories and converted to joint targets by inverse kinematics. The gait is set by the phase coupling between the oscillators.
Stage 1. The gait coupling is resampled every few seconds, and the policy learns to modulate step frequency and step length together with the locomotion style (body height, swing foot ground clearance, foot offsets) for every gait on every terrain. The reward is minimal and contains no style terms.
Stage 2. With the Stage 1 network frozen, a second policy observes the same inputs and selects the gait at each timestep to optimize a chosen criterion, such as power, base angular velocity or joint acceleration. A new criterion only requires retraining this lightweight policy.
Hardware. An encoder estimates the height map from an onboard depth camera; the Stage 1 and Stage 2 networks run unchanged on the Unitree Go1 and Go2.
The same policy executes all 11 gaits on every terrain.
It depends on the terrain, the metric and the speed. Every one of the 11 gaits is optimal in at least one combination.
Three Stage 2 policies, trained to minimize power, base angular velocity or joint acceleration, select and transition between different gaits on the same course.
Terrains harder than any seen in training, gait styles forced outside the training range, and a gait coupling the policy never saw.
Harder terrain than in training
New gait styles and couplings
The same gaps, with the gait style overridden
A single additional reward term for tracking either a positive or negative body pitch enables bipedal locomotion on the front or rear legs. The robot autonomously transitions from quadruped to biped mode.
Parkour course on the front legs, without oscillator coupling
All 11 gait couplings, on every terrain
With the height map estimated onboard from a depth camera, the policies run unchanged.
Stage 1: one commanded gait
Stage 2: the gait is selected online
@article{bellegarda2026terrain,
title = {Learning optimal gaits and styles for terrain-adaptive quadruped locomotion},
author = {Bellegarda, Guillaume and Ijspeert, Auke},
journal = {preprint},
year = {2026}
}