diff --git a/simPrototypeSTART.m b/simPrototypeSTART.m index 5aeefcd..822d600 100644 --- a/simPrototypeSTART.m +++ b/simPrototypeSTART.m @@ -3,17 +3,17 @@ close all; clear all; clc; %% User Defined Values % Initial Conditions -Kp = -8; -Ki = -0.25; -Kd = -1.6818; +Kp = -6.8699; +Ki = 0; +Kd = -0.775; v0 = 0; % Initial Velocity (z) [m/s] M0 = 1.2; % Initial Mass [kg] yaw0 = 75; % Initial Yaw [deg] -pitch0 = 0; % Initial Pitch [deg] +pitch0 = 30; % Initial Pitch [deg] roll0 = 0; % Initial Roll [deg] p0 = 0; % Initial Angular Velocity (x) [deg/s] -q0 = 0; % Initial Angular Velocity (y) [deg/s] +q0 = 0; % Initial Angular Velocity (y) [deg/s] r0 = 0; % Initial Angular Velocity (z) [deg/s] Tcurve = readmatrix('F15_thrustCurve.txt'); % Thrust Curve from .txt [t, N] @@ -25,8 +25,8 @@ Mb = M0 - Mp; % Bu tb = Tcurve(end, 1) - Tcurve(1, 1); % Burn Time [s] mdot = Mp / tb; % Mass Flow Rate [kg/s] D = 0; % Drag [N] -stepSize = 1/100; % Simulation Step Size [s] -maxServo = 7.5; % Max Servo Rotation [deg] +stepSize = 1/1000; % Simulation Step Size [s] +maxServo = 7; % Max Servo Rotation [deg] % Moment of Inertia / Mass I11 = (1/12) * 0.5318^2 + 0.25 * 0.05105^2; % (1/12) * h^2 + 0.25 * r^2 @@ -36,9 +36,9 @@ I = [I11 0 0; 0 I22 0; 0 0 I33]; % I %% Pre-Sim Calcs %K = calcLQR(I*M0) % LQR Gain Calcs -[h0, vb, burnStartTime] = burnStartTimeCalc(Tcurve, tb, M0, mdot, Mb, v0); % Burn Start Time Calc +[h0, vb, burnStartTime] = burnStartTimeCalc(Tcurve, tb, M0, mdot, Mb, v0) % Burn Start Time Calc h0 = 21; -simTime = burnStartTime + tb; % Simulation Time [s] +simTime = burnStartTime + tb % Simulation Time [s] yaw0 = yaw0 * pi / 180; % Initial Yaw [rad] pitch0 = pitch0 * pi / 180; % Initial Pitch [rad] @@ -55,6 +55,20 @@ load_system(model); simOut = sim(model); toc +%% Write to CSV +t = simOut.v.Time; +pos = simOut.h.Data; +vel = simOut.v.Data; +accel = simOut.a.Data; +ypr = simOut.YPR.Data; +yprDot = simOut.YPRdot.Data; +servo1 = [zeros(1163,1);simOut.servo1.Data]; +servo2 = [zeros(1163,1);simOut.servo2.Data]; +PIDx = simOut.PIDx.Data; +PIDy = simOut.PIDy.Data; + +M = [t, pos, vel, accel, ypr, yprDot, servo1, servo2, PIDx, PIDy]; +writematrix(M, 'out.xls'); %% Outputs % figure(1) %