Environment as Policy: Learning to Race in Unseen Tracks

Hongze Wang, Jiaxu Xing, Nico Messikommer, Davide Scaramuzza

TL;DR

This paper introduces an adaptive environment-shaping framework that allows reinforcement learning (RL) agents to master drone racing on entirely unseen tracks without retraining. By using a secondary "Environment Policy" to dynamically design training tracks that are challenging yet achievable, the authors produced a single racing policy capable of zero-shot generalization to complex 3D layouts and even dynamic environments with moving gates.

What Problem Does This Paper Address?

Reinforcement learning has enabled drones to outperform human champions on specific, known racing tracks. However, these agents are typically "specialists"—they overfit to the specific geometry of their training environment. When placed on a new track, they usually fail immediately and require complete retraining.

The obvious solution—training on a wide variety of tracks simultaneously—often fails because the task becomes too complex for the agent to explore effectively, leading to suboptimal performance. Manual curriculum design (starting easy and getting harder) is a common workaround, but it is labor-intensive, prone to human bias, and difficult to scale for high-dimensional robotic tasks like agile flight. The authors seek an automated way to "shape" the environment so the agent remains in a "Goldilocks zone" of learning: tasks that are neither too easy to be boring nor too hard to be impossible.

Methods

The core innovation is a dual-agent architecture where the environment itself is treated as a policy.

  1. Racing Policy (PPO): A primary agent trained using Proximal Policy Optimization to navigate through gates as fast as possible. Its observations include the drone's state (velocity, orientation) and the relative positions of the next two gates.
  2. Environment Policy (SAC): A secondary agent trained using Soft Actor-Critic. Its job is to modify the track layout (gate positions and yaw angles) for the racing agent.
  3. Relative Ranking Reward: This is the "secret sauce." Instead of using absolute performance metrics, the Environment Policy is rewarded based on how the racing agent performs across 100 parallel simulation environments. It is penalized for creating tracks that are too easy (where the agent passes everything perfectly) or too difficult (where the agent crashes immediately). It is rewarded for maintaining tracks in the intermediate range where the agent is challenged but showing progress.
  4. Alternating Training: The two policies train in an alternating fashion. The Environment Policy generates new layouts, and the Racing Policy trains on them for several iterations before the Environment Policy updates again.
Fig. 2: Overview of the proposed method. In every N iteration, the environment policy (left) takes as input the information of the racing policy evaluations and the current environments. It generates actions to adjust the gate layouts independently for each parallel environment. The racing policy (right) utilizes the information about drone and gate states from these simulation environments to learn time-optimal drone racing strategies through an MLP.

Datasets

The authors utilized the Flightmare simulator for large-scale training (800 million data samples).

  • Initial Layout: Training begins on a simple 8-gate oval track.
  • Evaluation Tracks: The policy was tested on six distinct, unseen tracks: Figure 8, Kidney, 2D Big S, 3D Figure 8, 3D Big S, and Twist. These tracks vary in gate count, height changes, and turn sharpness.
  • Real-World Testing: Experiments were conducted in a physical arena using the Agilicious quadrotor platform and a VICON motion capture system for state estimation.

Key Insights and Ideas

  • Environment as a Learnable Parameter: By treating track layout changes as "actions" in an RL MDP, the system automates curriculum discovery. The environment "evolves" alongside the agent's skill level.
  • The Power of Relative Ranking: Using a percentile-based ranking across parallel environments makes the training signal robust. As the racing agent gets faster, the "difficulty" threshold automatically shifts upward without manual retuning.
  • Emergent Generalization: By learning to handle a constantly shifting distribution of tracks, the agent learns the underlying logic of gate navigation (e.g., how to approach a sharp turn regardless of its specific coordinates) rather than just memorizing a trajectory. This allowed the agent to succeed on dynamic tracks with moving gates, even though it was never explicitly trained for moving obstacles.

Key Results

  • Zero-Shot Success: The proposed method achieved a 100% success rate across all six unseen test tracks in simulation. In contrast, vanilla RL without a curriculum failed on every single one.
  • Outperforming Baselines: The method significantly outperformed standard techniques like Domain Randomization and Particle Filter curricula, which struggled with the more complex "Big S" and "Twist" layouts.
  • Dynamic Robustness: In tests where gates moved at speeds up to 0.6 m/s, the agent maintained a 100% success rate, whereas baseline methods dropped to 0% success as the range of gate movement increased.
  • Real-World Validation: The single racing policy was deployed on a physical drone and successfully navigated six unseen tracks with a 100% success rate and competitive lap times.
Fig. 1: In this work, we introduce an environment-shaping framework to improve the generalization of RL drone racing agents to diverse and unseen tracks without retraining. We use a Soft Actor-Critic (SAC) policy to adaptively shape the track layouts by generating difficult but achievable race tracks based on the racing agent’s actual performance. The resulting single racing policy can fly in various unseen and challenging race tracks in the real world with competitive lap times.

Limitations and Future Work

  • Reset Mechanism: The authors noted that the Environment Policy can sometimes get "stuck" on infeasible tracks. They implemented a manual reset to the initial oval track if the success rate stays at zero for too long.
  • Fixed Gate Count: The current framework adjusts the layout of a fixed number of gates but does not yet dynamically add or remove gates to change track length.
  • State Estimation Dependency: The real-world tests relied on VICON for precise state estimation. A natural next step is integrating this environment-shaping approach with vision-based (pixels-to-actions) policies to handle perception uncertainty in the wild.

Summary updated

Abstract

Reinforcement learning (RL) has achieved outstanding success in complex robot control tasks, such as drone racing, where the RL agents have outperformed human champions in a known racing track. However, these agents fail in unseen track configurations, always requiring complete retraining when presented with new track layouts. This work aims to develop RL agents that generalize effectively to novel track configurations without retraining. The naive solution of training directly on a diverse set of track layouts can overburden the agent, resulting in suboptimal policy learning as the increased complexity of the environment impairs the agent's ability to learn to fly. To enhance the generalizability of the RL agent, we propose an adaptive environment-shaping framework that dynamically adjusts the training environment based on the agent's performance. We achieve this by leveraging a secondary RL policy to design environments that strike a balance between being challenging and achievable, allowing the agent to adapt and improve progressively. Using our adaptive environment shaping, one single racing policy efficiently learns to race in diverse challenging tracks. Experimental results validated in both simulation and the real world show that our method enables drones to successfully fly complex and unseen race tracks, outperforming existing environment-shaping techniques. Project page: http://rpg.ifi.uzh.ch/env_as_policy.
BibTeX
@inproceedings{wang2025environment,
  author = {Hongze Wang and Jiaxu Xing and Nico Messikommer and Davide Scaramuzza},
  title = {{Environment as Policy: Learning to Race in Unseen Tracks}},
  booktitle = {IEEE International Conference on Robotics and Automation},
  year = {2025},
  doi = {10.1109/icra55743.2025.11127376},
}
Figure