Understanding the acados development workflow in python

Hi,

Thanks for developing acados, I have been enjoying using it.

I am using the acados python interface and I am trying to understand the best development workflow when creating an MPC controller.

As I understand it, I first create an AcadosOcp object which I can then turn into a AcadosOcpSolver object. When this happens, c code is generated, but I can still interface with this code through python.

When I create the AcadosOcpSolver object, compiling all the code takes a while (5+ minutes) which slows down progress when I am trying to iterate and debug my MPC.

  1. Is there a way to re-use the compiled Casadi code? In general (for example) while developing code, my robot dynamics won’t change, but I will be iterating on the rest of the MPC, so waiting for the same code to be re-compiled takes a while.

  2. I see that there is a build and generate option in the AcadosOcpSolver constructor that default to true. If I set these to false, I no longer need to wait for things to be compiled. Can I set these to false while developing? What happens under the hood - is the solver still being updated with my most recent changes, but everything just stays in python?

  3. Are there any other options to adjust these compilations/is there a better workflow for developing MPC with acados than what I have outlined here?

  4. Once I have finished the MPC and happy with its performance, I will need to write code that interfaces with it. If I choose to do this in python is there a way to set a flag so I don’t have to wait for the solver to be re-compiled every time I test my code?

Thanks for the help!

Hi :wave:

… and welcome to the acados forum!

  1. At the moment it is not possible to not re-generating the model, while re-generating everything else.
  2. With generate=True all required C code (both CasADi functions and templated solver-specific acados code) is generated based on the description provided by AcadosOcp. With build=True, the generated code is compiled into a shared library which the python solver will then load. The solver will not include your most recent changes if you do not regenerate and recompile!
  3. A lot of things can be changed online (i.e. without regenerating and recompiling) using solver.constraints_set(), solver.cost_set(), solver.options_set().
  4. In this case you can safely set generate=False, build=False as you only need to load the shared library.

Hope this is helpful!
Katrin