Main Content

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.

x˙=f(x)+g(x)u

The control barrier function h(x) defines a safety set {x:h(x)0}, 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.

h˙(x)=h(x)xx˙=h(x)xf(x)Lfh(x)+h(x)xg(x)Lgh(x)u

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.

Shows a simple control barrier function surface and contour. The 3D plot displays the barrier function and level sets; the 2D plot highlights the safe set boundary (circle) with safe region inside and unsafe outside. Arrows indicate the gradient direction toward safety.

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:

h˙(x)=Lfh(x)+Lgh(x)uLgh(x)0

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.

hr(x)=Lfrh(x)+LgLfr1h(x)u

The function h(x) has a higher relative degree r until the following condition is satisfied.

LgLfr1h(x)0

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 Lfh(x)=hxf(x) and Lfih(x)=Lfi1h(x)xf(x).

  • LgLfih is given by LgLfih(x)=Lfih(x)xg(x).

Control Barrier Function Constraints

The control barrier function constraint for relative degree 1 is described by:

h˙(x,u)α(h(x))

Here α(h(x)) is an extended class Κ function. Typically, this function is of the following form.

α(h(x))=γhβ(x)

Therefore, in standard form, you can write the CBF inequality as:

Lfh(x)+Lgh(x)uγhβ

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:

hr(x,u)α(h(x))

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:

Lfrh(x)+LgLfr1h(x)uKαηh

Here:

ηh=[h(x)Lfh(x)Lfr1h(x)].

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:

Lfrh(x)+LgLfr1h(x)ui=0r1γiLfih(x)

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:

Lfrh(x)+LgLfr1h(x)ui=0r1γi+1(Lfih)βi+1(x)

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.

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 |uu0|2 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 DegreeConstraint Equation
First orderLfh+Lghu+γ1hβ10uminuumax
Second orderLf2h+LgLfhu+γ1hβ1+γ2(Lfh)β20uminuumax
Third orderLf3h+LgLf2hu+γ1hβ1+γ2(Lfh)β2+γ3(Lf2h)β30uminuumax
Fourth orderLf4h+LgLf3hu+γ1hβ1+γ2(Lfh)β2+γ3(Lf2h)β3+γ4(Lf3h)β40uminuumax

Implementation Workflow

To implement CBF constraints, use these steps.

  1. Define the system dynamics in control-affine form x˙=f(x)+g(x)u.

  2. Define a control barrier function h(x) that encodes the desired safety constraint.

  3. Determine the relative degree by differentiating h(x) until the input term u appears explicitly.

  4. Compute the required Lie derivatives and provide them as block inputs.

  5. Connect the baseline controller input u0 and the optional action bounds umin and umax.

  6. 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.

Modified control structure, with Control Barrier Function block inserted between the baseline controller and plant.

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

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

|

Topics