Real-Time CBF-QP Safety Filter
- Real-Time CBF-QP Safety Filter is an optimization-based control strategy that minimally alters nominal inputs using control barrier functions embedded in a quadratic program to ensure safety.
- It employs closed-form, piecewise-affine solutions via state-space partitioning, guaranteeing forward invariance and significantly reducing computational loads through resource-aware updates.
- Empirical evaluations in aerospace, robotics, and safe reinforcement learning highlight its efficacy with reduced CPU times and minimal QP calls while preserving strict safety guarantees.
A real-time safety filter based on quadratic programming (QP) is an optimization-based control strategy that minimally modifies a nominal controller to guarantee that a dynamical system remains within a prescribed safe set for all time. The primary mathematical mechanism is the embedding of state constraints, expressed via control barrier functions (CBFs), into a convex QP solved at each control cycle. Modern approaches integrate QP-based CBF safety filters with closed-form, region-based formulas and resource-aware logic to maximize computational efficiency without compromising safety or performance (Mestres et al., 10 Dec 2025).
1. Mathematical Formulation of Real-Time CBF-QP Safety Filters
For a control-affine plant
and a continuously differentiable CBF that defines the safe set , real-time safety filtering is implemented by solving a QP at each sampling instant. The standard QP is
where is the nominal control input, is an extended class- function (typically linear), and the box constraints enforce actuator limits (Mestres et al., 10 Dec 2025). The linear CBF constraint guarantees forward invariance of .
2. Closed-Form QP Solution via State-Space Partitioning
Since the QP cost is strictly convex and constraints are affine, Karush-Kuhn-Tucker (KKT) conditions are necessary and sufficient for optimality. Denoting all constraints as for , the KKT system becomes: 0 Define, for each subset 1 of active constraints, the region of the state space: 2 where 3 stacks columns 4 for 5, 6 solves
7
and 8 (Mestres et al., 10 Dec 2025).
Within each region 9, the QP optimizer is piecewise-affine and given by 0, which delivers a partition of the state space into regions where the active constraint set is constant and each region admits a closed-form law. Transitions between regions occur when the active set changes, i.e., as 1 crosses constraint boundaries or the rank condition is violated.
3. Resource-Aware Computation and Algorithmic Pipeline
To improve computational efficiency, the resource-aware filter caches the previous active set 2 and checks at each new 3 if the current region is unchanged by verifying:
- 4,
- 5,
- 6.
If all tests pass, the cached closed-form solution is correct and is immediately applied. Otherwise, the current active set 7 is recomputed (e.g., by solving the QP), and the closed-form expression is updated accordingly. Pseudocode for the resource-aware CBF-QP is given in [(Mestres et al., 10 Dec 2025), Alg. 1]. This loop yields order-of-magnitude CPU savings in practice, as the full QP is only solved on region transitions.
Computational complexity for the region check step is dominated by 8 for matrix inversion and 9 for inequality testing, while full QP solves scale with 0 per iteration and can require multiple iterations.
4. Empirical Evaluation: Benchmark Scenarios
The explicit, resource-aware CBF-QP safety filter was demonstrated on multiple domains:
- Aircraft roll–yaw control: 1 states, 2 inputs, 3 constraints, sampled at 4. Average time per step: 5s (resource-aware) vs.\ 6s (pure QP), with only 8 region transitions per 3000 steps. All safety objectives met.
- Multi-quadrotor collision avoidance: 7, 8 constraints, with 9 sampling, achieving 0s/step vs.\ 1s, and only 112 region changes over 2000 steps.
- Safe reinforcement learning (RL): in high-dimensional RL navigation with up to 40 CBF constraints, CPU time per training iteration was reduced by a factor of 2–3 for increasing constraint counts, facilitating RL with real-time safe filtering (Mestres et al., 10 Dec 2025).
All scenarios verified forward invariance of the safe set and reproduced the exact closed-loop trajectories as would be obtained by solving the QP at every step, but with substantially reduced computational load.
| Scenario | pure-OSQP (μs) | resource-aware (μs) | QP calls |
|---|---|---|---|
| Aircraft | 40 ± 8 | 4.5 ± 1 | 8/3000 |
| Quadrotors | 130 ± 20 | 19 ± 4 | 112/2000 |
| Safe-RL | 85 ± 10 | 25 ± 5 | ≈10% |
5. Structural Properties and Theoretical Guarantees
- Forward invariance: The CBF-QP filter guarantees that the safe set 4 is forward-invariant under closed-loop dynamics, as the linear CBF constraint ensures that once the trajectory enters 5 it cannot exit through the boundary.
- Piecewise-smoothness and Lipschitz continuity: The closed-form region-based controller is piecewise-smooth and locally Lipschitz everywhere except possibly on the region boundaries; under LICQ (linear independence constraint qualification) and constraint regularity, this excludes chattering and ensures robust controller trajectories.
- Exact recovery of QP optimality: The resource-aware approach is exact, matching the QP solution at all times, provided the active set is correctly maintained.
- Computational robustness: The partitioning strategy reduces unnecessary QP solves as the system evolves within a given region, yielding consistent real-time operation at high sampling rates (Mestres et al., 10 Dec 2025).
6. Applicability, Integration, and Limitations
The explicit CBF-QP safety filter paradigm is applicable to a wide range of control-affine safety-critical systems, including but not limited to aerospace, robotics, and RL applications. It can be retrofitted around legacy or learned controllers, requires only knowledge of the CBF and actuator constraints, and is algorithmically modular.
Limitations include:
- The need to precompute or symbolically represent the constraint gradients and their dependence on 6.
- The approach presumes local Lipschitz continuity and non-degeneracy in the constraints; in singular or degenerate scenarios, additional analysis or regularization may be required.
- For extremely high-dimensional problems with rapidly switching active sets, the overhead of region tracking may approach that of direct QP solving, though the resource-aware method remains advantageous when active set transitions are infrequent.
7. Significance and Impact
The integration of explicit region-based formulas with resource-aware QP evaluation fundamentally advances the practicality of real-time safety filters, enabling safety-critical feedback loops to operate at kilohertz frequencies on standard hardware (Mestres et al., 10 Dec 2025). The framework preserves exact safety guarantees, offers strict minimal intervention on the nominal controller, and circumvents the computational bottleneck associated with generic QP solvers in high-frequency, multi-constraint environments. These features position the explicit CBF-QP safety filter as a cornerstone methodology for safety assurance in real-time embedded and learning-based control systems.