Safe exploration in model-based reinforcement learning using control barrier functions

M. Cohen, Călin BeltaAutomatica 2021

Abstract

This paper develops a model-based reinforcement learning (MBRL) framework for learning online the value function of an infinite-horizon optimal control problem while obeying safety constraints expressed as control barrier functions (CBFs). Our approach is facilitated by the development of a novel class of CBFs, termed Lyapunov-like CBFs (LCBFs), that retain the beneficial properties of CBFs for developing minimally-invasive safe control policies while also possessing desirable Lyapunov-like qualities such as positive semi-definiteness. We show how these LCBFs can be used to augment a learning-based control policy to guarantee safety and then leverage this approach to develop a safe exploration framework in a MBRL setting. We demonstrate that our approach can handle more general safety constraints than comparative methods via numerical examples.

Introduction

Reinforcement Learning (RL) has demonstrated remarkable potential in solving complex control tasks within simulated environments. However, transitioning these agents to real-world, safety-critical hardware—such as autonomous vehicles, drones, or medical robotics—presents a significant challenge. Traditional RL agents are often "black-box" optimizers that learn through trial and error, frequently violating safety constraints during the exploration phase to discover optimal behaviors.

Existing "safe RL" approaches often suffer from two primary limitations. First, safety is frequently coupled with the convergence of the learning algorithm; if the agent has not yet converged, it may still exhibit unsafe behavior. Second, many methods are restricted to simple "box constraints" (e.g., keeping a state within a linear range), which fail to account for the complex, non-convex geometries encountered in real-world obstacle avoidance. This paper introduces a framework that decouples safety from the learning process, ensuring system integrity from the first moment of operation.

Methodology

The proposed framework utilizes a Model-Based Reinforcement Learning (MBRL) architecture built upon three core pillars: Lyapunov-like Control Barrier Functions, Decoupled Safeguarding, and Simulation of Experience.

Lyapunov-like Control Barrier Functions (LCBFs)

Standard Control Barrier Functions (CBFs) are effective for maintaining safety but can sometimes conflict with the stability requirements of a system (i.e., reaching a specific equilibrium or goal). The authors introduce a novel class of "recentered" barrier functions defined as $B(x) = (b(x) - b(0))^2$. This LCBF is designed to be zero at the goal (the origin) while approaching infinity at the boundary of the safe set. This mathematical structure allows the safety mechanism to remain inactive near the goal while providing a rigorous "push back" as the system nears a constraint violation.

Decoupled Safeguarding

The control architecture splits the input into two distinct components: a performance-driven RL policy and a safety-driven LCBF filter. Because the LCBF is designed to be "minimally invasive," it allows the RL agent to explore the state space freely as long as the system remains within the safe set. The safety filter only intervenes when the RL agent’s proposed action would lead to a boundary violation, effectively acting as a hard constraint that overrides the learner when necessary.

Simulation of Experience

To bridge the gap between exploration and safety, the system identifies the underlying dynamics model online. Rather than risking the physical hardware to explore dangerous states, the framework uses the learned model to simulate trajectories at unexplored points in the state space. This "imagined" data is used to update the agent’s value function. This allows for aggressive exploration in simulation while maintaining a conservative, safe policy on the actual hardware.

Experimental Evaluation

The framework was evaluated using numerical simulations of nonlinear dynamical systems, focusing on scenarios where traditional safety methods often struggle.

  1. Non-Convex Safety Sets: The method was tested on a 2D nonlinear system tasked with reaching an origin while navigating a non-convex safe set. While traditional methods limited to rectangular constraints would fail to utilize the full available state space, the LCBF approach successfully navigated the complex geometry.
  2. Collision Avoidance: In a 2D mobile robot simulation, the agent was required to avoid circular obstacles. A standard Linear Quadratic Regulator (LQR) equipped with a safety filter became "stuck" behind obstacles due to its static nature. In contrast, the RL agent evolved its policy over time, eventually learning to navigate around obstacles to reach the target while the LCBF ensured no collisions occurred during the learning process.

Key Insights

  • Safety as a Hard Constraint: By treating safety as a filter rather than a penalty in the cost function, the framework prevents the agent from "trading off" safety for high rewards—a common failure mode in traditional RL.
  • Goal-Safety Synergy: By ensuring the LCBF vanishes at the origin, the authors resolve the tension between safety and reaching the target equilibrium, ensuring the safety mechanism does not interfere with task completion.
  • Virtual Failure Learning: Through "simulation of experience," the agent learns the consequences of potential failures without having to experience them physically, addressing the fundamental tension between the need to explore and the need to remain safe.

Limitations and Future Work

While the framework provides robust safety guarantees, it is subject to certain growth restrictions; if the system's uncontrolled movement (drift) is too high near boundaries, the safety filter may lack the control authority to prevent a violation. Additionally, the use of State Following (StaF) kernels for function approximation may face the "curse of dimensionality" when scaled to high-dimensional systems like humanoid robots. Finally, the framework currently requires a pre-defined candidate Barrier Function; future research into the automated discovery of these functions would further enhance the autonomy of the system.

Summary updated

BibTeX
@article{cohen2021safe,
  author = {M. Cohen and Călin Belta},
  title = {{Safe exploration in model-based reinforcement learning using control barrier functions}},
  journal = {Automatica},
  year = {2021},
}
Figure