Thank you again for all your work on acados.
My question is, what should I do to create a new ocp problem (new initial conditions and new parameters) without recompiling the solver with the python interface?
I am trying to solve a multi-robot motion planning problem with an MPC. Each robot has an initial position and a goal to reach. I would like to solve the MPC for different couples (initial position,goal). For this, I set the goal as a parameter. I export the solver once, solve the first ocp, and then to solve a new ocp, I update the parameter (goal) with ocp_solver.acados_ocp.parameter_values = goal, and I use ocp_solver.solve_for_x0(x0) to use the new initial position. However, the results I get are still different than the ones I get if I recompile the solver.
At each time step, I also initialize the solver and the integrator using set():
ocp_solver.set(0, “lbx”, xcurrent)
ocp_solver.set(0, “ubx”, xcurrent)
What instructions do you think I should add? Does the ocp_solver keep the previous solution in memory and is it possible to delete it? I tried the function reset(), but then I get errors of status 4. I have also tried to use store_iterate() and load_iterate() but the problem is still here. I probably do not use these functions correctly? I do store_iterate(“json_file.json”) once after exporting/compiling the solver. And then, during the simulation I do load_iterate(“json_file.json”) at each time step, before initializing the solver, before calling .solve_for_x0. Should I create different json files for each different ocp?
I don’t think reset() is the issue because when I solve the problem exporting the solver for the specific initial positions and goals, then it works well. The problem occurs when I want to solve multiple ocp without re-exporting the solver.
Indeed the first debugging you propose actually reveals the problem!
When I apply store_iterate() after exporting the solver, every values are zeros except the x_i values that are equal to the my initial conditions x0. I guess these values correspond to the initial condition constraint.
When I apply store_iterate() after reset() then all the values in the json file are equal to zero, the x_i values too.
I was actually stuck on this problem for a long time, so thank you so much for your precious help and amazing responsiveness!
Your suggested tricks will definitely be useful for any problem I face in the future.