
AcadosCpp: a unified C++/Python interface for generated acados OCP solvers
Hi everyone,
I've been developing AcadosCpp, an open-source wrapper that helps you integrate acados-generated OCP solvers into both C++ and Python applications.
https://github.com/amaldevh/AcadosCpp
The main goal is to make integration easier. acados creates highly optimized C code for each model and OCP, but using its API directly can tie your application to specific symbols, dimensions, lifecycle calls, and data updates.
AcadosCpp provides a stable, stage-aware interface for the generated solver. Here’s how you typically use it:
- Define or modify the model and OCP in Python.
- Regenerate the acados solver and wrapper.
- Recompile and relink the application.
The control-loop structure in your application stays the same. If you change the model or problem, you usually don’t need to rewrite the integration layer, as long as your data matches the new dimensions and cost setup.
The wrapper includes:
- Stage-0 initial-state constraints
- Stage-varying and terminal references
- Generic raw yref support
- Per-stage and global parameters
- Full state/control initial guesses
- Shifted trajectory warm starts
- Complete predicted trajectories and solver diagnostics
- SQP-RTI preparation and feedback phases
- C++ and pybind11 interfaces
For a standard
y=[x,u], y_e=x
tracking problem, the control loop is:
const auto& u = ocp.solve(measured_x, xrefs, urefs);
This process shifts the previous solution, updates the stage-0 measurement and the full reference horizon, solves the OCP, and returns the first input.
The repository has matching Python and C++ quadrotor NMPC examples. I’d love to hear your feedback on the API, especially if you use acados with time-varying references, parameters, SQP-RTI, or custom cost outputs.