Giter VIP home page Giter VIP logo

reducedordermodelcbfs.jl's Introduction

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

reducedordermodelcbfs.jl's People

Contributors

maxhcohen avatar

Stargazers

 avatar  avatar Xinyue Zhao avatar  avatar Sai Sandeep Damera avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.