Adaptation from Acado Toolkit

Hi everyone,

I am currently working on an adaptation of a Nonlinear MPC for a formation of drones in acados. The problem was first implemented in Matlab using Acado Toolkit with code generation and I have to adapt it to acados.

To make sure that my implementation is correct, I just have a few questions:
On tolerances:

  • In Acado, we can check that the KKT tolerance to make sure the solution is correct. Is there any way to check it using the ‘sqp_rti’ nlp_solver ? Indeed, I can’t find any similar information in the statistics.
  • Using ‘sqp’ as the nlp_solver, we can retrieve the tolerances for the four KKT conditions separately. If I set them to the same amount that I want to have in Acado for the KKT tolerance, will it behave in the same way or is there any difference?

On parameters:

  • In the Acado version, the parameters are set over all horizon, as in acados, we can set the first time step with set(‘p’, p_first_step). For other time steps, is it correct to set them using set(‘p’, p_ith_step, i)?
  • If it is the case, is there a way to set the parameters for all steps at once?

On initialization:

  • Before calling the solver, is it needed to initialize the states and inputs after the first MPC step or are they set automatically to the previous shifted solutions?

The information relative to the system used are the following:
OS is Ubuntu 18.04.6
Matlab version is R2021b

Thanks a lot for your reply in advance,
Frank Centamori

Hi Frank,

Right, by default the residual is not evaluted in the RTI implementation. You can set the option ext_qp_res to evaluate the residual of the QP.
Alternatively, you can use SQP with just 1 SQP iteration.

It should. But I am not very familiar with ACADO admittedly.

In Matlab, if you omit the stage index, e.g. doing set(‘p’, p_val), the value is set for the field for all shooting nodes. Thus, set(‘p’, p_val) sets the parameter to p_val for all the shooting nodes.

If you don’t initialize the solver explicitly, it is initialized with the previous (non-shifted) solution.

Best,
Jonathan

1 Like

Thank you for your answer.

Hello again,

Regarding this solution:

So, I’ve tried to use either versions to achieve the result I want.

For the first version, my problem is that, with code generation, the sqp_rti solver will not give me the information when I set ext_qp_res. I have tried in the extensive_example_ocp. Solving using directly the ocp solver gives the information, but in the code generation part, it does not. And I did not find a way to set the option in the code generated solver.

Using the second version, I stated that the sqp must do only 1 iteration. This results of course in the solver doing only 1 iteration, but the information for the solver returns only 0.000000e+00 for the residuals.

Is there a way to solve either one of these problems?

Thanks in advance and have a good day,
Frank

Hi Frank,

I see, the ext_qp_res option is not interfaced in the code generation part.

Since you seem to use the generated solver.
I would like to point you to the get_residuals function in the Python interface:

The calls to the C functions in there can be used with SQP_RTI in the code generated solver, namely evaluating the residuals, which is not done by default in RTI for performance, and then calling the getters.

I am not sure in what framework you are using the code generated solver.
If in C++, ROS or the like you can just make those calls to the shared library.
It would of course be nice to also add this functionality to the Matlab interface.

Best,
Jonathan

Hello,

Thanks a lot. I’m using Matlab yes, and I also think it would be a good thing to have this functionality in Matlab.

Best,
Frank