Hi
If using the acadaos C interface. I’m trying to replicate functionality achieved in python interface. But when I go an set the y_ref for an external trajectory I get an error:
error: model entry: y_ref not available in module ocp_nlp_cost_external
the process then dies.
The specific code is something like:
Eigen::Matrix<double, NX, NX> Q;
for (size_t i=0; i< NX; i++)
{
Q.diagonal()[i] = Q_trace[i];
}
Eigen::Matrix<double, NU, NU> R;
for (size_t i =0; i< NU; i++)
{
R.diagonal()[i] = 0.01;
}
Eigen::Matrix<double, NX+NU, NX+NU> W;
W.block(0,0,NX, NX) = Q;
W.block(NX, NX, NU, NU)=R;
RCLCPP_INFO(rclcpp::get_logger("mpc_node"), "Setting Cost" );
for (size_t i =0; i < N_S; i++)
{
RCLCPP_INFO(rclcpp::get_logger("mpc_node"), "Setting Costi %d", i );
ocp_nlp_cost_model_set(nlp_config_, nlp_dims_, nlp_in_, i,
"y_ref", (double*)yref[i].data() );
// --> Code dies here
ocp_nlp_cost_model_set(nlp_config_, nlp_dims_, nlp_in_, i,
"W", (double*)W.data() );
}
RCLCPP_INFO(rclcpp::get_logger("mpc_node"), "Setting End Cost" );
ocp_nlp_cost_model_set(nlp_config_, nlp_dims_, nlp_in_, N_S,
"y_ref_e", (double*)yref[N_S].data() );
ocp_nlp_cost_model_set(nlp_config_, nlp_dims_, nlp_in_, N_S,
"W", (double*)Q.data() );
and is similar to how a reference is done in the engine example in the acados c example directory. However I initialise my nlp config using the generated functions such as
acados_ocp_capsule = <name>_acados_create_capsule();
<name>_acados_create(acados_ocp_capsule);
nlp_config_ = <name>_get_nlp_config(acados_ocp_capsule);
This is different to that used in the engine example which is full of boilerplate.
I am assuming most of this is unnecessary if development is done in python and autogenerated of a model <name>
. I am assuming that the auto generated code pre configures the nlp via the
<name>_acados_get_<this_component>(acados_ocp_capsule)
where <this_component>
is some part of the nlp problem?
How do I ensure that the capsule is initialised correctly to accept an external y_ref?