Giter VIP home page Giter VIP logo

polympc's Introduction

PolyMPC

Build Status

Documentation Status

PolyMPC: An Efficient and Extensible Tool for Real-Time Nonlinear Model Predictive Tracking and Path Following for Fast Mechatronic Systems. Developed at the Automatic Control laboratory EPFL as part of the AWESCO project.

Documentation

Information on installation, algorithms and API can be found here: polympc.rtfd.io

Description

PolyMPC an open-source C++ library for real-time embedded nonlinear optimal control that combines high computational performance, modularity and a simple and intuitive user interface. PolyMPC is a lightweight collection of optimised and loosely coupled tools for nonlinear optimisation and optimal control which includes several quadratic programming (QP) and nonlinear programming (NLP) solvers, quasi-Newton Hessian approximation and Hessian regularisation methods, a polynomial interpolation and approximation module and an implementation of the Chebyshev pseudospectral collocation method, a continuous algebraic Riccati equation (CARE) solver, linear quadratic regulator (LQR), and more.

Contact

Petr Listov - [email protected]

polympc's People

Contributors

msplr avatar petlist avatar rschwan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

polympc's Issues

Rectifying bug

in nmpf.hpp do not rectify augmented state after 2* pi

Support sparse matrices in solvers

The solvers should support Eigen::SparseMatrix types.
This should give a significant speedup, since for example the KKT system in the QP solver is very sparse (0.95).

Eigen assert fails in ConjugateGradient

When instantiating an Eigen::ConjugateGradient object with fixed-size matrices, an eigen_assert fails here at construction.

One can easily reproduce the problem when building with assertions enabled ("Debug" mode, NDEBUG not defined):

#include <Eigen/Dense>
#include <Eigen/IterativeLinearSolvers>

int main()
{
    Eigen::ConjugateGradient<Eigen::MatrixXd> cg2; // works fine
    Eigen::ConjugateGradient<Eigen::Matrix3d> cg1; // fails
}

Eigen dense matrix allocation limit

Eigen defines a limit on the maximum size of a dense matrix with static dimensions.
This limits the maximal problem size for the QP and SQP solvers, because of the dense KKT matrix and Hessian.

The limit is defined by the EIGEN_STACK_ALLOCATION_LIMIT macro.

Here is an example error message

[...]/polympc/benchmark/qp_bench.cpp:314:10: error:
      non-const lvalue reference to type 'Mat' (aka 'Matrix<double, N, N>') cannot
      bind to a temporary of type 'Mat *' (aka 'Matrix<double, N, N> *')
    Mat &A = new Mat();
         ^   ~~~~~~~~~
In file included from [...]/polympc/benchmark/qp_bench.cpp:9:
In file included from /usr/local/include/eigen3/Eigen/IterativeLinearSolvers:11:
In file included from /usr/local/include/eigen3/Eigen/SparseCore:11:
In file included from /usr/local/include/eigen3/Eigen/Core:450:
/usr/local/include/eigen3/Eigen/src/Core/DenseStorage.h:33:3: error: static_assert
      failed "OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG"
  EIGEN_STATIC_ASSERT(Size * sizeof(T) <= EIGEN_STACK_ALLOCATION_LIMIT, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/eigen3/Eigen/src/Core/util/StaticAssert.h:33:40: note: expanded
      from macro 'EIGEN_STATIC_ASSERT'
    #define EIGEN_STATIC_ASSERT(X,MSG) static_assert(X,#MSG);
                                       ^             ~
/usr/local/include/eigen3/Eigen/src/Core/DenseStorage.h:110:5: note: in
      instantiation of function template specialization
      'Eigen::internal::check_static_allocation_size<double, 160000>' requested
      here
    check_static_allocation_size<T,Size>();
    ^
/usr/local/include/eigen3/Eigen/src/Core/DenseStorage.h:187:23: note: in
      instantiation of member function 'Eigen::internal::plain_array<double,
      160000, 0, 16>::plain_array' requested here
    EIGEN_DEVICE_FUNC DenseStorage() {
                      ^
/usr/local/include/eigen3/Eigen/src/Core/PlainObjectBase.h:484:45: note: in
      instantiation of member function 'Eigen::DenseStorage<double, 160000, 400,
      400, 0>::DenseStorage' requested here
    EIGEN_STRONG_INLINE PlainObjectBase() : m_storage()
                                            ^
/usr/local/include/eigen3/Eigen/src/Core/Matrix.h:259:36: note: in instantiation of
      member function 'Eigen::PlainObjectBase<Eigen::Matrix<double, 400, 400, 0,
      400, 400> >::PlainObjectBase' requested here
    EIGEN_STRONG_INLINE Matrix() : Base()
                                   ^
[...]/polympc/benchmark/qp_bench.cpp:314:18: note:
      in instantiation of member function 'Eigen::Matrix<double, 400, 400, 0, 400,
      400>::Matrix' requested here
    Mat &A = new Mat();

Examples fail due to missing HSL dynamic library

The examples kite_control_test, kite_model_test, kite_sode_test, legendre_test run into an error because IPOPT doesn't find the HSL dynamic library libhsl.dylib.

We need to document how to install those dependencies.

[QP Solver] In-place LDLT decomposition of KKT matrix

The most significant memory cost of the dense QP solver come form storing the KKT matrix and its decomposition.
Eigen allows for in-place LDLT decomposition that reuses the coefficient matrix and to save memory.
The in-place decomposition requires a reference to the coefficient matrix at construction, which is not available at that point.
However, construction can be delayed using a placement new, which is illustrated below.

using linear_solver_t = Eigen::LDLT<Eigen::Ref<kkt_mat_t>>;
char linear_solver_buf[sizeof(linear_solver_t)]; // enforce some alignment somehow?
linear_solver_t* linear_solver;
//...
p = (void*) linear_solver_buf;
linear_solver = new(p) linear_solver_t(kkt_mat);

Note: Another option would be to construct the linear solver as a local object on the stack.

Add Eigen implementation to the repo

Eigen implementation of the Chebyshev class is missing due to lack of tests. Add the implementation and replicate control examples using Eigen interface.

Documentation site

We should add a documentation website for this project.
MkDocs is a good option which is easy to set up and works with GitHub Pages.

However, it might be challenging to set it up for a branch other than master.

Path error evaluation

in nmpf.hpp add path_parameters to PathError function input, as they are part of the residual

PathError = casadi::Function("PathError", {aug_state}, {residual});

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.