Attention-Based Map Encoding for Learning Generalized Legged Locomotion

Junzhe He, Chong Zhang, Fabian Jenelten, Ruben Grandia, Moritz Bächer, Marco Hutter

Abstract

Navigating sparse and challenging terrains, such as stepping stones and narrow beams, remains a significant hurdle for legged robots. While model-based controllers offer precision, they often lack robustness in noisy, real-world environments. Conversely, standard reinforcement learning (RL) methods excel in robustness but struggle with the precise foot placement required for sparse footholds. This paper presents a novel RL framework that utilizes a Multi-Head Attention (MHA) mechanism to encode 2.5D terrain maps. By querying terrain features based on the robot's proprioceptive state, the system learns to prioritize critical environmental information. Experimental results demonstrate a 100% success rate on complex parkour courses for both quadrupedal and humanoid platforms, showcasing a generalized approach to perceptive locomotion that bridges the gap between precision and ruggedness.

Introduction

Legged locomotion research has traditionally been divided into two paradigms: model-based control and learning-based control. Model-based methods, such as Model Predictive Control (MPC), provide high precision but are prone to failure when encountering sensor noise or unmodeled physical dynamics. Learning-based methods, particularly Deep Reinforcement Learning (DRL), have demonstrated remarkable robustness on rough terrain. However, these methods often fail on "sparse" terrains—environments where only specific, narrow areas are traversable. In such scenarios, the probability of a robot "stumbling" upon a successful path during random exploration is extremely low, making standard RL training inefficient.

This research introduces an end-to-end RL policy that integrates an attention-based map encoding module. This approach allows the robot to implicitly plan its footsteps by focusing on relevant terrain features, combining the surgical precision of classical planners with the adaptive robustness of neural networks.

Methodology

Architecture

The core of the proposed framework is an Attention-Based Map Encoding module. The architecture processes environmental data through a two-step pipeline:

  1. Local Feature Extraction: A Convolutional Neural Network (CNN) processes a 2.5D height map centered on the robot to extract local geometric features.
  2. Proprioceptive Attention: A Multi-Head Attention (MHA) module uses the robot’s proprioceptive state—including joint angles, velocities, and orientation—as a "query" to scan the features extracted by the CNN.

This mechanism allows the robot to dynamically weight different parts of the map. Effectively, the robot asks: "Given my current momentum and balance, which upcoming terrain features are most critical for my next step?" The resulting compact representation is then fed into the main RL policy to determine joint actions.

Training Pipeline

To ensure both high performance and real-world applicability, the authors employed a two-stage training strategy:

  • Stage 1: Skill Acquisition. The robot is trained on "base terrains" (stairs, pits, gaps) using noise-free, ground-truth data to learn fundamental locomotion skills.
  • Stage 2: Robustness Fine-tuning. The policy is refined on more difficult terrains (pentagon stones, 15cm narrow beams) with the introduction of sensor noise, state estimation drifts, and external physical disturbances. This stage is crucial for successful sim-to-real transfer.

Experimental Results

Performance and Success Rates

The framework was evaluated on two distinct platforms: the 12-DoF ANYmal-D quadruped and the 23-DoF Fourier GR-1 humanoid. In simulated "obstacle parkour" benchmarks, both robots achieved a 100% success rate, significantly outperforming baseline RL methods and hybrid model-based/learning approaches like Deep Tracking Control (DTC). The proposed method also demonstrated lower velocity tracking errors, particularly during high-speed maneuvers.

Cross-Embodiment and Emergent Behaviors

A key finding of this study is the generalizability of the attention mechanism. The same architectural principles enabled both the quadruped and the humanoid to navigate complex obstacles. Furthermore, the end-to-end nature of the training led to the emergence of sophisticated recovery reflexes. For instance, the GR-1 humanoid learned to perform "switch hops" in mid-air to correct its trajectory when its initial leap toward a stepping stone was off-target.

Real-World Validation

Hardware experiments confirmed the robustness of the system. The ANYmal-D successfully traversed moving debris and unstable, unfixed beams. The GR-1 humanoid demonstrated stable locomotion on narrow stepping stones and beams at speeds reaching 1.5 m/s, proving that the attention-based encoding translates effectively to physical hardware.

Discussion and Interpretability

One of the primary advantages of the MHA module is its interpretability. By visualizing the attention weights, the researchers could observe the network's "focus." The visualizations confirmed that the policy consistently attends to the specific areas where the feet are intended to land, providing a window into the decision-making process of an otherwise "black box" neural network.

Limitations and Future Work

Despite its success, the framework has limitations. Training is computationally intensive, requiring up to six days on high-end industrial GPUs. Additionally, the reliance on 2.5D height maps prevents the robot from reasoning about 3D structures, such as overhanging obstacles or tunnels. Future research will focus on integrating active arm manipulation—allowing humanoids to use their hands for balance or environmental interaction—and extending the perception system to handle fully 3D environments.

Summary updated

BibTeX
@inproceedings{he2025attention,
  author = {Junzhe He and Chong Zhang and Fabian Jenelten and Ruben Grandia and Moritz Bächer and Marco Hutter},
  title = {{Attention-Based Map Encoding for Learning Generalized Legged Locomotion}},
  booktitle = {Sci. Robotics},
  year = {2025},
}
Figure