-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_shared_files.m
108 lines (77 loc) · 3.46 KB
/
read_shared_files.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
%==========================================================================
% Description: Parses and plots shared 690 data maneuvering data
%
% Ver 1: 18 May 2021, Dan Stilwell
%
%==========================================================================
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all
DEGREES = 0;
RADIANS = 1;
ANGLES = DEGREES; % plot angles in degrees or radians
cd
% list of files: edit this list as needed
log_files = [ "share_pathfinder_dvl_node.velocity.dat", "DVL";
"share_depth_node.depth.dat", "depth";
"share_pid_attitude_control_node.pitch_pid.dat", "pitch control";
"share_pid_attitude_control_node.fins.dat", "flaps";
"share_pathfinder_dvl_node.height.dat", "altitude";
"share_inertial_nav_node.x.dat","Inertial Nav";
"share_pid_attitude_control_node.yaw_pid.dat","Yaw";
"share_ss_line_control_node.ss.dat", "line tracking";
];
saved_data_path = "C:\Users\stilw\My Drive\work\field_campaigns\2021.June.NRL\field_data\avl_log_plotter\SHARED\";
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% load tables
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
number_of_log_files = size(log_files, 1);
for i = 1:number_of_log_files
data_filename = strcat(saved_data_path, log_files(i,1));
opts = detectImportOptions(data_filename);
% 1st row is description of data, used for plot title
% 2nd row contains variable names
% 3rd row containts units
opts.DataLines = [4 Inf];
opts.VariableDescriptionsLine = 1;
opts.VariableNamesLine= 2;
opts.VariableUnitsLine = 3;
opts.VariableNamingRule = 'preserve';
p = readtable(data_filename,opts);
% put all tables and related data in an array
data_tables(i).table = p; % the table
data_tables(i).name = log_files(i); % file name of log file
data_tables(i).figure_title = p.Properties.VariableDescriptions{1}; % figure title for plotting
end
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% plot variables
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
legend_strings = "";
for i = 1:number_of_log_files
% plot time versus columns 2:n
p = data_tables(i).table;
figure;
set(gcf,'name', data_tables(i).figure_title);
set(gcf,'numbertitle','off');
set(gca, 'LooseInset', get(gca,'TightInset'));
set(gcf,'WindowStyle', 'docked')
n_columns = size(p,2);
for j=2:n_columns %this is the number of data rows not including time
if (ANGLES == DEGREES)
if ((data_tables(i).table.Properties.VariableUnits{j} == "rad") | ( data_tables(i).table.Properties.VariableUnits{j} == "rad/s" ) )
p{:,j} = p{:,j}*180/pi;
if (data_tables(i).table.Properties.VariableUnits{j} == "rad"),
legend_strings(j-1) = sprintf('%s (%s)', data_tables(i).table.Properties.VariableNames{j},"degrees");
else
legend_strings(j-1) = sprintf('%s (%s)', data_tables(i).table.Properties.VariableNames{j},"degrees/sec");
end
else
legend_strings(j-1) = sprintf('%s (%s)', data_tables(i).table.Properties.VariableNames{j},data_tables(i).table.Properties.VariableUnits{j});
end
end
end
plot(p{:,1}, p{:,2:n_columns})
legend(legend_strings);
xlabel('time (secs)');
end