Skip to content
Snippets Groups Projects
Commit a18ae6b3 authored by burneykb's avatar burneykb
Browse files
parents ee6a0850 6a55b2c2
No related branches found
No related tags found
No related merge requests found
......@@ -5,20 +5,20 @@ sim('test_model.slx');
% Determine model time for various sampling times and scale it according to
% logged data timescale
indices_40ms = find(pitch_setpoint_model.time > time(1));
indices_5ms = find(x_command_model.time > time(1));
indices_40ms = find(pitch_setpoint_model.time >= time(1));
indices_5ms = find(x_command_model.time >= time(1));
time_model_40ms = pitch_setpoint_model.time(indices_40ms);
time_model_5ms = x_command_model.time(indices_5ms);
% Pull x control structure data
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_position_model_data = x_position_model.signals.values(indices_40ms);
% Pull y control structure data
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_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);
% Pull yaw control structure data
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);
% Pull duty cycle commands from model
......@@ -59,7 +59,7 @@ legend('Log', 'Model', 'location', 'northwest');
% Plot pitch controller output
subplot(2, 2, 2);
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');
xlabel('Time (s)');
ylabel('d\theta/dt (rad/s)');
......@@ -97,7 +97,7 @@ legend('Log', 'Model', 'location', 'northwest');
% Plot roll controller output
subplot(2, 2, 2);
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');
xlabel('Time (s)');
ylabel('d\phi/dt (rad/s)');
......@@ -143,7 +143,7 @@ legend('Log', 'Model', 'location', 'northwest');
%% Plot yaw control structure
% Plot roll controller output
% Plot yaw controller output
figure(4); subplot(2, 2, 1);
stairs(time, yawrate_setpoint,'.-'); hold on; grid minor;
stairs(time_model_40ms, yawrate_setpoint_model_data, '.-'); hold off;
......@@ -155,7 +155,7 @@ legend('Log', 'Model', 'location', 'northwest');
% Plot yaw controller command
subplot(2, 2, 2);
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');
xlabel('Time (s)');
ylabel('Command');
......
......@@ -216,7 +216,8 @@ elseif logAnalysisToggle == 1 && temp == 1
[dataStruct, headers] = parse_log_model(params.file.pathName);
time = dataStruct.Time.data;
%time = dataStruct.time.data;
time = time - time(1);
runtime = max(time);
% Determine x position error
......@@ -236,12 +237,12 @@ elseif logAnalysisToggle == 1 && temp == 1
% Determine pitch error
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);
% Determine roll error
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);
% Determine yaw error
......@@ -293,7 +294,7 @@ elseif logAnalysisToggle == 1 && temp == 1
raw_gyro_data = timeseries( raw_gyro_data_arr , time );
%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
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