Skip to content

Instantly share code, notes, and snippets.

@abe-mart
Last active April 1, 2020 00:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abe-mart/acc983005a3baf8cfd3576836b4227c5 to your computer and use it in GitHub Desktop.
Save abe-mart/acc983005a3baf8cfd3576836b4227c5 to your computer and use it in GitHub Desktop.
2D_SI_model
function model = model_SI_2D()
%2D_SI_model Super simple 2D single integrator model
import casadi.*
%% Differential states
x = SX.sym('x',2);
sym_x = x;
sym_xdot = SX.sym('xdot',numel(sym_x),1);
%% Inputs
u = SX.sym('u',2);
sym_u = u;
%% Dynamics
expr_f_expl = u;
expr_f_impl = expr_f_expl - sym_xdot;
%% Constraints
expr_h = dot(u,u);
%
% %% Cost
expr_ext_cost_e = (x(1)-10)^2 + (x(2)-5)^2;
expr_ext_cost = (x(1)-10)^2 + (x(2)-5)^2;
%% Model structure
model.nx = numel(sym_x);
model.nu = numel(sym_u);
model.sym_x = sym_x;
model.sym_xdot = sym_xdot;
model.sym_u = sym_u;
model.expr_f_impl = expr_f_impl;
model.expr_f_expl = expr_f_expl;
model.expr_h = expr_h;
model.expr_ext_cost = expr_ext_cost;
model.expr_ext_cost_e = expr_ext_cost_e;
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment