Help with Simulink and acados Integration for Nonlinear MPC

Hi everyone,

I am currently working on a project where I need to implement a nonlinear model predictive control (NMPC) using acados in Simulink.

I have set up the model and solver in acados…, but I am struggling with integrating it smoothly into Simulink.

Specifically, I am not sure about the best way to pass the required inputs and retrieve the outputs within the Simulink environment.

Has anyone here successfully connected acados with Simulink: ?? I would appreciate any advice or examples, especially on how to manage the interface between the two platforms.

Also, any tips on handling real-time execution or avoiding potential pitfalls would be great…! :grinning: I also read this thread https://discourse.acados.org/t/nonlinear-mpc-example-in-matlab-react-native/ but couldn’t get the solution

Thanks in advance for your help…! :grinning:

With Regards,

Steve Smith

Hi Steve,

take a look athe the script simulink_example_advanced in the getting_started folder. I think everything that you need for integration acados in simulink is explained there.

Here a brief description of the overall workflow:

  1. Create an OCP solver like in the minimal_example till line 115.

  2. Set the simulink options by fist getting the simulink options and then setting the input and output ports of the generated s-function, like in the script simulink_example_advanced line 5 to 24.

  3. Navigate into the c_generated_code folder and call make_sfun for creating an s-function of the ocp solver and make_sfun_sim for creating an s-function of the process model of your NMPC (simulink_example_advanced line 35 to 38).

  4. Create a simulink model and import the generated s-function into the model.

Hope that helpts a bit

Jannis