nicolapiccinelli / libmpc

libmpc++ is a C++ header-only library to solve linear and non-linear MPC
https://altairlab.gitlab.io/optcontrol/libmpc/
MIT License
138 stars 21 forks source link

Custom numerical integrator for MPC predictions #36

Closed sara9915 closed 1 month ago

sara9915 commented 2 months ago

Hello @nicolapiccinelli, I'd like to use your library, but I need to employ a custom numerical integrator to make the MPC predictions along the prediction horizon. Can you give me some info about the routine now used to do this? I see there is an RK4 class, but I didn't find anywhere its usage in the provided examples.

nicolapiccinelli commented 2 months ago

Hello, @sara9915. Are you referring to the integration of the model dynamics?

sara9915 commented 2 months ago

Yes, exactly, but during the predictions along the horizon, not after the optimization

nicolapiccinelli commented 1 month ago

Ok, the library is handling things differently between linear and non-linear MPC. Which one are you interested in?

sara9915 commented 1 month ago

Non-linear MPC

nicolapiccinelli commented 1 month ago

If you already have a discrete-time model, the library is simply propagating the state x(k+1) = f(x(k),u(k)). Otherwise, if you provide a continuous time model, the integration is performed using central difference with the integration step of the sample time provided. In this case, the integration exploits the prediction horizon to implement the integration scheme.

sara9915 commented 1 month ago

I got it, thank you!