Simulink advanced closed loop example

Hi :wave:

I’m experimenting a bit with the Matlab Simulink interface of acados. I can get it running and the outputs seem fine. I have two questions about the simulink_model_advanced_closed_loop.slx, though:

  1. The ocp sfunction block has an input x_init, which is set to zeros. Does that mean that this example will not warmstart the ocp sfunction block with the states from the solution at the previous simulation timestep. If not, would it better to couple the (delayed) ouput xtraj to the input x_init of the ocp sfunction block?

  2. There is a delay block z^(-1) from the ocp sfunction block to the sim sfunction block. Wouldn’t it be better to put this delay block in the feedback line from the sim sfunction block to the ocp sfunction block? I think that corresponds better to how the closed loop examples are implemented.

Thanks in any case for making all of this Simulink functionality!

Kind regards,
Caspar

Hi Caspar,

the example was just made to demonstrate and test some features added in Simulink: add options for S functions by FreyJo · Pull Request #690 · acados/acados · GitHub

  1. If you would not use x_init, acados would use the x values available from the last call that are still in memory.
    Of course the previous solution can be shifted to initialize the solver.

  2. you are right, that would better correspond to how closed loop MPC works.

Feel free to contribute a better Simulink closed loop example, I am not very experienced with Simulink.

Best,
Jonathan

The suggested changes have been merged for the Simulink examples here:

Thanks!