How to use C-code with external cost function

Hi :wave:

I am trying to generate C-code using python interface. I have set my cost function to ‘EXTERNAL’. The cost function has parameters in order to change the reference. I am using this C-code in my ROS2 node.

When I build the C-code its giving me an error “model entry: yref not available in module ocp_nlp_cost_external”.

I have set dummy yref and yref_e to numpy arrays of zeroes in the python script. I have also set “ny” and ny_e" to the number according to my states and inputs.

How do I solve this model entry: yref not available in module ocp_nlp_cost_external error

Thank you for your help,
Rohan

Hi,

The external function module does not have y_\mathrm{ref} as part of the cost function definition.
Thus, it can not be set for this cost module.
Please check the cost function documentation.
You can use the EXTERNAL cost module with casadi parameters for varying references or the like.

Cheers!