Linear reference tracking MPC library using Eigen linear algebra library, OSQP quadratic programming solver and the OsqpEigen wrapper for OSQP.
This is a work in progress.
The library supports two versions of the reference tracking linear MPC:
Eigen matrices and vectors are used to describe the MPC problem:
//Define a discrete linear system
// A, B, C, and D are of type Eigen::MatrixXd
EigenLinearMpc::LinearSystem example_system(A, B, C, D);
// Construct a MPC object
EigenLinearMpc::MPC mpc(example_system, // Discrete linear system (EigenLinearMpc::LinearSystem)
horizon, // MPC horizon (uint32_t)
Y_d, // System output reference (Eigen::VectorXd)
x0, // Initial system state (Eigen::VectorXd)
Q, // Q weight value (double)
R); // R weight value (double)
mpc.initializeSolver();
// Solve problem
auto U_sol = mpc.solve();
The type of the reference tracking problem (MPC 1
or MPC 2
) is determined by MPC the object constructor.
For complete examples of the two versions of the MPC problem see test_example
and test_example_2
.
This project depends on osqp
and osqp-eigen
git clone https://github.com/ivatavuk/lin_mpc_eigen.git
cd lin_mpc_eigen
mkdir build
cmake ..
make
make install
lin_mpc_eigen provides native CMake
support which allows the library to be easily used in CMake
projects.
lin_mpc_eigen exports a CMake target called LinMpcEigen::LinMpcEigen
which can be imported using the find_package
CMake command and used by calling target_link_libraries
as in the following example:
project(myproject)
find_package(LinMpcEigen REQUIRED)
add_executable(example example.cpp)
target_link_libraries(example LinMpcEigen::LinMpcEigen)
## 📝 License
Materials in this repository are distributed under the following license:
> All software is licensed under the BSD 3-Clause License.