Skip to content
Snippets Groups Projects
Commit a628f876 authored by burneykb's avatar burneykb
Browse files

Merge branch 'master' into virt_quad

parents 63850629 311a4c8a
No related branches found
No related tags found
No related merge requests found
...@@ -5,20 +5,20 @@ sim('test_model.slx'); ...@@ -5,20 +5,20 @@ sim('test_model.slx');
% Determine model time for various sampling times and scale it according to % Determine model time for various sampling times and scale it according to
% logged data timescale % logged data timescale
indices_40ms = find(pitch_setpoint_model.time > time(1)); indices_40ms = find(pitch_setpoint_model.time >= time(1));
indices_5ms = find(x_command_model.time > time(1)); indices_5ms = find(x_command_model.time >= time(1));
time_model_40ms = pitch_setpoint_model.time(indices_40ms); time_model_40ms = pitch_setpoint_model.time(indices_40ms);
time_model_5ms = x_command_model.time(indices_5ms); time_model_5ms = x_command_model.time(indices_5ms);
% Pull x control structure data % Pull x control structure data
pitch_setpoint_model_data = pitch_setpoint_model.signals.values(indices_40ms); pitch_setpoint_model_data = pitch_setpoint_model.signals.values(indices_40ms);
pitchrate_setpoint_model_data = pitchrate_setpoint_model.signals.values(indices_40ms); pitchrate_setpoint_model_data = pitchrate_setpoint_model.signals.values(indices_5ms);
x_command_model_data = x_command_model.signals.values(indices_5ms); x_command_model_data = x_command_model.signals.values(indices_5ms);
x_position_model_data = x_position_model.signals.values(indices_40ms); x_position_model_data = x_position_model.signals.values(indices_40ms);
% Pull y control structure data % Pull y control structure data
roll_setpoint_model_data = roll_setpoint_model.signals.values(indices_40ms); roll_setpoint_model_data = roll_setpoint_model.signals.values(indices_40ms);
rollrate_setpoint_model_data = rollrate_setpoint_model.signals.values(indices_40ms); rollrate_setpoint_model_data = rollrate_setpoint_model.signals.values(indices_5ms);
y_command_model_data = y_command_model.signals.values(indices_5ms); y_command_model_data = y_command_model.signals.values(indices_5ms);
y_position_model_data = y_position_model.signals.values(indices_40ms); y_position_model_data = y_position_model.signals.values(indices_40ms);
...@@ -28,7 +28,7 @@ z_position_model_data = z_position_model.signals.values(indices_40ms); ...@@ -28,7 +28,7 @@ z_position_model_data = z_position_model.signals.values(indices_40ms);
% Pull yaw control structure data % Pull yaw control structure data
yawrate_setpoint_model_data = yawrate_setpoint_model.signals.values(indices_40ms); yawrate_setpoint_model_data = yawrate_setpoint_model.signals.values(indices_40ms);
yaw_command_model_data = yaw_command_model.signals.values(indices_40ms); yaw_command_model_data = yaw_command_model.signals.values(indices_5ms);
yaw_value_model_data = yaw_value_model.signals.values(indices_40ms); yaw_value_model_data = yaw_value_model.signals.values(indices_40ms);
% Pull duty cycle commands from model % Pull duty cycle commands from model
...@@ -59,7 +59,7 @@ legend('Log', 'Model', 'location', 'northwest'); ...@@ -59,7 +59,7 @@ legend('Log', 'Model', 'location', 'northwest');
% Plot pitch controller output % Plot pitch controller output
subplot(2, 2, 2); subplot(2, 2, 2);
stairs(time, pitchrate_setpoint,'.-'); hold on; grid minor; stairs(time, pitchrate_setpoint,'.-'); hold on; grid minor;
stairs(time_model_40ms, pitchrate_setpoint_model_data, '.-'); hold off; stairs(time_model_5ms, 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)');
...@@ -97,7 +97,7 @@ legend('Log', 'Model', 'location', 'northwest'); ...@@ -97,7 +97,7 @@ legend('Log', 'Model', 'location', 'northwest');
% Plot roll controller output % Plot roll controller output
subplot(2, 2, 2); subplot(2, 2, 2);
stairs(time, rollrate_setpoint,'.-'); hold on; grid minor; stairs(time, rollrate_setpoint,'.-'); hold on; grid minor;
stairs(time_model_40ms, rollrate_setpoint_model_data, '.-'); hold off; stairs(time_model_5ms, 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)');
...@@ -143,7 +143,7 @@ legend('Log', 'Model', 'location', 'northwest'); ...@@ -143,7 +143,7 @@ legend('Log', 'Model', 'location', 'northwest');
%% Plot yaw control structure %% Plot yaw control structure
% Plot roll controller output % Plot yaw controller output
figure(4); subplot(2, 2, 1); figure(4); subplot(2, 2, 1);
stairs(time, yawrate_setpoint,'.-'); hold on; grid minor; stairs(time, yawrate_setpoint,'.-'); hold on; grid minor;
stairs(time_model_40ms, yawrate_setpoint_model_data, '.-'); hold off; stairs(time_model_40ms, yawrate_setpoint_model_data, '.-'); hold off;
...@@ -155,7 +155,7 @@ legend('Log', 'Model', 'location', 'northwest'); ...@@ -155,7 +155,7 @@ legend('Log', 'Model', 'location', 'northwest');
% Plot yaw controller command % Plot yaw controller command
subplot(2, 2, 2); subplot(2, 2, 2);
stairs(time, yaw_command, '.-'); hold on; grid minor; stairs(time, yaw_command, '.-'); hold on; grid minor;
stairs(time_model_40ms, yaw_command_model_data, '.-'); hold off; stairs(time_model_5ms, yaw_command_model_data, '.-'); hold off;
title('Yaw Command'); title('Yaw Command');
xlabel('Time (s)'); xlabel('Time (s)');
ylabel('Command'); ylabel('Command');
......
...@@ -216,7 +216,8 @@ elseif logAnalysisToggle == 1 && temp == 1 ...@@ -216,7 +216,8 @@ elseif logAnalysisToggle == 1 && temp == 1
[dataStruct, headers] = parse_log_model(params.file.pathName); [dataStruct, headers] = parse_log_model(params.file.pathName);
time = dataStruct.Time.data; time = dataStruct.Time.data;
%time = dataStruct.time.data; time = time - time(1);
runtime = max(time); runtime = max(time);
% Determine x position error % Determine x position error
...@@ -236,12 +237,12 @@ elseif logAnalysisToggle == 1 && temp == 1 ...@@ -236,12 +237,12 @@ elseif logAnalysisToggle == 1 && temp == 1
% Determine pitch error % Determine pitch error
pitch_setpoint = dataStruct.X_pos_PID_Correction.data; pitch_setpoint = dataStruct.X_pos_PID_Correction.data;
pitch_value = dataStruct.VRPN_Pitch_Constant.data; pitch_value = dataStruct.Pitch_Constant.data;
pitch_error = timeseries(pitch_setpoint - pitch_value, time); pitch_error = timeseries(pitch_setpoint - pitch_value, time);
% Determine roll error % Determine roll error
roll_setpoint = dataStruct.Y_pos_PID_Correction.data; roll_setpoint = dataStruct.Y_pos_PID_Correction.data;
roll_value = dataStruct.VRPN_Roll_Constant.data; roll_value = dataStruct.Roll_Constant.data;
roll_error = timeseries(roll_setpoint - roll_value, time); roll_error = timeseries(roll_setpoint - roll_value, time);
% Determine yaw error % Determine yaw error
...@@ -293,7 +294,7 @@ elseif logAnalysisToggle == 1 && temp == 1 ...@@ -293,7 +294,7 @@ elseif logAnalysisToggle == 1 && temp == 1
raw_gyro_data = timeseries( raw_gyro_data_arr , time ); raw_gyro_data = timeseries( raw_gyro_data_arr , time );
%Create time series object for z command %Create time series object for z command
throttle_command = timeseries(z_command, time); throttle_command = timeseries(dataStruct.RC_Throttle_Constant.data, time);
%Pull the measurements from the complimentary filter %Pull the measurements from the complimentary filter
pitch_measured_IMU = dataStruct.Pitch_Constant.data; pitch_measured_IMU = dataStruct.Pitch_Constant.data;
......
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