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 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. Project page: https://guillaume10.github.io/terrain-gaits.
Figures & tables
Figure 1: Diverse gaits on challenging terrains. Locomotion with 11 distinct gait couplings on slopes, stairs, gaps, rough terrain, and random blocks. Color indicates the gait: lateral sequence walk , diagonal sequence walk , amble , trot , pace , pronk , half-bound , bound , canter , transverse gallop , and rotary gallop . The same gait couplings are also used to learn bipedal-mode locomotion. Bottom: hardware deployment with the height map estimated onboard from a forward-facing depth camera.
Figure 2: Control architecture for terrain-adaptive gait learning and selection. Stage 1 : the policy observes a velocity command vb,x∗ , exteroceptive sensing (height-map scan dots d ), proprioceptive sensing (body velocities vb , Ωb ; orientation ϕb,r , θb,p , ψb,y ; joint states q , q˙ ; previous action at−1 ), and CPG states ( r , θ , r˙ , θ˙ ), all as inputs to a multilayer perceptron (MLP). It outputs gait style parameters (body height h , ground clearance gc , foot offset xoff ) and CPG parameters ( μi , ωi ) for each leg, coordinating the Rhythm Generation and Pattern Formation layers. Task-space foot positions pd are converted to joint angles via inverse kinematics and tracked with PD control to produce torques τ . The enforced desired gait is provided as the coupling matrix Φ , resampled every few seconds during training. Stage 2 : the Stage 1 network is frozen; a second policy receives the same observation as Stage 1 and selects among 11 gaits at each decision timestep, adapting gait selection online to changing terrain to optimize a user-defined criterion. Heightmap encoder : for hardware deployment, the privileged heightmap is replaced by an estimate produced onboard. An encoder predicts the height-map scan dots from depth images captured by a camera mounted on the robot. The images pass through a convolutional neural network (CNN), and the resulting embedding is concatenated with body orientation ( ϕb,r , θb,p ) and foot positions ( p ) and passed to a single-layer gated recurrent unit (GRU), which lets the encoder integrate observations over time. A final MLP regresses the height-map scan dots, trained with DAgger. The Stage 1 and Stage 2 networks are unchanged. Deploy : with the encoder and camera onboard, the policies run on the physical Unitree Go1 and Go2.
Figure 3: Optimal gaits across terrains and metrics. Top : test terrains ranked in difficulty from 1 (easiest) to 5 (most difficult). Difficulty 5 corresponds to the steepest slopes, tallest steps, widest gaps (and smallest platforms), most uneven rough terrain, and largest random mixed blocks. Bottom : the gait achieving the lowest mean Cost of Transport, base angular velocity, and joint acceleration across five terrain difficulties and four velocity commands (0.5–2 m/s), averaged over 100 parallel agents on 10 m terrains. Lower values are better for each metric, and the corresponding gait is shown for each terrain difficulty and velocity combination. When multiple gaits achieve metric values within 5% of the minimum, their colors appear in a checkerboard pattern. Remarkably, all 11 gaits appear as optimal under at least one scenario.
Figure 4: Stage 2 gait selection on a parkour course. a : parkour course incorporating all considered terrain types. Robot snapshots show results from the power-minimizing policy. b : gaits selected by the power-minimizing Stage 2 policy at 1.5 m/s along the course shown in a , together with the corresponding gait style parameters (body height, foot ground clearance, foot offset) output by the Stage 1 policy. A single gait is active at each timestep, plotted against course position. The Stage 2 policy sometimes transiently selects a gait (rotary gallop), or switches rapidly between similar gaits (bound and half-bound, or bound and transverse gallop), which can occur when two gaits are close to tied on the optimized criterion (Fig. 3 ). The Stage 1 policy modulates the gait style parameters intuitively, e.g. shifting the foot offset forward when descending slopes or stairs. c,d : comparing gait selections and metrics on the parkour course for three Stage 2 policies. c : percentage of time each gait is selected by policies trained to minimize power, angular velocity, and joint acceleration, respectively, across four commanded velocities. Each regularly selects a unique gait not used by the others. d : mean metric values for each policy, computed over the entire course. Each policy outperforms the others on its respective targeted metric.
Figure 5: Generalization to out-of-distribution conditions. a : zero-shot locomotion with a novel 3-legged gait coupling not seen during training. b : pronk up stairs with overridden ground clearance ( gc=0.2 m, approximately 1.7× the training maximum). c : pace up stairs with ground clearance overridden to 2× the training maximum ( gc=0.24 m). d–f : gap traversal with different gait style parameter settings. d : base height forced to the training minimum (0.18 m). e : nominal traversal without overrides. f : ground clearance forced to 2× the training range maximum (0.24 m). g–i : generalization to other quadruped platforms. g : Unitree Go2 (roughly the same size as Go1), h : Unitree Aliengo ( 2× mass, 1.5× height), i : Unitree B2 ( 5× mass, 2.15× height).
Figure 6: Bipedal-mode locomotion on diverse terrains with all gait couplings. The robot locomotes on the front legs (handstand, positive pitch) and on the rear legs (negative pitch), using all 11 quadrupedal gait couplings in each configuration. Only one additional reward term (for base pitch) is needed, without any expert data or reference motions. The robot autonomously transitions from quadrupedal stance to a front-leg handstand, while rear-leg locomotion begins from an upright stance.
Figure 1: Contact timing for each foot with the ground as a percentage of a single gait cycle for various quadruped gaits: Lateral Sequence Walk (L.S. Walk), Diagonal Sequence Walk (D.S. Walk), Amble, Trot, Pace, Pronk, Half-Bound, Bound, Canter, Transverse Gallop (T. Gallop), Rotary Gallop (R. Gallop). While not considered during training as it is not a biological gait, during test time we show that the policy can still adapt to an artificial gait where 3 legs are coupled together. The timings are converted to matrices that denote phase offsets between different limbs (i.e. 0.5 corresponds to π ) in column order: Front Right (FR), Front Left (FL), Hind Right (HR), Hind Left (HL), as they appear in Equation 2 (main text).
Figure 2: Realization of commanded gait patterns across terrains and speeds . Gait-tracking accuracy measures the fraction of commanded stance time during which the corresponding foot is in terrain contact. We evaluate 11 gaits across seven terrains, five difficulty levels, and four commanded velocities (0.5–2.0 m/s), with 100 robots per setting. (a) Mean gait-tracking accuracy for each gait, terrain, and velocity. Values are averaged across difficulty levels, with standard deviations indicated where applicable. Commanded stance phases are consistently realized on most terrains, typically with 95–100% accuracy, with the largest reductions occurring over gaps. (b) Gait-tracking accuracy as a function of gap width. Walking, ambling, trotting, pacing, and pronking progressively lose contact availability as gaps widen, whereas bounding and galloping gaits maintain near-perfect contact realization. These reductions are primarily associated with the absence of suitable footholds over gaps, rather than changes in the commanded CPG phase pattern.
Figure 3: Traversal success rate for all gaits across all terrains. A baseline trained without gait coupling is shown in gray. The mean across all terrain difficulties is shown with the filled circle, and the error bars denote the standard deviation across the terrain difficulties from 1 through 5. If not a tie, the optimal gait from among the 11 is denoted by a star (*) for each velocity. Notably, even though the baseline does not have a fixed gait, implying it could adapt better to terrains in general, it performs comparably to the transverse gallop.
Figure 4: Cost of Transport for all gaits across all terrains. A baseline trained without gait coupling is shown in gray. The mean across all terrain difficulties is shown with the filled circle, and the error bars denote the standard deviation across the terrain difficulties from 1 through 5. The optimal gait from among the 11 is denoted by a star (*) for each velocity. Notably, even though the baseline does not have a fixed gait, implying it could adapt better to terrains in general, there are few terrain scenarios where it outperforms the optimal gait.
Figure 5: Mean base angular velocity for all gaits across all terrains. A baseline trained without gait coupling is shown in gray. The mean across all terrain difficulties is shown with the filled circle, and the error bars denote the standard deviation across the terrain difficulties from 1 through 5. The optimal gait from among the 11 is denoted by a star (*) for each velocity.
Figure 6: Mean total joint acceleration for all gaits across all terrains. A baseline trained without gait coupling is shown in gray. The mean across all terrain difficulties is shown with the filled circle, and the error bars denote the standard deviation across the terrain difficulties from 1 through 5. The optimal gait from among the 11 is denoted by a star (*) for each velocity.
Figure 7: Mean oscillator amplitudes (related to step lengths) for all gaits across all terrains. A baseline trained without gait coupling is shown in gray. The mean across all terrain difficulties is shown with the filled circle, and the error bars denote the standard deviation across the terrain difficulties from 1 through 5.
Figure 8: Mean oscillator frequencies (approximate step frequencies) for all gaits across all terrains. A baseline trained without gait coupling is shown in gray. The mean across all terrain difficulties is shown with the filled circle, and the error bars denote the standard deviation across the terrain difficulties from 1 through 5.
Figure 9: Mean body height for all gaits across all terrains. A baseline trained without gait coupling is shown in gray. The mean across all terrain difficulties is shown with the filled circle, and the error bars denote the standard deviation across the terrain difficulties from 1 through 5.
Figure 10: Mean swing foot ground clearance for all gaits across all terrains. A baseline trained without gait coupling is shown in gray. The mean across all terrain difficulties is shown with the filled circle, and the error bars denote the standard deviation across the terrain difficulties from 1 through 5.
Figure 11: Mean foot x -offset for all gaits across all terrains. A baseline trained without gait coupling is shown in gray. The mean across all terrain difficulties is shown with the filled circle, and the error bars denote the standard deviation across the terrain difficulties from 1 through 5.
Figure 12: Gait selection under different Stage 2 performance criteria. Independently trained Stage 2 policies are evaluated on the parkour terrain from Fig. 4 (main text). The percentage of time each gait is selected is shown across four commanded velocities. The expressions indicate the criterion-specific reward terms, with shared action regularization terms. Above the dashed red line, policies minimize quantities such as power, angular velocity, or contact forces. Below the red line, policies instead maximize some of these quantities to demonstrate the diversity of gait-selection behaviors, for example for the least energy-efficient locomotion possible, or the greatest vertical oscillations. For minimizing quantities that do not include the pitch axis, the bound gait is frequently selected due to its symmetry. When maximizing several of these quantities, the pronk gait is often preferred.
Parameter
Value
Batch size
98,304 (4,096 × 24)
Mini-batch size
24,576 (4,096 × 6)
Number of epochs
5
Clip range
0.2
Entropy coefficient
0.01
Discount factor
0.99
Table 1: PPO hyperparameters and neural network architectures.
Term
Formula
Weight
Linear velocity tracking vb,x∗
f(vb,x∗−vb,x)
3dt
Lateral/vertical velocity vb,yz
−∥vb,yz∥2
2dt
Angular velocity Ωb,xyz
−∥Ωb,xyz∥2
0.1dt
Power
−∑i∣τiq˙i∣
0.001dt
Action rate
−∥at−1−at∥2
0.01dt
Out-of-range actions
−∑kI(∣at,kraw∣>amax)
1dt
Table 2: Stage 1 reward function terms . The same reward is used for all 11 gaits and all terrains, with no term referring to the gait, the body height, the foot ground clearance, or the foot offset, all of which the policy controls directly through the CPG interface. (⋅)∗ denotes a desired command and f(x):=exp(−∥x∥2/0.25) . dt=0.03 s is the control time step.
Extreme Parkour 11
Robot Parkour Learning 66
ANYmal Parkour 23
Agile Jumping 59
This work
Gait repertoire, control, and evaluation
Gait repertoire and command interface
2 modes
5 skills
5 skills
Fixed bounding
11 gaits + zero-shot gait generalization
Systematic gait comparison across terrains, commanded speeds, and metrics
–
–
–
–
✓
Velocity tracking over varying commanded speeds
–
–
–
–
✓
Commandable locomotion style and extrapolation ( i.e. height, clearance)
Table 3: Reported capabilities and training organization of representative learning-based parkour controllers and our gait-learning framework. The methods address different research questions; repertoire counts refer to parkour skills, locomotion modes, or gait couplings, and are not directly equivalent.
Learning-based quadrupedal locomotion typically relies on complex reward formulations that entangle task specification, operational limits, gait preference, and terrain adaptation within a single optimization objective. We instead treat these functions through distinct mechanisms: rewards for task specification, constraints for operational limits, energy minimization for gait preference, and exteroceptive perception for adapting energy use to terrain difficulty. We show that these components jointly enable efficient, terrain-adaptive locomotion, and that removing each component exposes a distinct failure mode. Our formulation removes explicit gait priors (including air-time, contact-count, and foot-clearance targets) in favor of emergent behavior. Compared to a conventional complex-reward baseline, our formulation achieves comparable terrain traversal while reducing cost of transport by 56% and operational-limit violations by 96%. The resulting policies transfer zero-shot to a physical Unitree Go2 using LiDAR-based elevation mapping. Project website with videos: https://tinyurl.com/locomposition.
Loukas Kordos, Leonard T. Franz, Simon Rappenecker +4
Technical University of Munich. · University of Tübingen. · Hertie Institute for Clinical Brain Research & Center for Integrative Neuroscience. +1
Developing natural and diverse locomotion controllers for quadruped robots that can adapt to complex terrains while preserving motion style remains a significant challenge. Existing imitation-based methods face a fundamental optimization trade-off: strict adherence to motion capture (mocap) references penalizes the geometric deviations required for terrain adaptability, whereas terrain-centric policies often compromise stylistic fidelity. We introduce LatentMimic, a novel locomotion learning framework that decouples stylistic fidelity from geometric constraints. By minimizing the marginal latent divergence between the policy's state-action distribution and a learned mocap prior, our approach provides a conditional relaxation of rigid pose-tracking objectives. This formulation preserves gait topology while permitting independent end-effector adaptations for irregular terrains. We further introduce a terrain adaptation module with a dynamic replay buffer to resolve the policy's distribution shifts across different terrains. We validate our method across four locomotion styles and four terrains, demonstrating that LatentMimic enables effective terrain-adaptive locomotion, achieving higher terrain traversal success rates than state-of-the-art motion-tracking methods while maintaining high stylistic fidelity.
Zhiquan Wang, Yunyu Liu, Dipam Patel +3
Department of Computer Science, Purdue University, USA
Reinforcement learning (RL) for quadruped locomotion commonly depends on fixed, hand-crafted, and Markovian reward functions that limit both interpretability of learned policies and lack explicit control over gait behaviors. We introduce a framework where distinct gaits are specified using parameterized constraints expressed in Signal Temporal Logic (STL). These include safety bounds, gait synchronization constraints, command tracking, and actuation bounds. From these specifications, we develop a reward shaping mechanism that provides learning agents a dense, continuous reward landscape that encodes desired behavior. We define parametric STL templates for three speed regimes (walking-trot, trot, bound), calibrate their parameters from reference rollouts, and compute rewards from using smooth approximations of STL robustness over the rollouts. The generated rewards can be used to provide shaped gradients compatible with Proximal Policy Optimization (PPO). We instantiate the approach on Google's Barkour quadruped robot in MuJoCo XLA (MJX). We use parallelization within the simulator to improve training speeds and use domain randomization to robustify learned policies. We show that compared to a baseline of hand-crafted rewards, the STL-shaped rewards yield tighter velocity tracking and more stable training. Videos can be found on our project website: https://stl-locomotion.github.io/.