Inferensys

Glossary

Control Barrier Function (CBF)

A Control Barrier Function (CBF) is a mathematical tool used to enforce safety constraints by defining a forward-invariant safe set for robotic and autonomous systems.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
SAFETY-CRITICAL CONTROL

What is a Control Barrier Function (CBF)?

A formal mathematical tool for ensuring the safety of dynamical systems by synthesizing controllers that guarantee forward invariance of a defined safe set.

A Control Barrier Function (CBF) is a mathematical construct used to enforce safety constraints on a dynamical system by defining a forward-invariant safe set. It provides a formal, constraint-based method to synthesize or filter control inputs, ensuring the system state remains within a predefined safe region for all future time. This is achieved by deriving a condition that the control input must satisfy at each time step, directly linking safety to the system's dynamics.

In practice, a CBF is often integrated with controllers like Model Predictive Control (MPC) to create a predictive safety filter or as additional hard constraints in the optimization problem. This combination, known as CBF-MPC, leverages MPC's predictive optimization for performance while using the CBF's conditions to guarantee recursive feasibility and safety. The core mechanism involves defining a barrier function whose value remains non-negative if the system is safe, with the controller designed to enforce its time derivative is non-negative on the boundary of the safe set.

SAFETY FILTERS

Key Properties of Control Barrier Functions

Control Barrier Functions (CBFs) are mathematical constructs that formally guarantee a system remains within a designated safe set. Their core properties define how they interact with a controller to filter unsafe actions.

01

Forward Invariance

Forward invariance is the foundational guarantee provided by a valid CBF. If a system starts inside a safe set defined by the CBF, and the controller satisfies the CBF condition for all future time, then the system is guaranteed to remain inside the safe set forever. This property transforms a static safety specification into a dynamic control law.

  • Mathematical Definition: A set (C) is forward invariant if for every initial state (x(0) \in C), the trajectory (x(t) \in C) for all (t \geq 0).
  • Role of the CBF: The CBF's time derivative condition, (\dot{h}(x) \geq -\alpha(h(x))), is a constraint that, when enforced, mathematically proves forward invariance.
02

Relative Degree

The relative degree of a CBF is the number of times the output function (h(x)) must be differentiated with respect to time before the control input (u) explicitly appears. This property dictates the form of the CBF constraint and the complexity of the resulting safety filter.

  • Relative Degree 1: The control input (u) appears in the first derivative (\dot{h}(x,u)). This leads to a simple, affine constraint in (u) that is easy to enforce via a Quadratic Program (QP). Example: Velocity-level constraints for a mobile robot.
  • High Relative Degree: Requires (u) to appear after multiple differentiations. This necessitates techniques like Exponential Control Barrier Functions (ECBFs) or Integral Control Barrier Functions to formulate a constraint that is still applicable for real-time control.
03

Composition with Nominal Controllers

A primary use of a CBF is as a safety filter. It takes a potentially unsafe nominal control input (e.g., from an MPC or tracking controller) and minimally modifies it to ensure safety. This is typically formulated as a Quadratic Program (QP).

CBF-QP Formulation: [\min_{u} , |u - u_{nom}|^2] [\text{subject to: } , L_f h(x) + L_g h(x) u \geq -\alpha(h(x))]

  • (u_{nom}): The desired, performance-optimizing input from the nominal controller.
  • CBF Constraint: The inequality that enforces the forward invariance condition.
  • Minimal Intervention: The QP finds the safest control input closest to the nominal one, preserving performance when safety is not at risk.
04

Class K Function & Tunable Aggressiveness

The class (\mathcal{K}) function, (\alpha(\cdot)), in the CBF condition (\dot{h} \geq -\alpha(h)) is a tunable parameter that dictates how aggressively the controller acts to keep the system safe.

  • Function Definition: A continuous function (\alpha: [0, \infty) \to [0, \infty)) is class (\mathcal{K}) if it is strictly increasing and (\alpha(0) = 0). A common choice is (\alpha(h) = \gamma h) for (\gamma > 0).
  • Interpretation: When the system is far from the boundary ((h) is large), the constraint (\dot{h} \geq -\gamma h) is loose, allowing the nominal controller to act freely. As the system approaches the boundary ((h \to 0)), the constraint forces (\dot{h}) to become positive, pushing the state back into the interior of the safe set. A larger (\gamma) results in more aggressive corrective action.
05

Integration with Model Predictive Control (MPC)

CBFs and MPC can be integrated in two primary architectures, leveraging the predictive nature of MPC with the formal safety guarantees of CBFs.

  1. CBFs as Constraints in MPC: The CBF condition (\dot{h}(x,u) \geq -\alpha(h(x))) is added as a constraint within the MPC's finite-horizon Optimal Control Problem (OCP). This ensures the optimized trajectory is safe over the prediction horizon.
  2. CBFs as a Safety Filter for MPC: The MPC solves its OCP without explicit safety constraints to maximize performance. The resulting planned input sequence is then passed through a CBF-based safety filter (e.g., a CBF-QP) at each time step before being applied to the system. This decouples performance optimization from safety enforcement.
06

Comparison to Control Lyapunov Functions (CLFs)

CBFs are often discussed alongside Control Lyapunov Functions (CLFs), which certify stability (convergence to a goal). Understanding their dual role is key to unified controller design.

PropertyControl Lyapunov Function (CLF)Control Barrier Function (CBF)
Primary GoalStability - Drive the system to a desired equilibrium.Safety - Keep the system away from forbidden states.
Core Condition(\dot{V}(x,u) \leq -\lambda V(x)) (energy decreasing).(\dot{h}(x,u) \geq -\alpha(h(x))) (distance from boundary non-decreasing).
Typical UseFormulated as a constraint to achieve asymptotic tracking.Formulated as a constraint to enforce set invariance.
  • CLF-CBF QP: A single Quadratic Program can enforce both CLF (for performance) and CBF (for safety) constraints simultaneously, providing a unified framework for safe and stable control.
COMPARISON

CBF vs. Other Safety and Control Methods

A feature comparison of Control Barrier Functions (CBFs) against other prevalent safety and control methodologies, highlighting their respective mechanisms, computational properties, and integration capabilities.

Feature / MetricControl Barrier Function (CBF)Model Predictive Control (MPC)Lyapunov FunctionsRule-Based Safety (e.g., Emergency Stop)

Primary Safety Mechanism

Forward invariance of a safe set defined by a barrier function.

Explicit constraint satisfaction over a finite prediction horizon.

Asymptotic convergence to a stable equilibrium point.

Discrete, conditional logic triggers (e.g., if obstacle_detected then stop).

Constraint Handling

Hard constraints via barrier condition; can be paired with MPC for predictive constraints.

Explicit hard and soft state/input constraints within the optimization.

Typically does not handle path constraints; focuses on stability.

Binary, all-or-nothing; no formal constraint representation.

Computational Profile

Low; often adds a single constraint or QP to a nominal controller.

High; requires solving an optimization problem (QP/NLP) at each step.

Very low; stability check via function derivative.

Negligible; simple Boolean evaluation.

Predictive Capability

None inherently; provides instantaneous safety filter. Integrates with MPC for prediction.

Core feature; uses a dynamic model to predict and optimize future states.

None; analyzes stability of current state or trajectory.

None; reactive to immediate sensor input.

Formal Guarantees

Forward invariance (safety) for a perfectly known model.

Optimality w.r.t. cost function & constraint satisfaction for the horizon, subject to model fidelity.

Asymptotic stability (safety in the sense of converging to a safe equilibrium).

None; heuristic and scenario-dependent.

Integration with Performance Controllers

High; designed as a modular safety filter for any nominal controller (e.g., RL, PID).

Self-contained; performance and safety are jointly optimized in a single problem.

Moderate; often used as a stability certificate for a designed controller.

Low; typically overrides or interrupts the performance controller.

Handling of Model Uncertainty

Limited; requires robust or adaptive CBF formulations for guarantees.

Addressed via Robust MPC or Stochastic MPC (e.g., tube MPC, chance constraints).

Robust Lyapunov functions can provide stability guarantees under bounded uncertainty.

Not formally addressed; relies on sensor accuracy and threshold tuning.

Real-Time Suitability for Fast Dynamics

Excellent; low computational overhead enables high-frequency control loops.

Challenging; solving optimization in <1 ms is difficult for complex systems.

Excellent; function evaluation is trivial.

Excellent; minimal latency.

CONTROL BARRIER FUNCTION (CBF)

Frequently Asked Questions

A Control Barrier Function (CBF) is a mathematical tool used to enforce safety constraints in dynamic systems. It is a critical component for ensuring robots and autonomous systems operate within a predefined 'safe set' of states, often integrated with advanced controllers like Model Predictive Control (MPC).

A Control Barrier Function (CBF) is a mathematical construct used to guarantee that a dynamical system remains within a safe subset of its state space for all future time, a property known as forward invariance. It works by defining a scalar function, h(x), over the system state x, where h(x) ≥ 0 represents the safe set. The core mechanism is to synthesize a controller that ensures the time derivative of h(x) satisfies a condition (e.g., ḣ(x) ≥ -α(h(x))) that prevents h(x) from becoming negative, thus keeping the system safe. Unlike Lyapunov functions, which certify stability, CBFs explicitly certify safety with respect to constraints like collision avoidance or joint limits.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.