Start working on MPC Class

- Add `MPC_Class` to perform all MPC related computation
  for use with part 2's deliverable function
This commit is contained in:
Sravan Balaji
2021-12-10 07:31:13 -05:00
parent a0d868db88
commit b562360f6b

View File

@@ -0,0 +1,77 @@
% Written by: Sravan Balaji, Xenia Demenchuk, and Peter Pongsachai
% Created: 10 Dec 2021
classdef MPC_Class
%MPC_CLASS Summary of this class goes here
% Detailed explanation goes here
properties
% Vehicle Parameters (Table 1)
Nw = 2;
f = 0.01;
Iz = 2667;
a = 1.35;
b = 1.45;
By = 0.27;
Cy = 1.2;
Dy = 0.7;
Ey = -1.6;
Shy = 0;
Svy = 0;
m = 1400;
g = 9.806;
% Input Limits (Table 1)
delta_lims = [-0.5, 0.5];
Fx_lims = [-5e3, 5e3];
% Position Limits (Min/Max based on track)
x_lims = [ 200, 1600];
y_lims = [-200, 1000];
% Initial Conditions (Equation 15)
state_init = [ ...
287; ... % x [m]
5; ... % u [m/s]
-176; ... % y [m]
0; ... % v [m/s]
2; ... % psi [rad]
0; ... % r [rad/s]
];
% Simulation Parameters
T_s = 0.01; % Step Size [s]
T_p = 0.5; % Prediction Horizon [s]
% Decision Variables
% Y: State [x; u; y; v; psi; r]
% U: Input [delta_f; F_x]
% Z: Decision Variable [Y(0);...;Y(n+1);U(0);...;U(n)]
npred = T_p / T_s;
nstates = 6;
ninputs = 2;
ndec = (npred+1)*nstates + npred*ninputs;
% Track & Reference Trajectory Information
TestTrack;
Y_ref;
U_ref;
end
methods
function obj = MPC_Class(TestTrack, Y_ref, U_ref)
%MPC_CLASS Construct an instance of this class
% Store provided track & trajectory information
obj.TestTrack = TestTrack;
obj.Y_ref = Y_ref;
obj.U_ref = U_ref;
end
% function outputArg = method1(obj,inputArg)
% %METHOD1 Summary of this method goes here
% % Detailed explanation goes here
% outputArg = obj.Property1 + inputArg;
% end
end
end