OCP solver fails after adding nonlinear constraint


I have been working on the following OCP recently and I have trouble getting a solution when control allocation is implemented into the constraints.

Here is the code repo:

GitHub - ErcBunny/learn_acados.

To reproduce, please run omnihex.py. Without the allocation part (see the referenced lines below), the code runs nicely.

And this is what I can get when the allocation part is commented out as shown in the above code.

But once the control allocation part is involved, the solver (HPIPM) returns NaN immediately, even if the allocated thrust constraints are not violated as shown above in thrust.png.

I sincerely look forward to your suggestions. Thank you for reading and have a good day~


I think the term allocation is used in a confusing way in your post.
I changed the title of this thread to
“OCP solver fails after adding nonlinear constraint”

You will need to initialize the solver explicitly, for this problem formulation.
The default initialization is zeros, and an sqrt() constraint can not be linearized at 0.


1 Like

Hi Jonathan,

Thank you for pointing out the problem here. I tried with a nonlinear constraint without sqrt() and it worked without initializing the solver explicitly.

Thanks again!