Enforce Safety Constraints with Control Barrier Functions
A barrier certificate defines a safety set of the desired states of a system. A control barrier function is used to find a safe control such that the states remain in the safety set. Many real-world systems operate under physical or safety constraints such as state boundaries. Control barrier functions (CBFs) enforce safety constraints by keeping system states inside a defined safe set while a baseline controller tracks performance goals.
Using Simulink® Control Design™ software, you can enforce CBF safety constraints by restricting control inputs in real time. For safety constraints expressed as a linear inequality in u, the software solves a quadratic program (QP) at each step to apply the closest control that satisfies safety and actuator bounds. Therefore, CBFs provide formal safety guarantees and integrate easily with your existing baseline control system. You can use CBFs for applications where safety-critical operation is essential and constraints must always be respected, such as autonomous driving and robotic safety.
Control Barrier Functions
Consider control-affine plant dynamics of the following form.
The control barrier function h(x) defines a safety set , that is, an invariant set where any trajectory starting inside the set remains within the set.
For h(x) , the Lie derivative is the time derivative along the system trajectories, defined as follows.
For example, this figure shows a simple barrier function surface and its safe set. The barrier function h(x) defines a circular safe region where h(x) ≥ 0. The 3D plot shows the surface of h(x), while the 2D contour plot highlights the safe set boundary h = 0, and the gradient field, which points toward increasing h. This figure illustrates how CBFs maintain forward invariance by keeping the system state within the region where the barrier function is nonnegative.

Relative Degree and Higher-Order Lie Derivatives
Relative degree is the number of time derivatives of h you must take before the control term u appears explicitly. This means, for a relative degree of 1:
When the control term does not appear in the first-order Lie derivative of the CBF (Lgh = 0), you can use higher-order derivatives of the CBF. That is, you must differentiate further along f(x) until the input term u appears in the r-th order time derivative.
The function h(x) has a higher relative degree r until the following condition is satisfied.
Additionally, you obtain the higher-order Lie derivatives by repeatedly differentiating along the fields f(x) and g(x). Use these derivatives to build constraints for a higher relative degree.
Lfih is the i-th Lie derivative of hx with respect to x, with and .
LgLfih is given by .
Control Barrier Function Constraints
The control barrier function constraint for relative degree 1 is described by:
Here α(h(x)) is an extended class Κ function. Typically, this function is of the following form.
Therefore, in standard form, you can write the CBF inequality as:
Here, γ is the constraint factor and β is the constraint power.
High-Order Control Barrier Functions
If Lgh = 0, then you must use a higher-order formulation of the CBF constraints, described as follows:
For high-order CBF, you can use the exponential high-order CBF formulation that enforces a strict state-dependent high-relative degree safety for nonlinear systems. h(x) is an exponential CBF if there exists a row vector Kα such that:
Here:
You obtain this row vector of gains Kα using pole placement to make the companion form Hurwitz stable. This ensures all derivatives of h(x) decay exponentially.
An exponential CBF constraint is defined as follows:
Here, γi is the constraint factor values computed by placing poles for desired decay rate. The software also allows you to specify a more general form of high-order CBF constraints defined as follows:
For this form, you explicitly specify the values for constraint factors γi and the constraint power β.
Using CBF Constraints in Simulink
Use these blocks to implement control barrier function constraints in Simulink.
Barrier Certificate Enforcement block — For relative degree 1.
High-Order Control Barrier Function block — For relative degree 1 to 4.
These blocks, which require Optimization Toolbox™ software, compute minimum deviation control from baseline controller subject to barrier certificate constraints and action bounds. The blocks use a quadratic programming (QP) solver to find the control action u that minimizes the function in real time. Here, u0 is the unmodified control action from the controller.
This table summarizes the constraints used by the blocks, based on relative degree.
| Barrier Function Relative Degree | Constraint Equation |
|---|---|
| First order | |
| Second order | |
| Third order | |
| Fourth order |
Implementation Workflow
To implement CBF constraints, use these steps.
Define the system dynamics in control-affine form .
Define a control barrier function h(x) that encodes the desired safety constraint.
Determine the relative degree by differentiating h(x) until the input term u appears explicitly.
Compute the required Lie derivatives and provide them as block inputs.
Connect the baseline controller input u0 and the optional action bounds umin and umax.
Tune the parameters.
For standard CBF, configure the constraint factor γ and constraint power β to modify the aggressiveness of the constraint.
For exponential CBF, set the pole values for the exponential decay rate.
This figure shows how to add the CBF block to your existing system with baseline controller. The block inputs depend on the relative degree of the constraint.

Since the blocks modify the original control action, the final closed-loop system might not achieve the design objectives of the original controller, such as stability margins.
You must verify that the combined controller and CBF blocks meet your original control objectives. If the system does not meet your original objectives, consider updating your original controller design. For example, you can add additional gain and phase margins to compensate for any potential performance degradation.
Examples
Enforce Barrier Certificate Constraints for PID Controllers — Implements a simple first-order CBF.
Enforce Barrier Certificate Constraints for Collision-Free Multi-Robot System — Defines a barrier function such that the robots reach their target position while maintaining a distance greater than a threshold distance between any two robots.
Safe PID Controller for Two Link Robot using High-Order Control Barrier Function — Computes higher‑order derivatives and uses exponential CBF.
References
[1] Xiao, Wei, and Calin Belta. “High-Order Control Barrier Functions.” IEEE Transactions on Automatic Control 67, no. 7 (2022): 3655–62. https://doi.org/10.1109/TAC.2021.3105491.
See Also
Barrier Certificate Enforcement | High-Order Control Barrier Function
Topics
- Enforce Barrier Certificate Constraints for PID Controllers
- Enforce Barrier Certificate Constraints for Adaptive Cruise Control
- Enforce Barrier Certificate Constraints for Collision-Free Robots
- Enforce Barrier Certificate Constraints for Collision-Free Multi-Robot System
- Safe PID Controller for Two Link Robot using High-Order Control Barrier Function