Skip to content

The 1D_MPC_CBF repository houses a collection of MATLAB scripts written to study differnt state-constrained controllers.

License

Notifications You must be signed in to change notification settings

JohannesAutenrieb/1D_MPC_CBF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

1D_MPC_CBF

Description

The 1D_MPC_CBF repository houses a collection of MATLAB scripts written to study different state-constrained controllers. With a focus on a class of 1D dynamical systems, this collection of MATLAB scripts intends to compare and analyze the performance of different state-constrained controllers utilizing control barrier functions and model predictive control.

Concept of Control Barrier Functions

We consider the following control affine system:

$$\begin{equation} \dot{x}= f(x) + g(x)u \end{equation}$$

A closed set $\mathcal{C} \in \mathbf{R}^n$, which we consider as a safe set, is defined in the following form:

$$\begin{equation} \mathcal{C} = { x \in \mathbf{R}^n : h(x) \geq 0 } \end{equation}$$

with $h: \mathbf{R}^n \times \mathbf{R}^p \to \mathbf{R}$ being a continuously differentiable function, called control barrier function (CBF).

CBF_Function_Plot

The CBF can ensure for the presented control affine system that for any initial condition $x_0 := x(t_0) \in \mathcal{C}$, that $x(t)$ stays within $\mathcal{C}$ for any $t$, if there exists an extended class $\mathcal{K}$ functions $\alpha$ such that for all $x \in Int(\mathcal{C})$

$$\begin{equation} \sup_{u \in U} [L_f B(x) + L_g B(x) u + \alpha(h(x))] \geq 0 \end{equation}$$

Where $\alpha(h(x)$ often chosen to be

$$\begin{equation} \alpha(h(x)) = \gamma h(x) \end{equation}$$

with $\gamma$ being $\gamma > 0$.

Integrated Controllers

The following state-constrained controllers are implemented and can be compared via separate time simulations:

MPC controllers with classical state constraints

$$\begin{aligned} \min_{u_{t: t+N-1 \mid t}} \quad & \frac{1}{2} x_N^T P x_N+\sum_{k=0}^{N-1} \frac{1}{2} x_k^T Q x_k+\frac{1}{2} u_k^T R u_k\\\ \textrm{s.t.} \quad & x_{t+k+1 \mid t}=f\left(x_{t+k \mid t}, u_{t+k \mid t}\right), \quad k=0, . ., N-1,\\\ & x_{\min } \leq x_{t+k \mid t} \leq x_{\max }, \quad k=0, \ldots, N-1,\\\ & u_{\min } \leq u_{t+k \mid t} \leq u_{\max }, \quad k=0, \ldots, N-1, \\\ & x_{t \mid t}=x_t, \\\ & \Delta h\left(x_{t+k \mid t}, u_{t+k \mid t}\right) \geq-\gamma h\left(x_{t+k \mid t}\right), \quad k=0, \ldots, N-1 \\\ \end{aligned}$$

MPC controllers with discrete control barrier functions

$$\begin{aligned} \min_{u_{t: t+N-1 \mid t}} \quad & \frac{1}{2} x_N^T P x_N+\sum_{k=0}^{N-1} \frac{1}{2} x_k^T Q x_k+\frac{1}{2} u_k^T R u_k\\\ \textrm{s.t.} \quad & x_{t+k+1 \mid t}=f\left(x_{t+k \mid t}, u_{t+k \mid t}\right), \quad k=0, . ., N-1,\\\ & \Delta h\left(x_{t+k \mid t}, u_{t+k \mid t}\right) \geq-\gamma h\left(x_{t+k \mid t}\right), \quad k=0, \ldots, N-1 \\\ & u_{\min } \leq u_{t+k \mid t} \leq u_{\max }, \quad k=0, \ldots, N-1, \\\ & x_{t \mid t}=x_t, \\\ \end{aligned}$$

Pointwise Controller and CBF-QP Safety Filter

A linear controller of the following form is defined:

$$\begin{align} u_d = K_1 x + K_2 x_d \end{align}$$

The linear controller is tuned regarding the desired control performance but alone cannot generate safe commands. Therefore the following CLF-QP safety filter is used to adapt $u_d$ such that $x(t)$ stays within $\mathcal{C}$ for any $t$.

$$\begin{align} &\min_{u \in \mathcal{U}} \begin{aligned}[t] &|u - u_d|_2 \end{aligned} \\ &\text{s.t.} \notag \\ & L_f h(x) + L_g h(x)u - \gamma h(x) \leq 0, \notag \end{align}$$

After each simulation run, a plot with results is given out. An example of such a plot is given here:

MISSION_GUI

Dependencies

The scripts use external libraries, which need to be installed.

Further, the following MATLAB toolboxes are needed:

The software was tested with MATLAB 2020b under Windows 11 Home.

License

The contents of this repository are covered under the MIT License.

References

We kindly acknowledge the following papers, which have been the foundation of the here presented scripts:

About

The 1D_MPC_CBF repository houses a collection of MATLAB scripts written to study differnt state-constrained controllers.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages