diff --git a/controls/model/loggingAnalysis/logAnalysis.m b/controls/model/loggingAnalysis/logAnalysis.m index 4aae4c6b95a014962b6239467a5bd25e2c91a42f..d713a65bc2e51180c5078de694ef94f3bfa6f53b 100644 --- a/controls/model/loggingAnalysis/logAnalysis.m +++ b/controls/model/loggingAnalysis/logAnalysis.m @@ -40,7 +40,7 @@ stairs(time_model_40ms, pitch_setpoint_model_data, '.-'); hold off; title('Lateral Controller Output'); xlabel('Time (s)'); ylabel('\theta (rad)'); -legend('Log', 'Model'); +legend('Log', 'Model', 'location', 'northwest'); % Plot pitch controller output subplot(2, 2, 2); @@ -49,7 +49,7 @@ stairs(time_model_40ms, pitchrate_setpoint_model_data, '.-'); hold off; title('Pitch Controller Output'); xlabel('Time (s)'); ylabel('d\theta/dt (rad/s)'); -legend('Log', 'Model'); +legend('Log', 'Model', 'location', 'northwest'); % Plot x controller command subplot(2, 2, 3); @@ -58,7 +58,7 @@ stairs(time_model_5ms, x_command_model_data, '.-'); hold off; title('X Command'); xlabel('Time (s)'); ylabel('Command'); -legend('Log', 'Model'); +legend('Log', 'Model', 'location', 'northwest'); % Plot x position subplot(2, 2, 4); @@ -67,7 +67,7 @@ stairs(time_model_40ms, x_position_model_data, '.-'); hold off; title('X Position'); xlabel('Time (s)'); ylabel('Position (m)'); -legend('Log', 'Model'); +legend('Log', 'Model', 'location', 'northwest'); %% Plot y control structure @@ -78,7 +78,7 @@ stairs(time_model_40ms, pitch_setpoint_model_data, '.-'); hold off; title('Longitude Controller Output '); xlabel('Time (s)'); ylabel('\phi (rad)'); -legend('Log', 'Model'); +legend('Log', 'Model', 'location', 'northwest'); % Plot roll controller output subplot(2, 2, 2); @@ -87,7 +87,7 @@ stairs(time_model_40ms, rollrate_setpoint_model_data, '.-'); hold off; title('Roll Controller Output'); xlabel('Time (s)'); ylabel('d\phi/dt (rad/s)'); -legend('Log', 'Model'); +legend('Log', 'Model', 'location', 'northwest'); % Plot y controller command subplot(2, 2, 3); @@ -96,7 +96,7 @@ stairs(time_model_5ms, y_command_model_data, '.-'); hold off; title('Y Command'); xlabel('Time (s)'); ylabel('Command'); -legend('Log', 'Model'); +legend('Log', 'Model', 'location', 'northwest'); % Plot y position subplot(2, 2, 4); @@ -105,7 +105,7 @@ stairs(time_model_40ms, y_position_model_data, '.-'); hold off; title('Y Position'); xlabel('Time (s)'); ylabel('Position (m)'); -legend('Log', 'Model'); +legend('Log', 'Model', 'location', 'northwest'); %% Plot z control structure @@ -116,7 +116,7 @@ stairs(time_model_40ms, z_command_model_data, '.-'); hold off; title('Z Command'); xlabel('Time (s)'); ylabel('Command'); -legend('Log', 'Model'); +legend('Log', 'Model', 'location', 'northwest'); % Plot z position subplot(2, 1, 2); @@ -125,7 +125,7 @@ stairs(time_model_40ms, z_position_model_data, '.-'); hold off; title('Z Position'); xlabel('Time (s)'); ylabel('Position (m)'); -legend('Log', 'Model'); +legend('Log', 'Model', 'location', 'northwest'); %% Plot yaw control structure @@ -136,7 +136,7 @@ stairs(time_model_40ms, yawrate_setpoint_model_data, '.-'); hold off; title('Yaw Controller Output'); xlabel('Time (s)'); ylabel('d\psi/dt (rad/s)'); -legend('Log', 'Model'); +legend('Log', 'Model', 'location', 'northwest'); % Plot yaw controller command subplot(2, 2, 2); @@ -145,7 +145,7 @@ stairs(time_model_40ms, yaw_command_model_data, '.-'); hold off; title('Yaw Command'); xlabel('Time (s)'); ylabel('Command'); -legend('Log', 'Model'); +legend('Log', 'Model', 'location', 'northwest'); % Plot yaw position subplot(2, 2, 3); @@ -154,4 +154,4 @@ stairs(time_model_40ms, yaw_value_model_data, '.-'); hold off; title('Yaw Position'); xlabel('Time (s)'); ylabel('Value (rad)'); -legend('Log', 'Model'); \ No newline at end of file +legend('Log', 'Model', 'location', 'northwest'); \ No newline at end of file diff --git a/controls/model/modelParameters.m b/controls/model/modelParameters.m index 5af568c42ae034703801eb4d55c26d80c4cc5738..9ed5d14109548d4115835d454df256cc834e82f8 100644 --- a/controls/model/modelParameters.m +++ b/controls/model/modelParameters.m @@ -1,6 +1,10 @@ % Log Analysis Toggle logAnalysisToggle = 1; % 1 for log analysis, 0 for normal operation +% Define Simulink Runtime (if logAnalysisToggle is selected, this will be +% automatically set based on the log files time) + runtime = 20; + % Model Parameters m = 1.244; % Quadrotor + battery mass g = 9.81; % Acceleration of gravity @@ -37,12 +41,12 @@ % Import Data and determine errors if logAnalysisToggle == 1 - % Import Data to Workspace data = importdata('loggingAnalysis/logFiles/logData.csv'); % Set up time vector time = data.data(:, 1); + runtime = max(time); % Determine x position error x_setpoint = data.data(:, 25); diff --git a/controls/model/test_model.slx b/controls/model/test_model.slx index fcf716855f95156454eb3da5d19ef6c99b22301c..580cbfee5ee130885a96fc9f254099058bfb5e41 100644 Binary files a/controls/model/test_model.slx and b/controls/model/test_model.slx differ