Hi dear acados community
I am currently using the c-interface to use the c-generated code in C++. The problem I am facing currently is that I am only retrieving zeros, and the sqp is not even iterating. I have come up with the model myself, the OCP might be therefore illposed, but I think there should be at least some infeasible solutions. The model for the ocp has seven states I want to update at each iteration, in the python script as follows:
# set up states
x_pos = SX.sym('x_pos') #x position
y_pos = SX.sym('y_pos') #y position
psi = SX.sym('psi') # heading
v = SX.sym('v') # velocity
cte = SX.sym('cte') # cross track error
epsi = SX.sym('epsi') # heading error
evel = SX.sym('evel') # velocity error
x = vertcat(x_pos, y_pos, psi, v, cte, epsi, evel)
# set up controls
a = SX.sym('a') # acceleration
delta = SX.sym('delta') # steering angle
u = vertcat(a, delta)
# x_dot and parameters
x_pos_dot = SX.sym('x_pos_dot')
y_pos_dot = SX.sym('y_pos_dot')
psi_dot = SX.sym('psi_dot')
...
...
...
p = vertcat(...)
f_expl = vertcat(v * cos(psi),
v * sin(psi),
v * tan(delta)/wheelbase,
a,
f_1(x,p)
f_2(x,p),
f_2(x,p))
f_impl = x_dot - f_expl
Here, the dynamics of the error states are calculated through parameters set at each iteration, noted by f_i(\textbf{x},\textbf{p}). I only include those three states in the cost function, and y_ref is therefore zero for all states.
ocp.model.cost_y_expr = vertcat(
cte,
epsi,
evel,
a,
delta)
ocp.model.cost_y_expr_e = vertcat(
cte,
epsi,
evel
)
Solver settings are:
ocp.solver_options.qp_solver = "PARTIAL_CONDENSING_HPIPM"
ocp.solver_options.nlp_solver_type = "SQP"
ocp.solver_options.hessian_approx = "GAUSS_NEWTON"
ocp.solver_options.integrator_type = "ERK"
After (successfully) generating the code with
ocp_solver = AcadosOcpSolver(ocp, json_file=f"{ocp.code_export_directory}/acados_ocp_{ocp.model.name}.json", cmake_builder=CMakeBuilder())
I include all the necessary headers, and create all instantiate all capsules needed and update the solver in every iteration:
// initial condition
ocp_nlp_constraints_model_set(nlp_config_, nlp_dims_, nlp_in_, 0, "idxbx", idxbx0_);
ocp_nlp_constraints_model_set(nlp_config_, nlp_dims_, nlp_in_, 0, "lbx", x_current_);
ocp_nlp_constraints_model_set(nlp_config_, nlp_dims_, nlp_in_, 0, "ubx", x_current_); // updates all states
mpc_acados_update_params(acados_ocp_capsule_, i, param_buffer_[i], NP); // updates parameters
ocp_nlp_cost_model_set(nlp_config_, nlp_dims_, nlp_in_, i, "yref", y_ref_[i]); // updates yref, but anyways always zero
In the front end, everything looks quite promising, but the solver outputs only zeros and after searching for the reason for hours and hours, I am still clueless why this could be.
My output:
[INFO] [1712305176.414031349] [mpc_acados]: status: 1 (refers to the status of the solver)
[INFO] [1712305176.414042466] [mpc_acados]: Solver info:
SQP iterations 0
minimum time for 1 solve 0.000000 [ms]
KKT 0.000000e+00
— x_traj —
0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
.
. (N time steps)
.
0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00 0.000000e+00
— u_traj —
0.000000e+00 0.000000e+00
.
. (N time steps)
.
0.000000e+00 0.000000e+00
Did I overlook or forget an important setting? Any hints on what I can change? Thank you all already!