Skip to content

Commit

Permalink
Bugfix options construct fixed so they get passed correctly to osqp.s…
Browse files Browse the repository at this point in the history
…etup()
  • Loading branch information
andrino-meli authored and Ev3nt1ne committed Apr 9, 2024
1 parent b607dd8 commit 3ef9c7a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions Controllers/cp_mpc.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,16 @@
obj.ops.osqp.warm_start = 1;

% save yalmip model for potential extraction to external solver or code generation


% extract model from yalmip to QP formulation
obj.ylmp_opt_variables = {x{1},ot,ly_uref,ly_usum};
obj.ylmp_opt_output = {u{1},x{2}};
obj.ylmp_constraints = constraints;
obj.ylmp_objective = objective;
if obj.ops.warm_start
lops.osqp = obj.ops;
ymod = export(constraints,objective,lops);
%lops.osqp = obj.ops;
ymod = export(constraints,objective,sdpsettings('solver','osqp'));
% save model .mat file
lmz = struct(); % save in mazomeros file format
% cut away the -inf to inf constraints yalmip adds at the end of constraint matrix
Expand Down Expand Up @@ -139,11 +140,22 @@

% setup osqp solver
obj.osqps = osqp();
obj.osqps.setup(obj.mz.P, obj.mz.q, obj.mz.A, obj.mz.l, obj.mz.u ,ymod.options());
obj.osqps.setup(obj.mz.P, obj.mz.q, obj.mz.A, obj.mz.l, obj.mz.u ,obj.ops);
else
% generate optimizer
obj.mpc_ctrl = optimizer(constraints,objective,obj.ops,obj.ylmp_opt_variables,obj.ylmp_opt_output);
% OSQP) does not support warm-starts through YALMIP
%{
yops = sdpsettings('verbose',1,'solver','osqp', 'usex0',0);
yops.quadprog.TolCon = 1e-2;
yops.quadprog.TolX = 1e-5;
yops.quadprog.TolFun = 1e-3;
yops.convertconvexquad = 0;
yops.quadprog.MaxIter = 50;
obj.mpc_ctrl = optimizer(constraints,objective,yops,obj.ylmp_opt_variables,obj.ylmp_opt_output);
%}
obj.mpc_ctrl = optimizer(constraints,objective,obj.ops,obj.ylmp_opt_variables,obj.ylmp_opt_output);
%obj.mpc_ctrl = optimizer(constraints,objective,ops,{x{1},ot,ly_uref,ly_usum},{u{1}, x{2}});
obj.mpc_ctrl
end


Expand Down
Binary file modified noi_exploration.mlx
Binary file not shown.

0 comments on commit 3ef9c7a

Please sign in to comment.