HPIPM convergence issue with model dynamics containing division by a state


I’m not quite sure if it is definitely a bug or if it is a limitation of the HPIPM solver.

So what I’m trying to do is to build a simple NMPC controller which is already running in Casadi with the IPOPT solver. Nevertheless for performance and code generation reasons I want to switch to acados.

For testing purposes I build only a simple cost function (which will be expanded later on) in the form

cost_expr_ext_cost = b_c*(states(1)-P_ref)^2;
cost_expr_ext_cost_e = c_c*(states(1)-P_ref)^2;

where P_ref is the reference that should be tracked. The dynamics are desribed by

rhs = [Mpc_ig/Mpc_rwheel/Mpc_m*Tm/(v-abc) - Mpc_m*Mpc_g*sin_a/Mpc_m/(v-abc) - Mpc_m*Mpc_g*Mpc_cr*cos_a/Mpc_m/(v-abc) - 1/2*Mpc_rho*Mpc_A*Mpc_cw/(Mpc_m)*v

which is simply the longitudinal behaviour of a car with respect to position instead of time. The state vector in this description only contains the velocity v and the input vector the motor torque Tm.

The problem (I think) of this formulation is the division with the state v. abc is only a debbuging factor which is normally set to zero for the exact model equations. With abc set to zero and using casadi and ipopt as solver the NMPC runs fine. But when I use acados with the sqp and HPIPM as qp solver I need to set abc to at least 1 to get convergence in the HPIPM solver. Otherwise it will return qp_stat == 3 which means that the solution contains NaN.

I also tested to use state constraints with v > 0 to exclude the division by zero from the OCP. But this also didn’t worked. I tested different integration schemes (Euler, RK1-4). But all I’m tryiing has no effect on the convergence of the HPIPM solver.

I hope my problem explanation is understandable and someone of you could help me. If someone needs further information please let me know.

Thanks a lot.

Best regards



did you already try to initialize the OCP solver explicitly, i.e. with nonzero values for the state that you divide by within the model?

You made my day! :slight_smile:

This was exactly the reason.
I already initialized


with starting values unequal to zero. But what solved my problem was also to set


to some value unequal to zero.

Thanks a lot!