Control Barrier Function
- Also called: CBF, barrier function, CBF-QP
- Category: Control › Feedback control
- Tags: safety, nonlinear-control, optimization, quadratic-programming, safety-filter, collision-avoidance
A function of a robot's state whose sign marks a safe set, used to constrain control inputs so that a system starting inside the safe set provably never leaves it.
Definition
Control barrier functions (CBFs) are a tool from nonlinear control theory for enforcing safety constraints on dynamical systems. A safe set is described as the region where a scalar function h(x) of the state is non-negative, for example the distance to an obstacle minus a margin. A control barrier function adds a condition on how fast h may decrease: the control input must keep the time derivative of h above a negative function of h itself. If this condition holds at every instant, the safe set is forward invariant, meaning a system that starts safe stays safe.
The formulation most used in robotics was developed by Aaron Ames and colleagues in the mid-2010s. For control-affine systems, whose dynamics have the form ẋ = f(x) + g(x)u, the barrier condition is linear in the control input u. A safe input can therefore be found online by solving a small quadratic program (QP) at each control step: find the input closest to a desired nominal command, subject to the barrier constraint and any actuator limits.
This QP is often called a safety filter. Any controller, whether a hand-tuned tracking controller, a planner or a learned policy, proposes a command, and the CBF-QP changes it only as much as needed to satisfy the safety constraint. CBFs pair naturally with control Lyapunov functions (CLFs), which encode stability or tracking goals; a combined CLF-CBF QP trades performance against safety while treating safety as a hard constraint.
Practical use raises several issues. Finding a valid barrier function for complex geometry or high-dimensional robots can be difficult. When the constraint does not depend directly on the input, such as a position limit on a robot commanded through accelerations, extensions such as exponential or high-order CBFs are needed. Guarantees hold only as far as the model is accurate, so robust and data-driven variants account for model error, input limits and sampling time. CBF constraints can also be placed inside a model predictive control problem, so the controller looks ahead over a horizon instead of acting only on the current state.
Why it matters
Robots increasingly operate near people, obstacles and their own physical limits, and control barrier functions offer a mathematically grounded way to enforce those limits regardless of which controller generates the nominal command. Because the safety filter is a small optimization problem, it can run at control rates on embedded hardware, which makes formal safety arguments practical rather than purely theoretical.
Key applications
- Collision avoidance — keeping mobile robots, drones and manipulators a safe distance from obstacles
- Safety filters for learned policies — minimally modifying commands from reinforcement learning or imitation learning controllers
- Legged and humanoid robots — enforcing constraints on foot placement, balance or self-collision
- Multi-robot systems — maintaining separation between robots in formations and swarms
- Automated driving — keeping safe following distances in adaptive cruise control
In practice
A team typically starts by writing safety requirements as inequalities on the state, such as minimum distance to obstacles, joint limits or a region for foot placement, and turns each into a barrier function h(x). The robot's existing controller or learned policy produces a nominal command, and at every control cycle a QP solver such as OSQP or qpOASES finds the closest command that satisfies all barrier constraints and actuator bounds. Engineers tune the extended class-K function, often a simple linear gain on h, to set how early the filter intervenes, and they test with deliberately unsafe nominal commands to confirm the filter holds the boundary. Because the QP can become infeasible when constraints conflict or inputs saturate, the system also needs a defined fallback behavior.
Common misconceptions
- A CBF guarantees safety on the real robot unconditionally — the guarantee holds for the model used; unmodeled dynamics, delays and input limits require robust formulations and margins
- CBFs replace the main controller — they act as a filter around a nominal controller and only intervene near the boundary of the safe set
- Any distance function is a valid CBF — the function must satisfy the barrier condition given the system's actuation, which many naive choices with high relative degree do not
- The CBF-QP is always solvable — conflicting constraints or actuator saturation can make it infeasible, so a fallback is needed
Who should know this
- Control engineers designing safety-critical robot controllers
- Robot learning researchers adding safety layers to learned policies
- Drone and autonomous vehicle developers
- Graduate students studying nonlinear and optimization-based control
Related technologies
- Control Lyapunov Function
- Quadratic Programming
- Model Predictive Control
- Safety Filter
- Hamilton-Jacobi Reachability
- OSQP
Related terms
Related projects
- Drake: MIT robotics toolbox for model-based dynamics, optimization, and control system design
- GTSAM: Factor-graph optimization library powering many modern SLAM backends
- PyRoki: Modular Python toolkit for kinematic optimization across CPU, GPU, and TPU via JAX
- PyPose: PyTorch library for differentiable robotics with deep learning and Lie group optimization
- mink: Python inverse kinematics library built on MuJoCo supporting 20+ robot platforms
- NeuPAN: Real-time end-to-end planner that maps raw lidar points directly to robot actions
Videos
- Lec 40 Control Barrier Function (CBF): NPTEL - Indian Institute of Science, Bengaluru