CasADi callbacks

Hi,

I am interested in implementing an NMPC with the acados Python interface with Gaussian process based dynamics, similar to what is discussed in this CasADi blog post: https://web.casadi.org/blog/tensorflow/. It involves defining custom callbacks in CasADi. Does acados support defining the cost function and/or dynamics using such callback functions?

Cheers,
Martin

Hi Martin,

Interesting question!

The acados Python interface relies on two important CasADi features.

  1. the AD capabilities
  2. C code generation

These features are not supported for CasADi callbacks.
Unfortunately, it is thus not straight forward to implement what you described.

The last part of the blog post shows how the reverse AD of tensorflow can be interfaced to the CasADi callback.
However, acados typically uses the forward AD, as far as I know.
And extending this to also support C code generation of the derivatives seems not easy too.

Best,
Jonathan

Hi Jonathan,

Thanks for your reply.

That is unfortunate. Then it looks like I will have to stick to CasADi and hope it is fast enough for real-time useā€¦

Thanks for all the great work you do!

Cheers,
Martin

@martiabr , you could try to see if this example helps you: https://github.com/acados/acados/blob/master/examples/acados_python/getting_started/ocp/ocp_example_cost_formulations.py

Note that the cost ad dynamics are defined with casadi functions, so perhaps you could re-write your problem accordingly?

Hope it helps!