RepositoryPythonUSUnited States
tkkim-robot

tkkim-robot/online_adaptive_cbf

Implementation of the Online Adaptive CBF for safety-critical navigation for input constrained systems.

68stars
8forks
1issues
1views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: cbf-learning

#1 Repository of the week

1
TINIX TRENDING·Topic: obstacle-avoidance

#1 Repository of the week

1
TINIX TRENDING·Topic: cbf

#1 Repository of the week

online_adaptive_cbf

This repository contains the implementation of an online adaptive framework for Control Barrier Functions (CBFs) in input-constrained nonlinear systems. The algorithm dynamically adapts CBF parameters to optimize performance while ensuring safety.

Features

  • Implementation of the Probabilistic Ensemble Neural Network (PENN) which offers parallelized inference without an outer for loop. The predicted output can be interpreted as a Gaussian Mixture Model (GMM). (see Kim et al.)
  • Measurement of closed-form epistemic uncertainty from the PENN model's predictions. (see Kim et al.)
  • Integration with the safe_control repository for simulating robotic navigation, offering various robot dynamics, controllers, and RGB-D type sensor simulation.
  • Implementation of the Online Adaptive ICCBF, adapting ICCBF parameters online based on the robot's current state and nearby environment.

Installation

To install this project, follow these steps:

  1. Clone the repository:

    git clone --recursive https://github.com/tkkim-robot/online_adaptive_cbf.git
    cd online_adaptive_cbf
    

    If you've already cloned the repository without the --recursive flag, you can initialize and update the submodules with:

    submodule update --init --recursive
    
  2. (Optional) Create and activate a virtual environment

  3. Install the package and its dependencies:

    python -m pip install -e .
    

    BarrierNet dependencies are optional:

    python -m pip install -e ".[barriernet]"
    

    Or, install packages manually (see setup.py).

Getting Started

Familiarize with APIs and examples with the scripts in online_adaptive_cbf.py

Basic Example

You can run our test example by:

python online_adaptive_cbf.py

The MPC-CBF framework is implemented in our safe_control repository. It imports LocalTrackingController class and uses the mpc_cbf implementation:

from safe_control.tracking import LocalTrackingController
controller = LocalTrackingController(x_init, robot_spec,
                                control_type='mpc_cbf')

Then, it uses OnlineCBFAdapter to adapt the CBF parameters online.

online_cbf_adapter = OnlineCBFAdapter(nn_model, scaler)

for _ in range(int(tf / self.dt)):
   ret = controller.control_step()
   controller.draw_plot()

   best_gamma0, best_gamma1 = online_cbf_adapter.cbf_param_adaptation(controller)
   controller.pos_controller.cbf_param['alpha1'] = best_gamma0
   controller.pos_controller.cbf_param['alpha2'] = best_gamma1    

You can also test with compared methods:

  • Fixed CBF parameters:
    • mpc_cbf with conservatie fixed parameters: Set lower values to CBF parameters. (* MPC-CBF: An MPC controller using discrete-time CBF, ref: [1])
         controller.pos_controller.cbf_param['alpha1'] = {low value}
         controller.pos_controller.cbf_param['alpha2'] = {low value}
      
    • mpc_cbf with aggressive fixed parameters: Similarly, set higher values to CBF parameters.
  • Adaptive parameter methods:
    • optimal_decay_cbf_qp: A modified CBF-QP for point-wise feasibility guarantee (ref: [2])
      controller = LocalTrackingController(..., control_type='optimal_decay_cbf_qp')
      
    • optimal_decay_mpc_cbf: The same technique applied to MPC-CBF (ref: [3])
      controller = LocalTrackingController(..., control_type='optimal_decay_mpc_cbf')
      

The sample results from the basic example:

MPC-CBF w/ low parametersMPC-CBF w/ high parameters
Optimal Decay CBF-QPOptimal Decay MPC-CBF
Ours (Online Adaptive MPC-ICCBF)

The green point is the goal location, and the gray circles are the obstacles that are known a priori.

Live Simulation Preview

Use examples/run_simulation.py to interactively preview the scenarios with the safe_control renderer:

python examples/run_simulation.py --list
python examples/run_simulation.py --case narrow --dynamics quad2d --method ours_gat --backend MacOSX
python examples/run_simulation.py --case wide --dynamics dynamic_unicycle --method ours_gat --hold

Useful flags are --case narrow|wide, --dynamics, --method, --max-t, --backend, --pause, and --hold.

Paper Media

Warning: This feature requires a lot of computation time. For interactive visualization, use examples/run_simulation.py

Paper figures and videos are generated with plot/generate_paper_media.py:

python plot/generate_paper_media.py --case narrow --format svg
python plot/generate_paper_media.py --case wide --format svg
python plot/generate_paper_media.py --case narrow --format mp4 --media individual
python plot/generate_paper_media.py --case wide --format mp4 --media all

Use --dynamics quad2d or --dynamics dynamic_unicycle,quad3d to generate a subset. Outputs are written under paper_media/. For final videos, do not pass --max-frames; that option is only for quick smoke tests and compresses playback.

Module Breakdown

Safety Loss Density Function

The safety loss density function is designed to quantify the collision risk between the robot and obstacles. This safety loss is computed based on the robot's state and the obstacles' locations.

Safety Loss

Data Generation

You can use data_generation.py to collect training dataset. It will store risk_level and deadlock_time as the ground truth.

The risk_level refers to the maximum safety loss value recorded during the navigation (see the illustration below).

Safety Loss during Navigation

PENN Prediction

To train the PENN model, use the script penn/train_data.py. An example of the prediction results after training is shown below:

Mean Predicted Risk Level

You can observe that the predicted risk level becomes higher as the CBF parameter increases, the distance to the obstacle decreases, the velocity increases, and the relative angle to the obstacle becomes smaller.

Distributionally Robust CVaR

Please refer to our repository cvar-gmm-filter for more details.

Visualize Prediction Results for CBF Parameters of Interest

plot/plot_realtime_gmm_predictions.py provides an online plotting tool to visualize the predicted GMM distribution of the candidate CBF parameters. Here is the example of visualizing the predicted risk_level with three candidates, without adapting the parameters.

Single ObstacleMultiple Obstacles

Citing

If you find this repository useful, please consider citing our paper:

@inproceedings{kim2025learning, 
    author    = {Kim, Taekyung and Kee, Robin Inho and Panagou, Dimitra},
    title     = {Learning to Refine Input Constrained Control Barrier Functions via Uncertainty-Aware Online Parameter Adaptation}, 
    booktitle = {IEEE International Conference on Robotics and Automation (ICRA)},
    shorttitle = {Online-Adaptive-CBF},
    year      = {2025}
}

Our paper with more theoretical analysis:

@inproceedings{kim2025learning, 
    author    = {Kim, Taekyung and Kee, Robin Inho and Panagou, Dimitra},
    title     = {Learning to Refine Input Constrained Control Barrier Functions via Uncertainty-Aware Online Parameter Adaptation}, 
    booktitle = {IEEE International Conference on Robotics and Automation (ICRA)},
    shorttitle = {Online-Adaptive-CBF},
    year      = {2025}
}

Here are some related projects/codes that you might be interested:

  • Visibility-Aware RRT*: Safety-critical Global Path Planning (GPP) using Visibility Control Barrier Functions

  • UGV Experiments with ROS2: Environmental setup for rovers using PX4, ros2 humble, Vicon MoCap, and NVIDIA VSLAM + NvBlox

Similar Projects

Discover other similar projects and AI models.

RepositoryPython
tkkim-robot/safe_control

Safety-critical controllers for single/multi robotic navigation: CBF-QP, MPC-CBF, and etc.

319
Oct 7, 2026
RepositoryPython
AtsushiSakai/PythonRobotics

Python sample codes and textbook for robotics algorithms.

31.0k
Nov 30, 2026
RepositoryPython
hanruihua/ir-sim

A Python-based lightweight robot simulator designed for navigation, control, and learning

1.2k
Dec 1, 2026
RepositoryPython
tkkim-robot/visibility_rrt

The Visibility-Aware RRT* implementation for safety-critical navigation with perception-limited robots.

65
Jan 15, 2026
RepositoryC++
ros-navigation/navigation2

ROS 2 Navigation Framework and System

5.1k
Nov 26, 2026
RepositoryPython
commaai/openpilot

openpilot is an operating system for robotics. Currently, it upgrades the driver assistance system on 300+ supported cars.

64.2k
Nov 26, 2026
Repository
Developer-Y/cs-video-courses

List of Computer Science courses with video lectures.

85.1k
Nov 28, 2026
RepositoryPython
ungoogled-software/ungoogled-chromium

Google Chromium, sans integration with Google

28.4k
Nov 25, 2026
RepositoryPython
earthtojake/text-to-cad

Design physical products with AI

28.0k
Dec 2, 2026