Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code generation #124

Open
ufechner7 opened this issue Nov 11, 2024 · 2 comments
Open

Code generation #124

ufechner7 opened this issue Nov 11, 2024 · 2 comments

Comments

@ufechner7
Copy link

What would be the way forward to become able to run an MPC controller on a small microcontroller?

Other packages implement C code generation. Would that be possible, or what could be alternatives?

@baggepinnen
Copy link
Member

There is no code generation from this package yet, and it's not a small task to implement. One possible way forward is to use the code-generation capabilities of an existing MPC package with this feature, such as acados. I have a proof-of-concept doing that here https://github.com/baggepinnen/AcadosInterface.jl You would have to manually create the acados problem by passing the same cost matrices to acados as you do to MPC.jl, but this should be quite straightforward. It's limited to things that are easy to express in both Symbolics.jl and CasADi, so it does not accept any arbitrary dynamics.

@franckgaga
Copy link
Member

One issue with code generation in general is how it can be hard to exactly reproduce results. I expect to see difference between MPC.jl results and the Acados interface (different solvers, state estimators, linear algebra libraries, etc.). Hopefully, these differences will be negligible for well-conditioned problems.

In the end code generation is just another form of the two-language problem. It may be kind of a long shot prediction, but I think the future of MPC lies in more advanced control hardware, like a full-fledge computer or server instead of embedded platform. Micro-controllers and PLCs computational capabilities are more than enough for PIDs, but the layers of complexity in MPC (solvers, automatic differentiation libraries, linear algebra libraries, etc.) clearly benefits from Julia's modern features like the composability, the package manager, etc.

Still, code generation features for this package would be extremely useful right now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants