8000 MATLAB: minor cleanup of examples, rewrite to new interface by sandmaennchen · Pull Request #1206 · acados/acados · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

MATLAB: minor cleanup of examples, rewrite to new interface #1206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 50 additions & 37 deletions examples/acados_matlab_octave/control_rates/F8_crusader_model.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,50 +30,63 @@
%

function model = F8_crusader_model()
import casadi.*
import casadi.*

%% System dimension
nx = 4;
nu = 1;
%% System dimension
nx = 4;
nu = 1;

%% System parameters
a1 = -0.877; a2 = -0.088; a3 = 0.47; a4 = -0.019; a5 = 3.846; a6 = -0.215;
a7 = 0.28; a8 = 0.47; a9 = 0.63;
c1 = -4.208; c2 = -0.396; c3 = -0.47; c4 = -3.564; c5 = -20.967; c6 = 6.265;
c7 = 46; c8 = 61.4;
%% System parameters
a1 = -0.877;
a2 = -0.088;
a3 = 0.47;
a4 = -0.019;
a5 = 3.846;
a6 = -0.215;
a7 = 0.28;
a8 = 0.47;
a9 = 0.63;
c1 = -4.208;
c2 = -0.396;
c3 = -0.47;
c4 = -3.564;
c5 = -20.967;
c6 = 6.265;
c7 = 46;
c8 = 61.4;

%% Symbolic variables
% states
x1 = SX.sym('x1');
x2 = SX.sym('x2');
x3 = SX.sym('x3');
x4 = SX.sym('x4'); % extra state for the original control input
sym_x = vertcat(x1, x2, x3, x4);
%% Symbolic variables
% states
x1 = SX.sym('x1');
x2 = SX.sym('x2');
x3 = SX.sym('x3');
x4 = SX.sym('x4'); % extra state for the original control input
x = vertcat(x1, x2, x3, x4);

% controls
u = SX.sym('u'); % input rate becomes the input
sym_u = u;
% controls
u = SX.sym('u'); % input rate becomes the input

% state derivatives
sym_xdot = SX.sym('xdot', nx, 1);
% state derivatives
xdot = SX.sym('xdot', nx, 1);

%% The system dynamics
% Explicit Dynamics
expr_f_expl = vertcat(a1*x1+x3+a2*x1*x3+a3*x1.^2+a4*x2.^2-x1.^2*x3+a5*x1.^3+a6*x4+a7*x1.^2*x4+a8*x1*x4.^2+a9*x4.^3, ...
x3, ...
c1*x1+c2*x3+c3*x1.^2+c4*x1.^3+c5*x4+c6*x1.^2*x4+c7*x1*x4.^2+c8*x4.^3, ...
u); % dynamics of the added state
%% The system dynamics
% Explicit Dynamics
f_expl_expr = vertcat(
a1*x1+x3+a2*x1*x3+a3*x1.^2+a4*x2.^2-x1.^2*x3+a5*x1.^3+a6*x4+a7*x1.^2*x4+a8*x1*x4.^2+a9*x4.^3, ...
x3, ...
c1*x1+c2*x3+c3*x1.^2+c4*x1.^3+c5*x4+c6*x1.^2*x4+c7*x1*x4.^2+c8*x4.^3, ...
u); % dynamics of the added state

% Implicit Dynamics
expr_f_impl = expr_f_expl - sym_xdot;
% Implicit Dynamics
f_impl_expr = f_expl_expr - xdot;

%% fill structure
model.nx = nx;
model.nu = nu;
model.sym_x = sym_x;
model.sym_u = sym_u;
model.sym_xdot = sym_xdot;
model.expr_f_expl = expr_f_expl;
model.expr_f_impl = expr_f_impl;
% setup an acados model
model = AcadosModel();
model.x = x;
model.u = u;
model.xdot = xdot;
model.f_expl_expr = f_expl_expr;
model.f_impl_expr = f_impl_expr;
model.name = 'F8_crusader_model';

end
Loading
Loading
0