Abstract
In the context of safe exploration, Reinforcement Learning (RL) has long grappled with the challenges of balancing the tradeoff between maximizing rewards and minimizing safety violations, particularly in complex environments with contact-rich or non-smooth dynamics, and when dealing with high-dimensional pixel observations. Furthermore, incorporating state-wise safety constraints in the exploration and learning process, where the agent must avoid unsafe regions without prior knowledge, adds another layer of complexity. In this paper, we propose a novel pixel-observation safe RL algorithm that efficiently encodes state-wise safety constraints with unknown hazard regions through a newly introduced latent barrier-like function learning mechanism. As a joint learning framework, our approach begins by constructing a latent dynamics model with low-dimensional latent spaces derived from pixel observations. We then build and learn a latent barrier-like function on top of the latent dynamics and conduct policy optimization simultaneously, thereby improving both safety and the total expected return. Experimental evaluations on the safety-gym benchmark suite demonstrate that our proposed method significantly reduces safety violations throughout the training process, and demonstrates faster safety convergence compared to existing methods while achieving competitive results in reward return.
Introduction
In safety-critical applications like autonomous driving or robotics, "safe exploration" is a significant challenge. Traditional Reinforcement Learning (RL) agents must explore to learn, but exploration often leads to failures that can be catastrophic in the real world. Most current "Safe RL" approaches utilize the Constrained Markov Decision Process (CMDP) framework, which focuses on keeping the average cost of a trajectory below a threshold. However, this "soft" constraint does not guarantee safety at every individual step.
Control theory offers a solution through Barrier Functions, which ensure "forward invariance"—a mathematical guarantee that unsafe regions remain unreachable. However, these functions typically require perfect knowledge of environment physics and low-dimensional state information (e.g., exact coordinates). They struggle to scale to high-dimensional pixel data or complex, contact-rich environments. This paper introduces a framework that bridges this gap, enabling agents to maintain state-wise safety using only raw pixel observations.
Proposed Framework: Latent Barrier Functions
The researchers propose a joint learning framework that operates in three integrated stages to manage safety in a compressed representation of the world.
- Pixels to Latent Space: The agent uses a Variational Autoencoder (VAE) structure to compress high-dimensional RGB images into a low-dimensional latent space. It learns a "world model" to predict future latent states, rewards, and safety violations.
- Latent Barrier-like Function ($B_\theta$): A barrier function is learned directly on the latent vectors. It is trained to be positive in safe regions and negative in unsafe regions, incorporating a derivative condition that penalizes movement toward decreasing barrier values.
- Policy Optimization: Using an actor-critic setup, the barrier function serves as a differentiable "safety advisor." If a planned action in the "imagined" latent world threatens to breach the barrier, the gradient from the barrier function pushes the policy toward a safer action before any real-world movement occurs.
Experimental Evaluation
The framework was evaluated using the Safety Gym SG6 benchmark suite, featuring tasks like PointGoal, CarGoal, and DoggoGoal. In these environments, the agent only receives $3 \times 64 \times 64$ pixel images from a front-facing camera and must navigate to goals while avoiding unknown hazards.
Key Results
The proposed method was compared against model-free baselines (CPO, PPO-Lagrangian) and state-of-the-art model-based methods (LAMBDA, Safe-SLAC).
- Faster Safety Convergence: The latent barrier method reached low-cost levels significantly faster than competitors across almost all benchmarks.
- Reduced Cumulative Cost (Regret): The agent incurred fewer total safety violations during the training process, demonstrating the effectiveness of the "imagination-based" safety shield.
- Competitive Performance: Despite strict safety constraints, the agent achieved reward returns comparable to or better than less-safe methods. For instance, in
CarGoal1, it maintained near-zero costs while matching the reward of the best baseline.
Discussion and Conclusion
A critical insight from this work is that the latent barrier function effectively converts "soft" trajectory-level constraints into "hard" state-wise constraints. By "hallucinating" potential hazards in the latent space, the agent learns from mistakes mentally rather than physically.
However, limitations remain. The use of a single front-facing camera introduces partial observability; the agent cannot avoid hazards it cannot see. Additionally, like all model-based RL, performance depends on the accuracy of the "imagined" world. Future work will explore distribution-based barrier functions to better handle the inherent uncertainty in latent transitions.
Source code available at: GitHub - Step-Wise SafeRL Pixel
Summary updated