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
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.
I am still trying to use “EXTERNAL” cost function in the python interface and generate the C-code. I am getting this error.
Error: Failed to render ‘acados_solver.in.c’
Reason: Variable cost.yref[j] not found in context while rendering ‘acados_solver.in.c’: the evaluated version was cost.yref.0. Maybe the index is out of bounds?
Do I need to set yref if I am setting cost as external?