ACADOS C++ Interface

Hi!

I am interested in contributing towards a high-performance user-friendly native C++ interface to acados. Any roadmap recomendations? Anyone joining the quest?

Thanks!

Hi,

I just answered here:

But maybe we can follow up here with what you have in mind and how that would simplify using acados within C++ with respect to just using the C interface as I mentioned.

Hi @FreyJo. Thanks! I’ll give it a try.

Well, the core idea is to avoid code_generation, since it is a bit of a nightmare for practitioners to keep track of the indices and change all the code around the problem everytime you change the OCP. Here is a paper from your group that explains this pain extensively. I did an interface for ACADO, to somehow improve the user experience around the generated code and speed up my workflow. Might be dragons here & here, but let me know if you have any questions :slight_smile:

To achieve the goal of modularity and flexibility, object oriented programming (OOP) is the way to go (link). Here are some thoughts on how I would start:

As you probably noticed, most data structures in the OCP can be generated parametrically from nx, nu, N, etc. This can be well exploited by object oriented programming to automatize the initialization of the OCP, perform automatic memory management (link) and I expect some other benefits on the way.

I agree that I could just wrap the C interface into C++ but my OCD doesn’t allow me XD. Let’s make a beautiful interface that users love so we can dominate the MPC market :wink:. With a bit of help, I can also contribute to the documentation.

Anyway, no pressure here. I just wanted to work on this on my free time to contribute to the group that helped me during my PhD :slight_smile:. Here are some highlights, with acado though: moon_rover, autonomous_drone.

Hi Manuel,

Thanks for your reply on your background and motivation!
It sounds great and of course I generally want to encourage such a contribution from you! :slight_smile:

I think I am aware of the advantages of OOP in general and the downsides of code generation pointed out in that paper.
Some critical points, I currently see:

  • nonlinear functions - it is most convenient to use the ones generated from CasADi.
    → this means compilation and linking after specifying the problem [functions] can in general not be avoided.
  • why would a C++ interface not wrap the C interface?
  • “keep track of the indices” - how would you want to avoid that?
    Are you thinking about referring to entries of the states with names instead of indices?

:raised_hands:

If you like, we can schedule a virtual meeting to discuss this topic and a possible contribution.
Please send me a private message on the forum and suggest a date if you are interested :slight_smile:

Best,
Jonathan

Thanks! Very interesting…

  • Nonlinear functions are an issue. We would need to restrict ourselves to linear functions and see how we can generate the nonlinear ones then. We could employ C++ templates for that.
  • Wrapping the C interface with C++ would be my first approach, since the core objective is the C++ user interface, but we would loose the C++ abstractions and memory management goodies at the low level. Not concerned about that.
  • I already took care of the “keeping track of the indices” issue for ACADO, and should be similar for acados. It is a bit complex, and requires C++17 metaprogramming features, but here is some documentation.

Of course, pulling this off is a hard, but that’s what we love right? :stuck_out_tongue_winking_eye:. I’ll ping you to see how we proceed.

Thanks!