Issue with Acados Solver while using Parameter in Integrator

Hi,

When I am defining ocp_model.set(‘sym_p’, model.sym_p) for my model parameter and then generating S-function for my Solver and Sim_solver and then comparing the output of sim_solver with x1(1st node ) output of the acados solver. They aren’t matching at all. Whereas when I define my parameters in the model itself before generating S-function(without any input for parameter in acados or sim_solver), the output of sim_solver with x1(1st node ) output of the acados solver are the same.

Can anyone help me with troubleshooting this issue?

Do you define an input port for the Simulink S-function?
Note that the interactions with the solver in Matlab do not influence the generated code and thus not influence the solver used in Simulink.

I defined the input port requirements in Simulink.


x1 - simulated state and x1- state at node 1 ideally should match as it is same integrator being used in solver. But they are turning out to be different. x1-simulated state seems to correct(corroborated with MATLAB) where as x1(state at node 1 output from Acados solver(s-function0 isn’t matching).

Hi @FreyJo ,
Did you get the chance to look into this?
Plus I wanted to ask is there a way to just pass parameter for 1 stage instead concatenating it over the horizon(N+1). Like in matlab we define p for 1 timestep( that is ocp_model.set(‘p’,p))

Hi,

it is not easy to look into this without having a failing case available.
Could you provide a minimal example of such Simulink behavior, ideally as a test, similar to this one? acados/examples/acados_matlab_octave/test/simulink_test.m at master · acados/acados · GitHub
In this case, I would certainly be able to look into it.

As for the parameter, you need to set them stagewise, or define a custom port as shown in this example acados/examples/acados_matlab_octave/test/simulink_sparse_param_test.m at master · acados/acados · GitHub

Best,
Jonathan