← Guillaume Bellegarda

Learning Optimal Gaits and Styles for Terrain-Adaptive Quadruped Locomotion

1Inria   2EPFL
(preprint, 2026)

Highlights

One policy for all gaits and terrains, in simulation and on hardware.

Hardware: 0.5 m and 0.7 m gaps, 0.21 m box
Hardware: online gait selection
Stage 2 switching gaits to minimize energy
On the rear legs, across gaps
On the front legs, stairs and gaps
Out of distribution generalization:
onto a 0.55 m wall and up 0.4 m stairs
11quadrupedal gaits on 7 terrain types, learned by one policy
All 11gaits are optimal for at least one terrain, metric and speed
+45%gap width beyond the training range, zero-shot
Biped modeevery gait coupling also drives bipedal locomotion

Abstract

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.

Method

Control architecture: a Stage 1 policy outputs gait style and CPG parameters that drive oscillators, foot trajectories and joint PD control; a frozen Stage 1 is combined with a Stage 2 policy that selects the gait; a heightmap encoder estimates the terrain from depth images on hardware.

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.

Stage 1: any gait on any terrain

The same policy executes all 11 gaits on every terrain.

Playback
L.S. Walk
D.S. Walk
Amble
Trot
Pace
Pronk
Half-Bound
Bound
Canter
T. Gallop
R. Gallop
Stairs upAll 11 gaits, one policySame command

Which gait is best?

It depends on the terrain, the metric and the speed. Every one of the 11 gaits is optimal in at least one combination.

For seven terrains, five difficulty levels and four speeds, the gait with the lowest Cost of Transport, base angular velocity and joint acceleration.
The gait minimizing Cost of Transport, base angular velocity and joint acceleration, for five difficulty levels of each terrain and four speeds (0.5–2 m/s). Gaits within 5% of the best share a cell. The trot, which most learned controllers converge to, is the most energy-efficient gait in only about a quarter of the cases.

Stage 2: gait selection

Three Stage 2 policies, trained to minimize power, base angular velocity or joint acceleration, select and transition between different gaits on the same course.

Playback
The bar under each run shows the gait selected along the course, and the bar on the right shows the share of each gait so far, for this run. Fig. 3c below gives the averages.
Parkour course with the gaits selected by the power-minimizing policy, the selected gait and style parameters along the course, gait usage per policy and velocity, and the metric each policy achieves.
a–b: gaits and style parameters selected by the power-minimizing policy along the course. c: share of each gait per policy and speed; each policy regularly uses a gait the others do not. d: each policy outperforms the others on its own metric.

Zero-shot generalization

Terrains harder than any seen in training, gait styles forced outside the training range, and a gait coupling the policy never saw.

Playback

Harder terrain than in training

Gallop across 0.8 m gaps45% wider than in training
Bound onto a 0.55 m wall10% higher than in training
Gallop up 0.4 m stairs60% higher than in training

New gait styles and couplings

Unseen gait couplingthree legs in phase, the fourth in antiphase
Pronk, swing height forced to 0.2 mtraining maximum: 0.12 m
Pace, swing height forced to 0.24 m2× the training maximum

The same gaps, with the gait style overridden

Body height 0.18 mforced to the training minimum
Nominalstyle chosen by the policy
Swing height 0.24 mforced to 2× the training maximum
All three runs successfully traverse the gaps.

Bipedal mode

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.

Playback

Parkour course on the front legs, without oscillator coupling

All 11 gait couplings, on every terrain

Playback
L.S. Walk
D.S. Walk
Amble
Trot
Pace
Pronk
Half-Bound
Bound
Canter
T. Gallop
R. Gallop
Stairs upFront legs, all 11 gait couplingsSame command

Hardware

With the height map estimated onboard from a depth camera, the policies run unchanged.

Playback

Stage 1: one commanded gait

0.5 m gap
0.7 m gapwider than any gap in training
Box

Stage 2: the gait is selected online

Gaptrot-bound-trot
Gapwalk-gallop-walk
Boxtrot-bound-trot

BibTeX

@article{bellegarda2026terrain,
  title   = {Learning optimal gaits and styles for terrain-adaptive quadruped locomotion},
  author  = {Bellegarda, Guillaume and Ijspeert, Auke},
  journal = {preprint},
  year    = {2026}
}