Chapter 13: Safety-Critical Robot Control (Technical Layer Only)
Lesson 1: Control Barrier Functions (CBF) Fundamentals
This lesson introduces Control Barrier Functions (CBFs) as a rigorous mathematical tool to guarantee safety of robot motion by enforcing forward invariance of constraint sets. We work with control-affine robot models, define safe sets, derive CBF conditions, and show how they induce constrained control laws that minimally modify a nominal controller. Simple 1D examples are implemented in Python, C++, Java, MATLAB/Simulink, and Wolfram Mathematica.
1. Safety Sets and Control-Affine Robot Models
We assume the robot dynamics, after prior modeling in joint or task space, can be written in control-affine form
\[ \dot{x} = f(x) + g(x)u, \quad x \in \mathbb{R}^n,\; u \in \mathbb{R}^m, \]
where \( f:\mathbb{R}^n \to \mathbb{R}^n \) is the drift (natural robot dynamics) and \( g:\mathbb{R}^n \to \mathbb{R}^{n \times m} \) collects input directions. Most robot dynamics (e.g. joint-space rigid-body dynamics) can be brought to this form after defining the state \( x \) appropriately (e.g. positions and velocities).
A safe set is encoded by a continuously differentiable function \( h:\mathbb{R}^n \to \mathbb{R} \):
\[ \mathcal{C} := \{ x \in \mathbb{R}^n \mid h(x) \ge 0 \}, \quad \partial\mathcal{C} := \{ x \mid h(x) = 0 \}, \quad \mathrm{Int}(\mathcal{C}) := \{ x \mid h(x) > 0 \}. \]
Intuitively, \( h(x) \) measures the signed distance to the constraint: joint limits, minimum distance to obstacles, torque envelopes, etc. Safety means that once the state is inside \( \mathcal{C} \), it should never leave. Formally:
Definition (Forward invariance). A set \( \mathcal{C} \subset \mathbb{R}^n \) is forward invariant for the closed-loop system if \( x(0) \in \mathcal{C} \Rightarrow x(t) \in \mathcal{C} \) for all \( t \ge 0 \).
Control Barrier Functions provide inequalities on the control input that guarantee forward invariance of \( \mathcal{C} \).
flowchart TD
X["Robot state x"] --> N["Nominal controller u_nom(x)"]
N --> F["Safety filter (CBF constraint)"]
F --> U["Safe control u_safe"]
U --> DYN["Robot dynamics x_dot = f(x) + g(x) u_safe"]
DYN --> X
F -->|uses| H["Safe set C = { x | h(x) >= 0 }"]
2. Lie Derivatives and Safety Constraints
The evolution of the barrier function \( h(x) \) along trajectories of the system is obtained via the chain rule:
\[ \dot{h}(x) = \frac{\partial h}{\partial x}(x)\,\dot{x} = \frac{\partial h}{\partial x}(x)\big(f(x) + g(x)u\big). \]
The terms \( L_f h(x) := \frac{\partial h}{\partial x}(x) f(x) \) and \( L_g h(x) := \frac{\partial h}{\partial x}(x) g(x) \) are the Lie derivatives of \( h \) along \( f \) and \( g \). Thus we can write
\[ \dot{h}(x) = L_f h(x) + L_g h(x) u. \]
Safety constraints will be inequalities of the form \( \dot{h}(x) \ge -\alpha(h(x)) \), where \( \alpha \) is a suitable comparison function.
Definition (Extended class-\( \mathcal{K} \) function). A continuous function \( \alpha:\mathbb{R} \to \mathbb{R} \) is of extended class-\( \mathcal{K} \) if it is strictly increasing and \( \alpha(0)=0 \). A typical example is \( \alpha(s) = \gamma s \) with \( \gamma > 0 \).
The inequality
\[ L_f h(x) + L_g h(x) u \ge -\alpha(h(x)) \]
will be the central CBF constraint that admissible controls must satisfy to guarantee safety.
3. Barrier Functions and Forward Invariance
Before introducing control-dependent CBFs, consider the simpler situation of an autonomous system \( \dot{x} = F(x) \) and a barrier function \( h(x) \). A classical barrier condition for invariance of \( \mathcal{C} = \{x \mid h(x) \ge 0\} \) is:
\[ h(x) = 0 \;\Rightarrow\; \dot{h}(x) \ge 0. \]
For control systems, we want to choose inputs so that an analogous condition holds along closed-loop trajectories. A stronger but convenient condition uses an extended class-\( \mathcal{K} \) function:
\[ \dot{h}(x) \ge -\alpha(h(x)). \]
This inequality ensures that when \( h(x) \) approaches zero, its derivative cannot be too negative, preventing crossings of the boundary in finite time.
Lemma (Comparison-based invariance). Let \( h:\mathbb{R}^n \to \mathbb{R} \) be locally Lipschitz and \( \alpha \) extended class-\( \mathcal{K} \). Suppose along a trajectory \( x(t) \) of the closed-loop system we have
\[ \dot{h}(x(t)) \ge -\alpha(h(x(t))) \quad \text{for almost all } t \ge 0. \]
If \( h(x(0)) \ge 0 \), then \( h(x(t)) \ge 0 \) for all \( t \ge 0 \). Thus \( \mathcal{C} \) is forward invariant.
Sketch of proof. Consider the scalar differential inequality \( \dot{z}(t) = -\alpha(z(t)) \), \( z(0)=h(x(0)) \ge 0 \). By comparison principles (commonly used in Lyapunov theory), \( h(x(t)) \ge z(t) \) for all \( t \). Since \( z(t) \ge 0 \) (because \( \alpha(z) \) vanishes at 0 and is increasing), \( h(x(t)) \) cannot become negative.
Control Barrier Functions enforce exactly this differential inequality by constraining the control input.
4. Zeroing Control Barrier Functions (ZCBFs)
We now formalize Control Barrier Functions for control-affine systems. We restrict to the common case in which \( h(x) \) has relative degree one, meaning \( L_g h(x) \neq 0 \) on the boundary \( \partial\mathcal{C} \). Higher relative degree cases require high-order CBFs and will be treated later in the chapter.
Definition (Zeroing Control Barrier Function). Let \( \mathcal{C} = \{ x \mid h(x) \ge 0 \} \) with \( h \in C^1(\mathbb{R}^n,\mathbb{R}) \). A function \( h \) is called a Zeroing Control Barrier Function (ZCBF) for the system \( \dot{x} = f(x) + g(x)u \) on a set \( \mathcal{D} \supset \mathcal{C} \) if there exists an extended class-\( \mathcal{K} \) function \( \alpha \) such that
\[ \sup_{u \in \mathcal{U}} \big( L_f h(x) + L_g h(x) u + \alpha(h(x)) \big) \ge 0 \quad \forall x \in \mathcal{D}, \]
where \( \mathcal{U} \subset \mathbb{R}^m \) is the admissible input set.
For each state \( x \), define the CBF-admissible control set
\[ \mathcal{K}_{\mathrm{CBF}}(x) := \big\{ u \in \mathcal{U} \,\big|\, L_f h(x) + L_g h(x) u + \alpha(h(x)) \ge 0 \big\}. \]
Theorem (Forward invariance via ZCBF). Assume \( h \) is a ZCBF on \( \mathcal{D} \) and that \( \mathcal{K}_{\mathrm{CBF}}(x) \) is nonempty for all \( x \in \mathcal{C} \). Let \( k:\mathcal{D} \to \mathcal{U} \) be any locally Lipschitz feedback with \( k(x) \in \mathcal{K}_{\mathrm{CBF}}(x) \) for all \( x \in \mathcal{C} \). Then \( \mathcal{C} \) is forward invariant for the closed-loop system \( \dot{x} = f(x) + g(x)k(x) \).
Proof idea. Along closed-loop trajectories, \( u(t) = k(x(t)) \in \mathcal{K}_{\mathrm{CBF}}(x(t)) \), so
\[ \dot{h}(x(t)) = L_f h(x(t)) + L_g h(x(t))k(x(t)) \ge -\alpha(h(x(t))). \]
By the comparison-based invariance lemma, \( h(x(t)) \ge 0 \) for all time if \( h(x(0)) \ge 0 \). Thus trajectories that start in \( \mathcal{C} \) stay in \( \mathcal{C} \).
Note how \( \mathcal{K}_{\mathrm{CBF}}(x) \) defines a set of safe controls. Other objectives (tracking, energy minimization) must be realized within this set.
5. CBF-Based Safety Filters and Quadratic Programs
In practice, we often start with a nominal controller \( u_{\mathrm{nom}}(x) \) designed for performance (tracking, optimality) but not guaranteed safe. The CBF approach wraps this nominal law with a safety filter that solves, at each control step, a small optimization problem:
\[ \begin{aligned} u^\star(x) &= \arg\min_{u \in \mathcal{U}} (u - u_{\mathrm{nom}}(x))^\top W (u - u_{\mathrm{nom}}(x)) \\ \text{s.t. } & L_f h(x) + L_g h(x) u + \alpha(h(x)) \ge 0, \end{aligned} \]
where \( W \succ 0 \) is a weighting matrix (often identity). This is a quadratic program (QP) in \( u \) with a single linear inequality constraint if the system is control-affine and \( \alpha \) is linear.
Under mild conditions (e.g. feasibility and convexity of \( \mathcal{U} \)), this QP has a unique solution, which belongs to \( \mathcal{K}_{\mathrm{CBF}}(x) \) and is the closest safe input to the nominal control in the metric induced by \( W \).
flowchart TD
S["Measure x_k"] --> NOM["Compute u_nom = k_nom(x_k)"]
NOM --> QP["Solve QP: min ||u - u_nom||^2 s.t. CBF constraint"]
QP --> USAFE["Apply u_safe = u_star"]
USAFE --> PLANT["Robot plant"]
PLANT --> S
Later lessons in this chapter will extend this formulation to joint and task-space constraints with multiple CBFs, and to input limits and disturbance robustness.
6. 1D Example — Analytic Safety Filter
Consider the simplest possible robot model:
\[ \dot{x} = u, \quad x \in \mathbb{R},\; u \in \mathbb{R}. \]
Interpret \( x \) as the signed distance to an obstacle, with \( x \ge 0 \) safe. Take the barrier function \( h(x) = x \) and \( \alpha(s) = \gamma s \) with \( \gamma > 0 \). Then
\[ L_f h(x) = 0, \quad L_g h(x) = 1, \quad \dot{h}(x) = u. \]
The CBF constraint
\[ L_f h(x) + L_g h(x)u + \alpha(h(x)) \ge 0 \]
reduces to
\[ u + \gamma x \ge 0 \quad \Leftrightarrow \quad u \ge -\gamma x. \]
Thus the safe input set is the half-line \( \mathcal{K}_{\mathrm{CBF}}(x) = \{ u \in \mathbb{R} \mid u \ge -\gamma x \} \).
If we use the QP with scalar input and identity weight, the solution is just the Euclidean projection of \( u_{\mathrm{nom}} \) onto this half-line:
\[ u^\star(x) = \max\big(u_{\mathrm{nom}}(x),\, -\gamma x\big). \]
So near the constraint boundary (\( x \approx 0 \)), the CBF acts like a one-sided saturation preventing negative velocities that would decrease \( h(x) \) too fast.
7. Python Implementation — 1D CBF Safety Filter
Below is a minimal Python implementation of the 1D CBF safety filter from Section 6. A proportional nominal controller tries to track a reference \( x_{\mathrm{ref}} \), while the CBF prevents \( x \) from becoming negative.
import numpy as np
import matplotlib.pyplot as plt
def nominal_control(x, x_ref, k_p=2.0):
# Simple proportional controller (no safety)
return -k_p * (x - x_ref)
def cbf_filter_1d(x, u_nom, gamma=5.0):
# CBF constraint: u >= -gamma * x
u_min = -gamma * x
return max(u_nom, u_min)
def simulate_cbf_1d(x0, x_ref, dt=0.001, T=2.0, k_p=2.0, gamma=5.0):
N = int(T / dt)
xs = np.zeros(N + 1)
us_nom = np.zeros(N)
us_safe = np.zeros(N)
t = np.linspace(0.0, T, N + 1)
xs[0] = x0
for k in range(N):
x = xs[k]
u_nom = nominal_control(x, x_ref, k_p)
u_safe = cbf_filter_1d(x, u_nom, gamma)
us_nom[k] = u_nom
us_safe[k] = u_safe
# Integrate dynamics: x_dot = u_safe
xs[k + 1] = x + dt * u_safe
return t, xs, us_nom, us_safe
if __name__ == "__main__":
# Start inside the safe set but close to the boundary
x0 = 0.05
x_ref = -1.0 # nominal controller wants to cross into unsafe region
t, xs, u_nom, u_safe = simulate_cbf_1d(x0, x_ref)
plt.figure()
plt.plot(t, xs)
plt.axhline(0.0, linestyle="--") # safety boundary
plt.xlabel("time [s]")
plt.ylabel("x(t)")
plt.title("State trajectory with CBF safety filter")
plt.figure()
plt.plot(t[:-1], u_nom, label="u_nom")
plt.plot(t[:-1], u_safe, label="u_safe")
plt.axhline(0.0, linestyle="--")
plt.xlabel("time [s]")
plt.ylabel("control input")
plt.legend()
plt.show()
For a real manipulator, the role of \( x \) would be
played by a function of joint angles (e.g. distance to joint limits) or
task-space coordinates (e.g. distance to workspace boundaries).
Libraries such as roboticstoolbox or
pinocchio can be used to compute kinematics, while the same
CBF logic applies to the safety filter.
8. C++ Implementation — 1D CBF Filter Function
A simple C++ implementation of the same safety filter can be used inside a high-frequency control loop for a robot controller node (e.g. in ROS).
#include <iostream>
#include <algorithm>
double nominal_control(double x, double x_ref, double k_p = 2.0)
{
return -k_p * (x - x_ref);
}
double cbf_filter_1d(double x, double u_nom, double gamma = 5.0)
{
// CBF constraint: u >= -gamma * x
double u_min = -gamma * x;
return std::max(u_nom, u_min);
}
int main()
{
double dt = 0.001;
double T = 2.0;
int N = static_cast<int>(T / dt);
double x = 0.05; // initial state
double x_ref = -1.0;
for (int k = 0; k < N; ++k)
{
double u_nom = nominal_control(x, x_ref);
double u_safe = cbf_filter_1d(x, u_nom);
// integrate: x_dot = u_safe
x += dt * u_safe;
if (k % 100 == 0)
{
std::cout << "t = " << k * dt
<< ", x = " << x
<< ", u_nom = " << u_nom
<< ", u_safe = " << u_safe
<< std::endl;
}
}
return 0;
}
For full robot applications, one would typically compute joint or
task-space distances using a library such as Pinocchio or
RBDL and then apply the scalar or vector CBF constraints
component-wise or jointly via a QP solver (e.g. qpOASES,
OSQP).
9. Java Implementation — 1D CBF Filter
Java is sometimes used for high-level robot control or simulation environments. The same 1D CBF safety filter can be implemented as follows:
public class CBF1D {
public static double nominalControl(double x, double xRef, double kP) {
return -kP * (x - xRef);
}
public static double cbfFilter1D(double x, double uNom, double gamma) {
// CBF constraint: u >= -gamma * x
double uMin = -gamma * x;
return Math.max(uNom, uMin);
}
public static void main(String[] args) {
double dt = 0.001;
double T = 2.0;
int N = (int) (T / dt);
double x = 0.05;
double xRef = -1.0;
double kP = 2.0;
double gamma = 5.0;
for (int k = 0; k < N; ++k) {
double uNom = nominalControl(x, xRef, kP);
double uSafe = cbfFilter1D(x, uNom, gamma);
x += dt * uSafe;
if (k % 100 == 0) {
System.out.println("t = " + (k * dt)
+ ", x = " + x
+ ", u_nom = " + uNom
+ ", u_safe = " + uSafe);
}
}
}
}
For multi-dimensional robot states, Java linear algebra libraries such
as
EJML or Apache Commons Math can be used to
implement Lie derivatives and QP-based safety filters.
10. MATLAB/Simulink Implementation
In MATLAB, the 1D CBF safety filter can be expressed as a simple function. This function can then be used directly in scripts or inside a Simulink MATLAB Function block.
function u_safe = cbf_filter_1d(x, u_nom, gamma)
% CBF filter for 1D system x_dot = u
% Enforces x >= 0 with barrier h(x) = x and alpha(s) = gamma * s
u_min = -gamma * x; % from constraint u + gamma * x >= 0
u_safe = max(u_nom, u_min);
end
A simple MATLAB simulation using this filter:
dt = 1e-3;
T = 2.0;
N = round(T / dt);
x = zeros(1, N+1);
u_nom = zeros(1, N);
u_safe = zeros(1, N);
x(1) = 0.05;
x_ref = -1.0;
k_p = 2.0;
gamma = 5.0;
for k = 1:N
u_nom(k) = -k_p * (x(k) - x_ref);
u_safe(k) = cbf_filter_1d(x(k), u_nom(k), gamma);
x(k+1) = x(k) + dt * u_safe(k);
end
t = (0:N) * dt;
figure;
plot(t, x); hold on;
yline(0, "--");
xlabel("time [s]");
ylabel("x(t)");
title("1D CBF Safety Filter in MATLAB");
In Simulink, one typically builds the robot dynamics using integrator
blocks, computes the nominal control in a controller subsystem, and then
applies
cbf_filter_1d in a MATLAB Function block before sending the
filtered input to the plant.
11. Wolfram Mathematica Implementation
Mathematica can simulate CBF-based closed-loop systems via
NDSolve. The code below implements the 1D example:
kP = 2.0;
gamma = 5.0;
xRef = -1.0;
uNom[x_] := -kP (x - xRef);
uSafe[x_] := Max[uNom[x], -gamma x];
tmax = 2.0;
x0 = 0.05;
sol = NDSolve[{
x'[t] == uSafe[x[t]],
x[0] == x0
},
{x}, {t, 0, tmax}
];
Plot[Evaluate[{x[t]} /. sol], {t, 0, tmax},
AxesLabel -> {"t", "x(t)"},
PlotLegends -> {"x(t)"},
Epilog -> {Dashed, Line[{ {0, 0}, {tmax, 0} }]}
]
For more complex robot models (e.g. multi-DOF manipulators), the state vector and barrier functions can be defined symbolically, and CBF inequalities can be manipulated and analyzed using Mathematica's symbolic capabilities before implementing them numerically.
12. Problems and Solutions
Problem 1 (Invariance proof with extended class-\( \mathcal{K} \)). Let \( h:\mathbb{R}^n \to \mathbb{R} \) be locally Lipschitz and let \( \alpha \) be an extended class-\( \mathcal{K} \) function. Suppose that along a closed-loop trajectory \( x(t) \) we have
\[ \dot{h}(x(t)) \ge -\alpha(h(x(t))) \quad \text{for almost all } t \ge 0, \]
and \( h(x(0)) \ge 0 \). Prove rigorously that \( h(x(t)) \ge 0 \) for all \( t \ge 0 \).
Solution. Define \( z(t) \) as the solution of the scalar ODE
\[ \dot{z}(t) = -\alpha(z(t)), \quad z(0) = h(x(0)). \]
Because \( \alpha(0)=0 \) and is strictly increasing, the right-hand side is nonpositive when \( z(t) \ge 0 \). Hence \( z(t) \) is nonincreasing, and since it starts nonnegative, it remains nonnegative for all \( t \ge 0 \).
The inequality for \( h \) can be written as \( \dot{h}(x(t)) + \alpha(h(x(t))) \ge 0 \). Standard comparison lemmas (see Lyapunov theory) state that if \( \dot{y}(t) \ge -\alpha(y(t)) \) and \( y(0) = z(0) \), then \( y(t) \ge z(t) \) for all \( t \ge 0 \). Applying this with \( y(t) = h(x(t)) \) yields \( h(x(t)) \ge z(t) \ge 0 \) for all \( t \). Therefore the set \( \mathcal{C} = \{ x \mid h(x) \ge 0 \} \) is forward invariant.
Problem 2 (ZCBF for 1D integrator). For the system \( \dot{x} = u \) and safe set \( \mathcal{C} = \{x \mid x \ge 0\} \), show that \( h(x) = x \) is a Zeroing Control Barrier Function with \( \alpha(s) = \gamma s \), \( \gamma > 0 \). Compute the admissible control set \( \mathcal{K}_{\mathrm{CBF}}(x) \).
Solution. We have \( h(x) = x \), so \( \partial h / \partial x = 1 \). For the dynamics \( \dot{x} = u \), \( f(x)=0 \), \( g(x)=1 \), hence \( L_f h(x) = 0 \), \( L_g h(x) = 1 \). The ZCBF condition is
\[ \sup_{u \in \mathbb{R}} \big( L_f h(x) + L_g h(x)u + \alpha(h(x)) \big) \ge 0. \]
Substituting gives \( \sup_{u \in \mathbb{R}} (u + \gamma x) = +\infty \), which is trivially \( \ge 0 \) for all \( x \). Thus the ZCBF condition holds. The admissible control set is
\[ \mathcal{K}_{\mathrm{CBF}}(x) = \big\{ u \in \mathbb{R} \mid u + \gamma x \ge 0 \big\} = \big\{ u \in \mathbb{R} \mid u \ge -\gamma x \big\}. \]
Problem 3 (Control bounds and feasibility). Consider again \( \dot{x} = u \) with safe set \( x \ge 0 \) and ZCBF \( h(x)=x \), \( \alpha(s)=\gamma s \). Suppose control inputs are bounded: \( \mathcal{U} = \{ u \in \mathbb{R} \mid |u| \le u_{\max} \} \). For which \( x \) is \( \mathcal{K}_{\mathrm{CBF}}(x) \cap \mathcal{U} \neq \emptyset \)?
Solution. The CBF admissible set is \( \mathcal{K}_{\mathrm{CBF}}(x) = \{ u \mid u \ge -\gamma x \} \). Intersecting with \( \mathcal{U} \) gives
\[ \mathcal{K}_{\mathrm{CBF}}(x) \cap \mathcal{U} = \{ u \mid -u_{\max} \le u \le u_{\max},\; u \ge -\gamma x \}. \]
This set is nonempty if and only if its lower bounds are compatible: \( -u_{\max} \le u_{\max} \) (always true) and the maximum of \( -u_{\max} \) and \( -\gamma x \) is at most \( u_{\max} \). The critical condition is that \( -\gamma x \le u_{\max} \), i.e. \( x \ge -u_{\max}/\gamma \).
Since we care only about \( x \ge 0 \), feasibility holds for all admissible states \( x \in \mathcal{C} \). However, if the safe set were \( x \ge x_{\min} > 0 \), then the margin \( x_{\min} \) and \( u_{\max} \) must satisfy \( x_{\min} \le u_{\max}/\gamma \) to guarantee feasibility.
Problem 4 (Intersection of safety constraints). Suppose we have two scalar safety constraints \( h_1(x) \ge 0 \) and \( h_2(x) \ge 0 \), each with its own ZCBF condition
\[ L_f h_i(x) + L_g h_i(x) u + \alpha_i(h_i(x)) \ge 0, \quad i = 1,2. \]
Show that if both inequalities are used as constraints in the QP, then any resulting control \( u^\star \) keeps the intersection \( \mathcal{C}_1 \cap \mathcal{C}_2 \) forward invariant, provided the feasible set is nonempty.
Solution. Let \( \mathcal{C}_i = \{ x \mid h_i(x) \ge 0 \} \). By the same argument used in the ZCBF theorem, if the closed-loop control satisfies both inequalities along trajectories starting in \( \mathcal{C}_1 \cap \mathcal{C}_2 \), then each \( h_i(x(t)) \ge 0 \) for all time. Hence \( x(t) \in \mathcal{C}_1 \) and \( x(t) \in \mathcal{C}_2 \) for all \( t \), meaning \( x(t) \in \mathcal{C}_1 \cap \mathcal{C}_2 \). The key requirement is that the intersection of admissible sets \( \mathcal{K}_{\mathrm{CBF},1}(x) \cap \mathcal{K}_{\mathrm{CBF},2}(x) \cap \mathcal{U} \) is nonempty for all \( x \in \mathcal{C}_1 \cap \mathcal{C}_2 \).
Problem 5 (CBF vs Lyapunov function). Let \( V(x) \) be a control Lyapunov function (CLF) for stabilization of an equilibrium \( x^\star \), satisfying
\[ \inf_{u \in \mathcal{U}} \big( L_f V(x) + L_g V(x)u + c V(x) \big) \le 0 \quad \text{for some } c > 0. \]
Explain how the CBF inequality conceptually differs from this CLF inequality, and why CBFs are naturally suited to safety (set invariance) rather than asymptotic stabilization.
Solution. The CLF inequality requires the existence of a control that makes \( \dot{V} \) negative enough so that \( V(x(t)) \to 0 \), yielding convergence to an equilibrium. It is about decrease of a scalar function that is positive definite around the target. In contrast, the CBF inequality is of the form
\[ L_f h(x) + L_g h(x)u + \alpha(h(x)) \ge 0, \]
which enforces that \( h(x(t)) \) does not decrease too fast and remain nonnegative, focusing on invariance of a set \( \mathcal{C} \) rather than convergence to a point. CLFs encode performance (stability), while CBFs encode constraints (safety). In many designs, both constraints are combined in a single QP to balance stabilization and safety.
13. Summary
In this lesson we introduced Control Barrier Functions as a systematic tool to impose hard safety constraints on robot motion. Starting from a control-affine model, we described safe sets via scalar functions \( h(x) \), used Lie derivatives to capture their evolution, and formulated ZCBF inequalities that guarantee forward invariance via extended class-\( \mathcal{K} \) comparison arguments.
We also showed how CBFs naturally integrate with existing nominal controllers through small QPs or simple projections (in the scalar case), and provided implementations in Python, C++, Java, MATLAB/Simulink, and Mathematica. Subsequent lessons in this chapter will build on these fundamentals to design robot-specific safe sets, multi-constraint CBF-QP controllers in joint and task space, and to handle input limits and more complex dynamics.
14. References
- Prajna, S., Jadbabaie, A., & Pappas, G. J. (2004). Safety verification of hybrid systems using barrier certificates. Hybrid Systems: Computation and Control, 477–492.
- Prajna, S., & Rantzer, A. (2007). Convex programs for temporal verification of nonlinear dynamical systems. SIAM Journal on Control and Optimization, 46(3), 999–1021.
- Ames, A. D., Xu, X., Grizzle, J. W., & Tabuada, P. (2017). Control barrier function based quadratic programs for safety critical systems. IEEE Transactions on Automatic Control, 62(8), 3861–3876.
- Xu, X., & Tabuada, P. (2015). Robustness of control barrier functions for safety critical control. IFAC-PapersOnLine, 48(27), 54–61.
- Wieland, P., & Allgöwer, F. (2007). Constructive safety using control barrier functions. In IFAC Conference on Analysis and Design of Hybrid Systems.
- Romdlony, M. Z., & Jayawardhana, B. (2016). Stabilization with guaranteed safety using control Lyapunov–barrier function. Automatica, 66, 39–47.
- Ames, A. D., Coogan, S., Egerstedt, M., Notomista, G., Sreenath, K., & Wabersich, K. P. (2019). Control barrier functions: Theory and applications. In European Control Conference (ECC), 3420–3431.
- Wang, L., & Ames, A. D. (2017). Safety barrier certificates for collisions-free multirobot systems. IEEE Transactions on Robotics, 33(3), 661–674.
- Prajna, S. (2006). Barrier certificates for nonlinear model validation. Automatica, 42(1), 117–126.
- Konda, R., & Ames, A. D. (2020). Characterizing the robustness of control barrier functions. IEEE Control Systems Letters, 4(1), 95–100.