Library for simulation of nonlinear control systems, control design, and Lyapunov-based learning.
You will need Python3 and PIP package manager. Clone the repository in a directory of your choice, we will refer to it as DIR
.
Navigate to the directory DIR
. Create a virtual environment with target directory .venv
with
python3 -m venv .venv
To activate the virtual environment, use
source .venv/bin/activate
When you want to deactivate the environment, use
deactivate
To install all dependencies, use
pip3 install -r requirements.txt
To run an example, use
python3 -m lyapy.examples.inverted_pendulum
Let x
denote a state vector, t
denote a time, eta
denote an output, x_dot
= dx/dt
denote a state derivative, and u
denote a control input.
System classes are the fundamental classes used to simulate dynamical systems.
Abstract class for simulating continuous-time dynamics of the form x_dot = f(t, x)
.
System
-> ControlSystem
Abstract class for simulating control systems of the form x_dot = f(x, u, t)
. u
is computed by a Controller
object only at specified time steps.
System
-> ControlSystem
-> AffineControlSystem
Abstract class for simulating affine control systems of the form x_dot = f(x) + g(x) * u
. As with a ControlSystem
, u
is computed by a Controller
object only at specified time steps.
Output classes define control objectives as functions of state and time. They are used to specify controllers and Lyapunov functions.
Abstract class for evaluating control objectives of the form eta(x, t)
.
Output
-> AffineDynamicOutput
Abstract class for evaluating differentiable control objectives with dynamics eta_dot
that decompose as eta_dot = drift(x, t) + decoupling(x, t) * u
.
Output
-> AffineDynamicOutput
-> FeedbackLinearizableOutput
Abstract class for evaluating differentiable control objectives with valid vector relative degree. The dynamics eta_dot
decompose as eta_dot = drift(x, t) + decoupling(x, t) * u
.
The output eta(x, t)
itself should also decompose as blocks [eta_1(x, t), ..., eta_k(x, t)]
, corresponding to relative degree vector [gamma_1, ..., gamma_k]
. The block eta_i(x, t)
should contain gamma_i
elements in increasing derivative order of the i
-th control objective. If eta(x, t)
is not organized in this block structure, a permutation into this structure must be provided.
Output
-> PDOutput
Abstract class for evaluating control objectives which contain proportional and derivative error components.
Output
-> AffineDynamicOutput
-> FeedbackLinearizableOutput
-> RoboticSystemOutput
Output
-> PDOutput
-> RoboticSystemOutput
Abstract class for evaluating differentiable control objectives, each with relative degree 2. The dynamics eta_dot
decompose as eta_dot = drift(x, t) + decoupling(x, t) * u
.
Proportional and derivative error components are defined as e_p(x, t) = y(x) - y_d(t)
and e_d(x, t) = d/dt ( y(x) - y_d(t) )
, respectively. The output eta(x, t)
itself should also decompose as blocks [e_p(x, t), e_d(x, t)]
.
Lyapunov functions are defined on outputs and can be evaluated given a state and time.
Abstract class for differentiable Lyapunov functions.
LyapunovFunction
-> QuadraticLyapunovFunction
Class for Lyapunov functions of the form V(eta) = eta' * P * eta
, for positive definite P
.
LyapunovFunction
-> ControlLyapunovFunction
Abstract class for differentiable Lyapunov functions for which V_dot
can be computed as a function of state, control input, and time.
LyapunovFunction
-> QuadraticLyapunovFunction
-> QuadraticControlLyapunovFunction
LyapunovFunction
-> ControlLyapunovFunction
-> QuadraticControlLyapunovFunction
Class for Lyapunov functions of the form V(eta) = eta' * P * eta
, for positive definite P
. V_dot
can be decomposed as drift(x, t) + decoupling(x, t) * u
.
LyapunovFunction
-> QuadraticLyapunovFunction
-> QuadraticControlLyapunovFunction
-> LearnedQuadraticControlLyapunovFunction
LyapunovFunction
-> ControlLyapunovFunction
-> QuadraticControlLyapunovFunction
-> LearnedQuadraticControlLyapunovFunction
Class for Lyapunov functions of the form V(eta) = eta' * P * eta
, for positive definite P
. V_dot
can be decomposed as drift(x, t) + decoupling(x, t) * u
, where drift
and decoupling
are modified with additive estimation models b(x, t)
and a(x, t)
, respectively.
Controller classes specify actions as a function of state and time. The objective of a controller is specified through an Output object.
Abstract class for controllers.
Controller
-> ConstantController
Class for controllers that output the same action at every state and time.
Controller
-> PDController
Class for controllers with actions linear in proportional and derivative terms of a PDOutput.
Controller
-> LinearizingFeedbackController
Class for controllers acting on FeedbackLinearizableOutput objects that pseudoinvert the output decoupling, subtract the output drift, and add an auxilliary control term linear in the output.
Controller
-> QPController
Class for controllers that compute actions by solving quadratic programs. Quadratic programs may have one constraint, which may be slacked.
Controller
-> PerturbingController
Class for controllers that perturb nominal controllers with predetermined actions. The actions are scaled by the norm of the nominal controller, potentially offset from 0 so the perturbations may always be nonzero.
Controller
-> CombinedController
Class for controllers specified as linear combinations of other controllers.