AcadosSimSolver vs AcadosOcpSolver

Hi,
I want to implement an NMPC in MATLAB, which calculates the optimal control variables, inputs the first control, and then integrates continuous state dynamics for every time step.
However, I am confused about the differences of AcadosSimSolver and AcadosOcpSolver and which to use to solve optimal control problem + integrate state dynamics.

My understanding is that if I am

  • using AcadosSimSolver, I can solve optimal control problem + integrate state dynamics for simulation without using AcadosOcpSolver and external integrator
  • using AcadosOcpSolver to solve optimal control problem, I need to separately use ode45 in MATLAB for integration without using AcadosSimSolver

Can somebody please let me know which to use (which is faster, more accurate, etc.)?

Also, I cannot use same ocp settings for AcadosOcpSolver(ocp) and AcadosSimSolver(ocp) where ocp = AcadosOcp() because I get error:

Unrecognized method, property, or field ‘sens_hess’ for class
‘AcadosOcpOptions’.

Error in sim_generate_c_code (line 37)
code_gen_opts.generate_hess = sim.solver_options.sens_hess;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in AcadosSimSolver (line 54)
sim_generate_c_code(obj.sim);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error in LinearMPCTest (line 159)
integrator = AcadosSimSolver(ocp);
^^^^^^^^^^^^^^^^^^^^

Thank you in advance.

Hi :wave:

typically you have both, an AcadosOcpSolver for solving the optimal control problem and an AcadosSimSolver as the plant in your closed-loop simulation. These object are created from an AcadosOcp object which contains a full description of the optimal control problem. The integrator requires an AcadosSim object which describes the initial value problem.

I recommend to check this minimal example of how to set up a closed-loop simulation:

Best, Katrin

1 Like

(post deleted by author)