Skip to content

Commit

Permalink
MEX: fix generic_external_cost example
Browse files Browse the repository at this point in the history
  • Loading branch information
FreyJo committed Mar 5, 2021
1 parent c4bf95d commit 74d3e69
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion interfaces/acados_matlab_octave/acados_ocp.m
Expand Up @@ -90,7 +90,10 @@
elseif (strcmp(obj.model_struct.cost_type, 'nonlinear_ls'))
obj.model_struct.cost_expr_y_0 = obj.model_struct.cost_expr_y;
elseif (strcmp(obj.model_struct.cost_type, 'ext_cost'))
obj.model_struct.cost_expr_ext_cost_0 = obj.model_struct.cost_expr_ext_cost;
obj.model_struct.ext_fun_type_0 = obj.model_struct.ext_fun_type;
if strcmp(obj.model_struct.ext_fun_type_0, 'casadi')
obj.model_struct.cost_expr_ext_cost_0 = obj.model_struct.cost_expr_ext_cost;
end
end
if (strcmp(obj.model_struct.cost_type, 'linear_ls')) || (strcmp(obj.model_struct.cost_type, 'nonlinear_ls'))
obj.model_struct.cost_W_0 = obj.model_struct.cost_W;
Expand Down
2 changes: 1 addition & 1 deletion interfaces/acados_matlab_octave/generate_c_code_ext_cost.m
Expand Up @@ -92,7 +92,7 @@ function generate_c_code_ext_cost( model, opts, target_dir )
ext_cost_fun_jac.generate([model_name,'_cost_ext_cost_fun_jac'], casadi_opts);
end

if isfield(model, 'cost_expr_ext_cost_0')% && strcmp(model.ext_fun_type_e, 'casadi')
if isfield(model, 'cost_expr_ext_cost_0') && strcmp(model.ext_fun_type_0, 'casadi')
ext_cost_0 = model.cost_expr_ext_cost_0;
% generate jacobian, hessian
[full_hess, grad] = hessian(ext_cost_0, vertcat(u, x));
Expand Down

0 comments on commit 74d3e69

Please sign in to comment.