Difference in RTI example implementation

Hello :wave:

what is the difference between these two solving implementations, without looking at AS-RTI and Plain RTI → as_rti_closed_loop_example.py, example_sqp_rti_loop.py?

Here is also a very short example of what i mean, without model, constraints and stuff.
The SQP-RTI-loop:

  tol = 1e-6
  max_rti_iter = 20
  ocp.solver_options.nlp_solver_type = 'SQP_RTI'
  ocp_solver = AcadosOcpSolver(ocp, json_file = 'acados_ocp.json')
  
  for i in range(max_rti_iter):
    # preparation
    ocp_solver.options_set("rti_phase", 1)
    status = ocp_solver.solve()
    
    # feedback
    ocp_solver.options_set("rti_phase", 2)
    status = ocp_solver.solve()
  
    residuals = ocp_solver.get_residuals()
    if max(residuals) < tol:
        break

And the example without the for loop (from as_rti_closed_loop_example, but with RTI level 4 for comparison):

  max_rti_iter = 20
  ocp.solver_options.nlp_solver_type = 'SQP_RTI'
  ocp.solver_options.as_rti_level = 4
  ocp.solver_options.as_rti_iters = max_rti_iter 
  ocp_solver = AcadosOcpSolver(ocp, json_file = 'acados_ocp.json')
  
  # preparation
  ocp_solver.options_set("rti_phase", 1)
  status = ocp_solver.solve()
  
  # feedback
  ocp_solver.options_set("rti_phase", 2)
  status = ocp_solver.solve()

Is it the same? What is the difference, except that the one handles the iteration in python and the other one handles it in acados itself?
Thanks for the answere in advance :pray:

Hi,

The as_rti_closed_loop_example, demonstrates how to use RTI and AS-RTI in closed loop as an MPC controller, where the actual system is simulated with an acados integrator.

The example_sqp_rti_loop does solve a single OCP problem to convergence by calling an RTI solver in a for loop and checking the residuals.
Here, there is no system to which the OCP solution is applied, so no MPC.

Best,
Jonathan

1 Like