Skip to content
Snippets Groups Projects
Commit 461199e9 authored by Andy Snawerdt's avatar Andy Snawerdt
Browse files

Updated model to better support active logging

parent 1022df30
No related branches found
No related tags found
No related merge requests found
...@@ -40,7 +40,7 @@ stairs(time_model_40ms, pitch_setpoint_model_data, '.-'); hold off; ...@@ -40,7 +40,7 @@ stairs(time_model_40ms, pitch_setpoint_model_data, '.-'); hold off;
title('Lateral Controller Output'); title('Lateral Controller Output');
xlabel('Time (s)'); xlabel('Time (s)');
ylabel('\theta (rad)'); ylabel('\theta (rad)');
legend('Log', 'Model'); legend('Log', 'Model', 'location', 'northwest');
% Plot pitch controller output % Plot pitch controller output
subplot(2, 2, 2); subplot(2, 2, 2);
...@@ -49,7 +49,7 @@ stairs(time_model_40ms, pitchrate_setpoint_model_data, '.-'); hold off; ...@@ -49,7 +49,7 @@ stairs(time_model_40ms, pitchrate_setpoint_model_data, '.-'); hold off;
title('Pitch Controller Output'); title('Pitch Controller Output');
xlabel('Time (s)'); xlabel('Time (s)');
ylabel('d\theta/dt (rad/s)'); ylabel('d\theta/dt (rad/s)');
legend('Log', 'Model'); legend('Log', 'Model', 'location', 'northwest');
% Plot x controller command % Plot x controller command
subplot(2, 2, 3); subplot(2, 2, 3);
...@@ -58,7 +58,7 @@ stairs(time_model_5ms, x_command_model_data, '.-'); hold off; ...@@ -58,7 +58,7 @@ stairs(time_model_5ms, x_command_model_data, '.-'); hold off;
title('X Command'); title('X Command');
xlabel('Time (s)'); xlabel('Time (s)');
ylabel('Command'); ylabel('Command');
legend('Log', 'Model'); legend('Log', 'Model', 'location', 'northwest');
% Plot x position % Plot x position
subplot(2, 2, 4); subplot(2, 2, 4);
...@@ -67,7 +67,7 @@ stairs(time_model_40ms, x_position_model_data, '.-'); hold off; ...@@ -67,7 +67,7 @@ stairs(time_model_40ms, x_position_model_data, '.-'); hold off;
title('X Position'); title('X Position');
xlabel('Time (s)'); xlabel('Time (s)');
ylabel('Position (m)'); ylabel('Position (m)');
legend('Log', 'Model'); legend('Log', 'Model', 'location', 'northwest');
%% Plot y control structure %% Plot y control structure
...@@ -78,7 +78,7 @@ stairs(time_model_40ms, pitch_setpoint_model_data, '.-'); hold off; ...@@ -78,7 +78,7 @@ stairs(time_model_40ms, pitch_setpoint_model_data, '.-'); hold off;
title('Longitude Controller Output '); title('Longitude Controller Output ');
xlabel('Time (s)'); xlabel('Time (s)');
ylabel('\phi (rad)'); ylabel('\phi (rad)');
legend('Log', 'Model'); legend('Log', 'Model', 'location', 'northwest');
% Plot roll controller output % Plot roll controller output
subplot(2, 2, 2); subplot(2, 2, 2);
...@@ -87,7 +87,7 @@ stairs(time_model_40ms, rollrate_setpoint_model_data, '.-'); hold off; ...@@ -87,7 +87,7 @@ stairs(time_model_40ms, rollrate_setpoint_model_data, '.-'); hold off;
title('Roll Controller Output'); title('Roll Controller Output');
xlabel('Time (s)'); xlabel('Time (s)');
ylabel('d\phi/dt (rad/s)'); ylabel('d\phi/dt (rad/s)');
legend('Log', 'Model'); legend('Log', 'Model', 'location', 'northwest');
% Plot y controller command % Plot y controller command
subplot(2, 2, 3); subplot(2, 2, 3);
...@@ -96,7 +96,7 @@ stairs(time_model_5ms, y_command_model_data, '.-'); hold off; ...@@ -96,7 +96,7 @@ stairs(time_model_5ms, y_command_model_data, '.-'); hold off;
title('Y Command'); title('Y Command');
xlabel('Time (s)'); xlabel('Time (s)');
ylabel('Command'); ylabel('Command');
legend('Log', 'Model'); legend('Log', 'Model', 'location', 'northwest');
% Plot y position % Plot y position
subplot(2, 2, 4); subplot(2, 2, 4);
...@@ -105,7 +105,7 @@ stairs(time_model_40ms, y_position_model_data, '.-'); hold off; ...@@ -105,7 +105,7 @@ stairs(time_model_40ms, y_position_model_data, '.-'); hold off;
title('Y Position'); title('Y Position');
xlabel('Time (s)'); xlabel('Time (s)');
ylabel('Position (m)'); ylabel('Position (m)');
legend('Log', 'Model'); legend('Log', 'Model', 'location', 'northwest');
%% Plot z control structure %% Plot z control structure
...@@ -116,7 +116,7 @@ stairs(time_model_40ms, z_command_model_data, '.-'); hold off; ...@@ -116,7 +116,7 @@ stairs(time_model_40ms, z_command_model_data, '.-'); hold off;
title('Z Command'); title('Z Command');
xlabel('Time (s)'); xlabel('Time (s)');
ylabel('Command'); ylabel('Command');
legend('Log', 'Model'); legend('Log', 'Model', 'location', 'northwest');
% Plot z position % Plot z position
subplot(2, 1, 2); subplot(2, 1, 2);
...@@ -125,7 +125,7 @@ stairs(time_model_40ms, z_position_model_data, '.-'); hold off; ...@@ -125,7 +125,7 @@ stairs(time_model_40ms, z_position_model_data, '.-'); hold off;
title('Z Position'); title('Z Position');
xlabel('Time (s)'); xlabel('Time (s)');
ylabel('Position (m)'); ylabel('Position (m)');
legend('Log', 'Model'); legend('Log', 'Model', 'location', 'northwest');
%% Plot yaw control structure %% Plot yaw control structure
...@@ -136,7 +136,7 @@ stairs(time_model_40ms, yawrate_setpoint_model_data, '.-'); hold off; ...@@ -136,7 +136,7 @@ stairs(time_model_40ms, yawrate_setpoint_model_data, '.-'); hold off;
title('Yaw Controller Output'); title('Yaw Controller Output');
xlabel('Time (s)'); xlabel('Time (s)');
ylabel('d\psi/dt (rad/s)'); ylabel('d\psi/dt (rad/s)');
legend('Log', 'Model'); legend('Log', 'Model', 'location', 'northwest');
% Plot yaw controller command % Plot yaw controller command
subplot(2, 2, 2); subplot(2, 2, 2);
...@@ -145,7 +145,7 @@ stairs(time_model_40ms, yaw_command_model_data, '.-'); hold off; ...@@ -145,7 +145,7 @@ stairs(time_model_40ms, yaw_command_model_data, '.-'); hold off;
title('Yaw Command'); title('Yaw Command');
xlabel('Time (s)'); xlabel('Time (s)');
ylabel('Command'); ylabel('Command');
legend('Log', 'Model'); legend('Log', 'Model', 'location', 'northwest');
% Plot yaw position % Plot yaw position
subplot(2, 2, 3); subplot(2, 2, 3);
...@@ -154,4 +154,4 @@ stairs(time_model_40ms, yaw_value_model_data, '.-'); hold off; ...@@ -154,4 +154,4 @@ stairs(time_model_40ms, yaw_value_model_data, '.-'); hold off;
title('Yaw Position'); title('Yaw Position');
xlabel('Time (s)'); xlabel('Time (s)');
ylabel('Value (rad)'); ylabel('Value (rad)');
legend('Log', 'Model'); legend('Log', 'Model', 'location', 'northwest');
\ No newline at end of file \ No newline at end of file
% Log Analysis Toggle % Log Analysis Toggle
logAnalysisToggle = 1; % 1 for log analysis, 0 for normal operation 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 % Model Parameters
m = 1.244; % Quadrotor + battery mass m = 1.244; % Quadrotor + battery mass
g = 9.81; % Acceleration of gravity g = 9.81; % Acceleration of gravity
...@@ -37,12 +41,12 @@ ...@@ -37,12 +41,12 @@
% Import Data and determine errors % Import Data and determine errors
if logAnalysisToggle == 1 if logAnalysisToggle == 1
% Import Data to Workspace % Import Data to Workspace
data = importdata('loggingAnalysis/logFiles/logData.csv'); data = importdata('loggingAnalysis/logFiles/logData.csv');
% Set up time vector % Set up time vector
time = data.data(:, 1); time = data.data(:, 1);
runtime = max(time);
% Determine x position error % Determine x position error
x_setpoint = data.data(:, 25); x_setpoint = data.data(:, 25);
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment