S-Function (qp solver failed =>init_u?)

Hello everyone,

Unfortunately, I am currently stuck at one point and would like to ask for your advice. (Matlab/Simulink Interface)

Problem: When simulating in Matlab (one trajectorie, as in “minimal_example” from “getting started”-Example), the simulation runs and the solver can find a final solution after a few steps (0, success in every step). If I now generate code and run the simulation in Simulink with the same input variables, the qp solver fails permanently (4).

Background info: Based on the “getting started” example, I have extended the pendulum model with constraints on x. I have prepared all settings for my model (Explicit. Added non-quadratic terms to the cost function =>external costs. NLP). Furthermore, I added parameters. Up to this point, everything works perfectly (incl. S-Function in Simulink).
I then replaced the pendulum model with my model. I still use an external cost function without terminal costs. After the first copy-paste battle, I also had a failed solver (4) in Matlab. However, this was because init_x and init_u were both still 0-vectors from the example. After I had replaced these with my actual initial states, the model ran in Matlab.
For Simulink, init_x can be added via the Simulink options (get_acados_simulink_opts), but init_u unfortunately cannot. Is this perhaps also the problem in Simulink? Do the initial vectors affect the codegen?

Side question: What is init_pi for? Unfortunately I have not found a lot on this.

Many thanks in advance, best regards
Björn

P.S. I am looking forward to the workshop next week!

1 Like

Hi Björn,

This functionality is indeed missing for the Simulink interface.
It seems generally useful and important to make the solver converge for your problem.
I am going to add it later this week.

Best,
Jonathan

1 Like

Hi Jonathan,

perfect, thank you!

Best regards,
Björn

I added the u_init port in this PR, which I plan to merge tomorrow:

Side question: What is init_pi for? Unfortunately I have not found a lot on this.

Forgot to answer here:
pi: multipliers for dynamics equality constraints

This can be found here: https://docs.acados.org/python_api/index.html#acados_template.acados_ocp_solver.AcadosOcpSolver.get

1 Like