Possibility to add output functions to acados


We use Matlab and CasADi to specify our Acados OCPs, and we often have the need to extract information from the OCP solve which is not directly contained in the state or control vector,

For example we might have a rotational velocity ‘w’ as a state and the torque applied to that body as decision variable ‘T’. In this case it could be that we are really interested in the power p=w*T. To get this value we need to re-implement this computation outside of the Acados definition.

This is of course possible, but creates the risk of introducing mistakes since the same expressions must be replicated in two places. We therefore think it would be valueable if we could specify and output function.

As an example assume that F is a CasADi function of the state, decisions variables and parameters, then it would be very convenient if we could set the output_expression like below and have the result of that expression calculated as part of the solver call.


Currently we achieve this by using CasADi’s s-function generation capabilities CasADi - Blog - CasADi codegen and S-Functions but it would be nice to have similar or more generic/better functionality embedded in Acados.


I see that this might be useful.
However, I don’t think this will be high priority in the acados developer team for now.

This is very disconnected from the solver itself, the only thing being shared is that parameters are updated in the same way.
Thus, it could be realized just within the template based interface and without touching the acados core.