Skip to content

Berk-Tosun/cbf-cartpole

Repository files navigation

cbf-cartpole

Introduction

Following repository is a minimalistic environment for experimenting with Control Barrier Functions (CBF).

The classical benchmark cartpole is used as the plant model. To keep it simple no simulator is used; instead, full non-linear dynamics of the cartpole is integrated.

Folder structure (ordered with increasing difficulty):

  • acc.py: Most well-known, simple example: adaptive cruise control via CBF-QP. (not related to cartpole)

  • cartpole.py: Cartpole dynamics and simulation, all controllers use it as plant

  • nominal_control.py: Nominal controllers

  • cbf_qp.py: Safety-Critical control with classical CBF, constrain cart velocity

CBF Enabled CBF Disabled
CBF Enabled CBF Disabled
  • ecbf_qp.py: Exponential CBF with known model, constrain cart position
  • cbf_qp_learning: Safety-Critical control with model uncertainty, CBF + learning (TODO)
  • ecbf_qp_learning: Exponential CBF with unknown model, ECBF + learning (TODO)
  • cbf_qp_id.py: CBF-QP embedded into inverse dynamics formulation.

Installation

  1. Clone the repository
git clone https://github.com/Berk-Tosun/cbf-cartpole
  1. Install required packages
pip install -r requirements.txt

Getting Started

Most python files in this project have a main guard. It means you can directly run them, e.g.:

python cbf_qp.py

This will generate one of the figures given in the introduction section.

What is CBF?