Skip to content

maxhcohen/ReducedOrderModelCBFs.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ReducedOrderModelCBFs

This repository contains a Julia package that implements various control barrier function (CBFs) techniques based on reduced-order models. The code here is based on a collection of papers (see related works at the end of this readme) and may be used to reconstruct many of the examples from our papers:

M. H. Cohen, T. G. Molnar, and A. D. Ames, "Safety-Critical Control of Autonomous Systems: Control Barrier Functions via Reduced-Order Models," Annual Reviews in Control, vol. 57, pp. 100947, 2024;

M. H. Cohen, R. K. Cosner, and A.D. Ames, "Constructive Safety-Critical Control: Synthesizing Control Barrier Functions for Partially Feedback Linearizable Systems," IEEE Control Systems Letters, 2024.

The code corresponding to the examples in the above papers can be found in the examples folder of this repo. If you find this code useful, please consider citing the above papers or some of the works mentioned at the end of this README.

Installation

The most reliable way to use this code would be to clone this repo, activate the corresponding Julia environment, and then run the code examples. Alternatively, you can directly add this repo as an unregistered Julia package by entering the Julia package manager and executing:

add https://github.com/maxhcohen/ReducedOrderModelCBFs.jl

Quick tutorial

We'll walk step-by-step through one of the examples that demonstrates the procedure used to construct CBFs via reduced-order models. The objective here is to design a controller for a double integrator to avoid an obstacle by extending a CBF for a single integrator to that for a double integrator

First, we need to load the packages we'll use:

using LinearAlgebra
using ReducedOrderModelCBFs

Next, we create our reduced-order model -- a 2D single integrator:

Σ0 = SingleIntegrator(2)

Now, we construct a CBF for this single integrator:

xo = [-1.0, 1.0] # Obstacle center
ro = 0.4 # Obstacle radius
h0(x) = norm(x - xo)^2 - ro^2 # Distance to obstacle
cbf0 = ControlBarrierFunction(h0, s -> s); # CBF for reduced-order model

We use this CBF to construct a smooth safety filter for the reduced-order model:

kd0(x) = -x # Desired controller for ROM
k0 = SmoothSafetyFilter(Σ0, cbf0, kd0, formula="gaussian", σ=0.1);

This smooth safety filter is now used to construct a CBF for the double-integrator:

μ = 5.0
h(x) = h0(x[1:2]) - (0.5/μ)*norm(x[3:4] - k0(x[1:2]))^2
cbf = ControlBarrierFunction(h, s -> s);

Finally, we construct a QP-based safety filter for the double-integrator:

kd(x) = -x[1:2] - 2*x[3:4] # Desired controller for full-order model
k = ReluSafetyFilter(Σ, cbf, kd);

If we want, we can then simulate the system under this controller:

x0 = [-2.1, 2.0, 0.0, 0.0] # Initial condition
T = 15.0 # Length of simulation
sol = simulate(Σ, k, x0, T) # Resulting solution

A Note on Plotting

I make all of my plots using PGFPlotsX.jl, which is essentially a Julia wrapper for the PGFPlots LaTeX package. The examples in this repo make use of this package, which requires you to have a working LaTeX installation. If you do want to use PGFPlots for plotting, please have a look at the Plots.jl package.

Related Works

Smooth Safety Filters

Backstepping

CBFs via Reduced-Order Models

About

Control barrier functions via reduced-order models.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages