A ROS (catkin) package implementing a multi-mode control barrier function (CBF) safety supervisor for longitudinal vehicle control (adaptive cruise control). The node takes the acceleration requested by an untrusted nominal controller and modifies it when needed so that the ego vehicle keeps a safe space gap to the lead vehicle.
Unlike a single-mode CBF, which uses a fixed 15 m minimum space gap at every speed, the multi-mode CBF shrinks that margin to 5 m in slow, stop-and-go traffic. This allows higher vehicle density at low speeds. At higher speeds it restores the full margin.
This package was auto-generated with Simulink Coder (ROS Toolbox) from the Simulink model at:
Do not edit the generated C++ sources by hand. Make changes in the Simulink model and regenerate the package.
The method is described in Sanborn et al., Traffic Density with Multi-Mode Control Barrier Functions at Scale.
For an ego vehicle
The safety property requires the space gap to exceed a desired gap made of a time-gap term and a minimum distance:
From this property, the CBF control law is
The commanded acceleration is the more conservative of the CBF and nominal commands:
The multi-mode CBF uses the same control law. The value of
| Mode | Name | Accel. bound |
|
|---|---|---|---|
| Full range (same as the single-mode CBF) |
|
|
|
| Stop-and-go |
|
|
|
| Transition |
|
|
In the transition mode, the minimum gap blends smoothly between the two values as a sigmoid of ego velocity:
The lower acceleration limit in mode 3 lets the lead vehicle pull away, so the larger gap can be rebuilt before the controller returns to full-range mode.
stateDiagram-v2
direction LR
[*] --> FullRange
FullRange: q=1 full range
StopAndGo: q=2 stop-and-go
Transition: q=3 transition
FullRange --> StopAndGo: s ≥ τv + d1 − ε AND v ≤ v_slow for ≥ τ12
StopAndGo --> Transition: s ≥ τv + d2 − ε AND v ≥ v_fast
Transition --> StopAndGo: v ≤ v_slow
Transition --> FullRange: s ≥ τv + d1 − ε AND v > v_slow
-
1 → 2: the gap satisfies the full-range safety property, and the ego vehicle has been slow (
$v_n \le v_{\text{slow}}$ ) for at least$\tau_{1,2}$ seconds. -
2 → 3: the ego vehicle speeds up (
$v_n \ge v_{\text{fast}}$ ) while the gap satisfies the stop-and-go safety property. -
3 → 1: the gap has grown enough to satisfy the full-range safety property again (and
$v_n > v_{\text{slow}}$ ). -
3 → 2: the ego vehicle slows back down (
$v_n \le v_{\text{slow}}$ ). This check takes priority over 3 → 1.
The node always starts in mode 1.
| Constant | Value | Meaning |
|---|---|---|
| 2.0 s | Desired time gap | |
| 0.1 | CBF gain | |
| 15.0 m | Minimum gap, full-range mode | |
| 5.0 m | Minimum gap, stop-and-go mode | |
| 3.0 | Sigmoid gain for |
|
| 5.0 m/s | Low-speed threshold | |
| 7.5 m/s | High-speed threshold | |
| 0.1 m | Transition buffer | |
| 3.0 s | Time spent slow before entering stop-and-go (60 steps at 20 Hz) | |
| −3.0 m/s² | Minimum commanded acceleration | |
| 1.5 / 1.0 / 0.5 m/s² | Maximum acceleration per mode |
At every step (20 Hz, 0.05 s), the node does the following:
- It updates the mode state machine from
lead_distandcar/state/vel_x. - It computes
$u_{\text{cbf}}$ with the mode's$d^{\min}$ , usingrel_velas$\Delta v_n$ , and clamps it to the mode's$u^{\max}_q$ . This value is published onmultimodecbf_debug/cbf_acc. -
Creep hold (an addition beyond the paper): if the ego velocity is ≤
creep_velocity_limitand the clamped CBF acceleration is ≤creep_acceleration_limit, the node forces a command of −1.0 m/s². This holds the vehicle still instead of letting it creep forward at near-zero speed. - It takes the minimum of the CBF acceleration, the nominal command
cmd_accel_pre, and the creep-hold value, then saturates it below at −3.0 m/s². This result is published oncmd_accel.
Node name (default): multimodecbf. All messages are from std_msgs.
| Topic | Type | Description |
|---|---|---|
lead_dist |
std_msgs/Float64 |
Space gap to the lead vehicle, |
car/state/vel_x |
std_msgs/Float64 |
Ego longitudinal velocity, |
rel_vel |
std_msgs/Float64 |
Relative velocity |
cmd_accel_pre |
std_msgs/Float64 |
Acceleration requested by the nominal (untrusted) controller, |
| Topic | Type | Description |
|---|---|---|
cmd_accel |
std_msgs/Float64 |
Safe commanded acceleration sent to the vehicle (m/s²) |
multimodecbf_debug/cbf_acc |
std_msgs/Float64 |
CBF acceleration |
multimodecbf_debug/cbf_mode |
std_msgs/Int8 |
Active mode: 1 = full range, 2 = stop-and-go, 3 = transition |
multimodecbf_debug/cbf_active |
std_msgs/Int8 |
1 if cmd_accel differs from cmd_accel_pre (the CBF modified the nominal command), else 0
|
Queue sizes are 1 for all topics. Before a topic has received its first message, its input is treated as 0.
| Parameter | Type | Default | Description |
|---|---|---|---|
creep_velocity_limit |
double | 0.1 |
Ego velocity (m/s) at or below which creep hold may engage |
creep_acceleration_limit |
double | 0.0 |
CBF acceleration (m/s²) at or below which creep hold engages when the vehicle is below creep_velocity_limit |
The node reads the parameters every step, so you can change them at runtime with rosparam set. They are resolved with the node's public NodeHandle, which means they are relative to the node's namespace and are not private (~) parameters. A <param> nested inside a <node> tag in a launch file creates a private parameter (/<node_name>/creep_velocity_limit), which this node does not read. Set the parameters at the namespace level instead, or push the node into a namespace with <group ns="...">.
This is a ROS 1 catkin package that depends on roscpp and std_msgs.
cd ~/catkin_ws
catkin_make # or: catkin build multimodecbf
source devel/setup.bash
rosrun multimodecbf multimodecbfRemap topics as needed for your vehicle stack, e.g.:
rosrun multimodecbf multimodecbf cmd_accel:=new_cmd_accel lead_dist:=lead_dist_extra- Simulink source model: https://github.com/jmscslgroup/multimodecbf_simulink
- Traffic-scale simulations and plots from the paper: https://github.com/jmscslgroup/multi-mode_cbf_simulation
To cite the usage of this repository, use the following:
Kate Sanborn, George Gunter, Daniel B. Work, Ricardo G. Sanfelice, Jonathan Sprinkle. "Traffic Density with Multi-Mode Control Barrier Functions at Scale." in 2026 IEEE International Conference on Intelligent Transportation Systems (ITSC), (in press) 2026.
or using bibtex:
@inproceedings{sanborn2026single,
author = {Sanborn, Kate and Gunter, George and Work, Daniel B. and Sanfelice, Ricardo G. and Sprinkle, Jonathan},
title = {Traffic Density with Multi-Mode Control Barrier Functions at Scale},
booktitle = {2026 IEEE International Conference on Intelligent Transportation Systems (ITSC)},
year = {2026},
note = {in press}
}
The single-mode CBF this work builds on:
G. Gunter, M. W. Nice, M. Bunting, J. Sprinkle, and D. B. Work, "Can control barrier functions keep automated vehicles safe in live freeway traffic?," in 2025 ACM/IEEE 15th International Conference on Cyber-Physical Systems (ICCPS), 2025.