I am developing the package LinearMPC.jl, which is a package for Model Predictive Control (MPC) of linear dynamical systems.
The focus of the package to produce high-performant and lightweight C-code that can easily be used on embedded systems, while at the same time give a user-friendly and expressive development environment for linear MPC.
It also includes tools for computing explicit MPC controllers, and for certifying the compelxity of implicit MPC controllers before they are deployed on hardware.
A summary of some of the main features:
- Code generation of high-performant, allocation-free, library-free, and lightweight C-code that can be embedded on any micro controller (with the QP solver DAQP).
- State-of-the-art computation of explicit MPC (~100x faster than other software packages such as MPT in MATLAB)
- Tools to determine real-time certificates of the complexity of the solver, allowing for MPC in with guarantees on the memory and computationala requirements before deploying the solver.
The main difference to the excellent package ModelPredictiveControl.jl of @franckgaga & @baggepinnen is that LinearMPC.jl focus on MPC controllers that can be deployed directly on embedded systems, while ModelPredictiveControl.jl is currently more for high-level development of MPCs in Julia with more flexibility (e.g., support for nonlinear MPC).
Any feedback is highly appreciated!
11 Likes
Tjenare, congratulations on the release and welcome to the community! 
I have looked through the code and docs (a few days ago), and would be happy to promote the package from the ecosystem section in the ControlSystem docs if it had a bit more developed documentation and tests.
Tackar @baggepinnen 
The docs/tests are indeed lacking a bit… But now when most of the “base functionality” of the package is established, my main focus is on improving that. So in the upcoming days the documentation will be improved!
1 Like
Thanks for sharing this work!
Slightly off-topic, I see that you’re using a custom QP solver DAQP. Is this code in the same spirit as the older conic solver ECOS?
It depends on what you mean with “in the same spirit”, but I would say yes.
ECOS solves a slightly wider problem class (conic problems), while DAQP focuses on quadratic programs. But both are written in C and are readily embeddable.
DAQP is for example library-free, allocation-free, square-root-free, which makes it embeddable on any platform with a C compiler (which is basically any target)
Regarding performance, I tend to get speedups with DAQP that are one or two orders of magnitude faster than ECOS (just to be transparent: I am the developer of DAQP, so I might not be completely unbiased)
If you want some more information on DAQP, you can checkout the corresponding publication.
2 Likes
Great Job @darnstrom, both for LinearMPC.jl and DAQP.jl !
About the features:
- Does it support constraint softening ? I don’t see any constraint relaxation term e.g. C\epsilon^2 in the objective function
- I see the the initial state is defined as x_0 = \hat{x}. There is probably no built-in state estimator in your package, e.g. you assume that all the states are measured? Is there any offset-free tracking mechanism (the integral action)?
At some point I would like to link ModelPredictiveControl.jl with this LinearMPC.jl. The objective would be to offer some code generation functionalities. For sure it would be limited in feature (no nonlinear MPC and only DAQP solver), but that’s generally expected for code generation.
Keep up the good work!
1 Like
Thank you @franckgaga, and great job with ModelPredictiveControl.jl!
Yes, it supports soft constraints (I will add information about this in the documentation.)
Actually, DAQP internally handles soft constraints in a very efficient manner (might publish something on this in another context soon)
The problem formulation in the README is just a simplified version to make it more readable. Some things supported in the package, but that are not documented yet:
- Soft constraints
- Prestabilizing feedback
- Move blocking
- Binary controls (so hybrid systems can be handled)
- Measured disturbances
- Prioritized constraints (when I release DAQP v0.7.0)
The measured disturbances relates to offset-free tracking.
Currently, it assumes full state measurements. So an observer need to be provided from another package (I don’t plan on providing an observer to keep the focus of the package on LMPC, rather than the observer.) In the end the compute_control
function takes in x
, which can be provided by any state estimator.
I have also been thinking about linking ModelPredictiveControl.jl with LinearMPC.jl. In addition to code generation, I think the explicit MPC support could be nice (since only constraint-free explicit MPC is currently supported in ModelPredictiveControl.jl)
I have been putting of this linking until the basic interface/internals of LinearMPC.jl have converged . But I think that the package is soon in a state to start this linking. Let’s discuss this more at some point!
1 Like
OK that’s what I thought with “in the same spirit”: close to bare metal micro controller implementation.
Also it’s good to know that you have observed “one or two orders of magnitude” of faster solving speed versus ECOS. I’ll keep this in my mental library.
1 Like