## Barrier Certificate Enforcement for Control Design

In optimization-based control, a barrier certificate defines a safety set of the desired states of a system. A control barrier function is used to find a control law such that the states remain in the safety set.

### Barrier Certificate Enforcement Block

The Barrier Certificate Enforcement block, which requires Optimization Toolbox™ software, computes the modified control actions that are closest to specified control actions subject to barrier certificate constraints and action bounds. The block uses a quadratic programming (QP) solver to find the control action u that minimizes the function ${|u-{u}_{0}|}^{2}$ in real time. Here, u0 is the unmodified control action from the controller.

The solver applies the following constraints to the optimization problem.

`$\begin{array}{l}{q}_{x}{f}_{x}+{q}_{x}{g}_{x}u+\gamma {h}_{x}^{\beta }\ge 0\\ {u}_{\mathrm{min}}\le u\le {u}_{\mathrm{max}}\end{array}$`

Here:

• fx and gx are functions defined by the plant dynamics $\stackrel{˙}{x}=f\left(x\right)+g\left(x\right)u$.

• hx is the control barrier function.

• qx is the partial derivative of the control barrier function over states x.

• γ is the constraint factor.

• β is the constraint power.

• umin is a lower bound for the control action.

• umax is an upper bound for the control action.

Since the Barrier Certificate Enforcement block modifies 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 Barrier Certificate Enforcement block 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.

### Control Barrier Function

Consider plant dynamics of the following form.

`$\stackrel{˙}{x}=f\left(x\right)+g\left(x\right)u$`

The control barrier function h(x) defines a safety set $\left\{x:h\left(x\right)\ge 0\right\}$, that is, an invariant set where any trajectory starting inside the set remains within the set.

For this invariant set, the constraint is described by:

`$\stackrel{˙}{h}\left(x,u\right)\ge -\alpha \left(h\left(x\right)\right)$`

Therefore, you can define a constraint that depends on the control barrier function and the system dynamics as follows.

`$\frac{\partial h}{\partial x}f\left(x\right)+\frac{\partial h}{\partial x}g\left(x\right)u\ge -\alpha \left(h\left(x\right)\right)$`

Here α(h(x)) is an extended class Κ function. Using the Barrier Certificate Enforcement block, you can specify a function of the following form.

`$\alpha \left(h\left(x\right)\right)=\gamma {h}^{\beta }\left(x\right)$`

For an example that uses a simple control barrier function, see Enforce Barrier Certificate Constraints for PID Controllers.

For an example that defines a control barrier function to avoid collisions between three robots, see Enforce Barrier Certificate Constraints for Collision-Free Multi-Robot System. This example 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.