hello FreyJo !
my prevous python RTI code
for i in range(N_sim):
# preparation phase
ocp_solver.options_set('rti_phase', 1)
status = ocp_solver.solve()
t_preparation[i] = ocp_solver.get_stats('time_tot')
ocp_solver.set(0, "ubx", simX[i, :])
ocp_solver.set(0, "lbx", simX[i, :])
ocp_solver.options_set('rti_phase', 2)
status = ocp_solver.solve()
t_feedback[i] = ocp_solver.get_stats('time_tot')
simU[i, :] = ocp_solver.get(0, "u")
# simU[i,:] = ocp_solver.solve_for_x0(x0_bar = simX[i, :])
simX[i+1, :] = integrator.simulate(x=simX[i, :], u=simU[i,:])
i change the generated_code to this RTI step. is this right?
// RTI section
for (int ii = 0; ii < NTIMINGS; ii++) {
// ocp_nlp_solver_opts_set(nlp_config, "rti_phase", 1);
ocp_nlp_solver_opts_set(nlp_config, nlp_opts, "rti_phase", &RTI_phase_prepare);
int status = quad_body_3d_acados_solve(acados_ocp_capsule);
ocp_nlp_get(nlp_solver, "time_tot", &elapsed_time);
min_time = MIN(elapsed_time, min_time);
printf("\n--- rti_phase %d ---\n", ii);
// get current state, set the lbx ubx and solve
ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, 0, "lbx", x_init);
ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, 0, "ubx", x_init);
ocp_nlp_solver_opts_set(nlp_config, nlp_opts, "rti_phase", &RTI_phase_feed);
status = quad_body_3d_acados_solve(acados_ocp_capsule);
// ocp_nlp_out_set(nlp_config, nlp_dims, nlp_out, 0, "x", x_init)
// ocp_nlp_out_get(nlp_config, nlp_dims, nlp_out, 0, "u", u0);
}