Acados MPC Build Error - Simulink Options

Hello everyone :wave:

I am having issues with the current acados head version when trying to built mpc interface for simulink:

  • Acados with Matlab (R2018b, 2020b, 2023b)
  • Casadi 3.3.5
  • minGW64 6.3
  • CMAKE 3.26

→ all default examples are working as intended

The problem is that there are much less and also different mex files compiled (compared to working revision from 14/06) when executing the main build script which then results in the following issue:

Error using acados_ocp/generate_c_code
If you want to provide simulink options, put it in the constructor of acados_ocp.

Error in generateSfunction (line 30)

The error is refered to acados\interfaces\acados_matlab_octave\acados_ocp() (line 228).
There are definitely simulink options defined which are also present in the workspace before the error event. Options are listed below:


When line 228 is commented out the build script is atleast executed without errors but then there are strange things happening in the simulink model (returned signals from sfunction solver model (ultraj/xtraj) will be disconnected during compiling as corresponding inputs disappear and also some controls are not working properly anymore).
I invested much time oberving the problem, but without any success.

Thanks in advance and feel free to ask for more information on the problem, if needed.


Hi Marius,

I updated the release notes Release v0.2.2 · acados/acados · GitHub

and added this:

Breaking changes:

Simulink interface: After Matlab full template based OCP solver by yzuuang · Pull Request #934 · acados/acados · GitHub the Matlab OCP solver interface is fully template based. Thus, there is no need anymore to call ocp.generate_c_code(simulink_opts);. This is now done within the creation of the Matlab OCP solver object.
The simulink_opts, have to be provided to the constructor of the ocp solver instead, i.e. with the optional argument simulink_opts:

ocp = acados_ocp(ocp_model, ocp_opts, simulink_opts);

For details, see Matlab full template based OCP solver by yzuuang · Pull Request #934 · acados/acados · GitHub

I hope makes it more clear.


Hey Jonathan,

Thanks for the quick reply and clarifying this!
After small changes in the setup,
following your advice, it’s compiling flawless (and even faster!) now. :slight_smile:

Sorry for the inconvenience,
I will have a look into the notes next time.