Unfortunately I am having issues to solve a MHE problem with acados when using simulink. What I have done is implemented a simple PT2 model containing two s-Functions, one MPC and one MHE (similar to the MHE example in python). The formulation works fine as an m-Code. When executing the simulink model, Matlab instantly crashes with an error message that a mex-Function has crashed.
I have a suspicion, that the crash is caused by the choice of constraints, as I have observed the following behaviour:
- According to the pdf-document
problem_formulation_ocp_mex.pdfthe initial state
x0should not be set for MHE problems. When formulating an
ocpwithout constraints either MATLAB crashes when compiling the mex functions or I receive error messages from acados, that
x0needs to be set.
Error: Failed to render 'main_sim.in.c' Reason: Variable `constraints.lbx_0[i]` not found in context while rendering 'main_sim.in.c': the evaluated version was `constraints.lbx_0.0`. Maybe the index is out of bounds?
Therefore I constrain
constr_Jbx_0 within a range of -1e6 and +1e6.
- When setting only
constr_Jbx_0as mentioned in point 1. the simulink MHE s-functions does not crash. However no solution is found in the s-Function (ocp status ~=0), although the
acados_ocpobject is able to find a solution when calling
acados_ocp.solve()in an m-script with the same input values. I checked the code in the c-Code of the s-Function. It seems to me, that
x0is constrained with lower and upper bounds of the same value, which is in contrast to point 1.
- So what I have tried next is to set constraints via
constr_expr_h. In this case the
ocpformulation as a m-script is execetud fine, but the corresponding compiled s-Function causes simulink to crash.
Do you know what causes these problems? If you are interested in my example to reconstruct the problem, I will upload it.
These issues happen when using the acados version of the 3rd of November with the commit:
Thanks a lot for helping!