Linear constraint on the states defined as Non-Linear does not work

Hi all:

I’m trying to control a system using acados for python. I want to impose a constraint for the velocity of the system in body frame, so I need to use a non-linear constraint, at it depends on the attitude of the system.

I have tried but I doesnt work. I tried to simplify by imposing the constraint in the global frame like this:

ocp.constraints.idxbx = np.array([21])
ocp.constraints.lbx =  -np.array([1])
ocp.constraints.ubx =+np.array([1])

Like this it work perfectly, as I define it as a linear constraint.

Then, I tried to apply the same constraint but using the non-linear definition of acados (as an intermediate step before imposing the velocity constraint in the body frame). The code that I used is:

ocp.model.con_h_expr = model.x[21]
lb_vh = -np.array([1])
ub_vh = +np.array([1])
ocp.constraints.lh = lb_vh
ocp.constraints.uh = ub_vh

It does not work. I do not know why, there is no sense for me as the constraint is the same. The solver settings are:

ocp.solver_options.qp_solver = 'PARTIAL_CONDENSING_HPIPM' 
ocp.solver_options.hessian_approx = 'GAUSS_NEWTON'
ocp.solver_options.integrator_type = 'IRK'
ocp.solver_options.sim_method_newton_iter = 10
ocp.solver_options.qp_solver_iter_max = 300

My model includes algebraic equations so I need to use the implicit formulation.

Thanks a lot!

It might be related to this: Missing documentation for initial constraints constr_expr_h_0 (MATLAB) · Issue #1009 · acados/acados · GitHub
Or what do you mean with “It does not work.”?

Thanks for the reply. I mean that the QP solver finds a NaN solution: SQP_RTI: QP solver returned error status 3 QP iteration 3. (HPIPM solver)

However, If I define it as linear constraint it works properly.

UPDATED: I managed to run it as a Non-Linear constraint but I had to reduce the N_horizon of the solver (N=4 or less). If I use the N_horizon of the linear constraints (N=8) the QP solver fails with status 3.Why is this happening? How can I increase the N without causing the QP solver to fail?