RTI phases in Python interface

Hi, I’m using the python interface of acados to do NMPC.
I’m wondering if it is possible to make use of SQP_RTI directly from python to control my robot.
Right now I’m just simulating my system following this example

# preparation rti_phase
acados_solver.options_set('rti_phase', 1)
status = acados_solver.solve()

# update initial condition
acados_solver.set(0, "lbx", x0)
acados_solver.set(0, "ubx", x0)

# feedback rti_phase
acados_solver.options_set('rti_phase', 2)
status = acados_solver.solve()

from https://github.com/acados/acados/blob/master/examples/acados_python/rsm_example/generate_c_code.py

I assume that the two phases refer to the preparation phase of RTI (to do before the current state is available) and the second phase is when the solution is “adapted” to the current state. Is it correct?

In my simulations I find that the second phase is the most time consuming, I would expect the opposite, but is it something you would deem normal?

Hi,

Exactly. The rti_phase value has the following 3 values:
(1) preparation, (2) feedback, (0) both.

About how long the phases should take and if everything that can be is carried out in the preparation phase, I am not sure.
I also don’t know how the ratio for preparation and feedback time typically is. If you can point to some paper, where you got your intuition from, that would be interesting.

Cheers,
Jonathan

Thanks Jonathan,

https://www.tandfonline.com/doi/full/10.1080/00207179.2016.1222553

This is the first article that comes to my mind.

I don’t think they explicitly say that the preparation phase should be more time consuming than the feedback phase. Surely the feedback phase consists in a QP and therefore will always require some time, while the preparation phase may not be “necessary” if it were a linear MPC.

I guess what suggested me that idea was figure 3, but that’s just a visualization so I shouldn’t read too much into only that.
I wanted to be sure that I was setting the solver properly because I would have expected the feedback phase to take less, being it “only” a QP, but the more I think about it the more I understand that that’s just what it is.

Thank you again,
Tommaso

1 Like