forked from JD-Kidd/7_DataAnalysisSuite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimportTruthData.m
More file actions
312 lines (217 loc) · 8.1 KB
/
importTruthData.m
File metadata and controls
312 lines (217 loc) · 8.1 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
function [ t, x, y, z ] = importTruthData( filename, should_edit )
if nargin < 2
should_edit = 1;
end
if ~nargin
done = 0;
while ~done
type = questdlg( 'What type of test?', '', 'Modular', '100m', ...
'Modular' );
switch type
case 'Modular'
[ filename, path ] = uigetfile( '*.csv' );
case '100m'
[ filename, path ] = uigetfile( '*.txt' );
otherwise
return
end
if ~path
return
end
answer = questdlg( [ 'Is ''', filename, ''' correct?' ], ...
'GPS CHECK', 'Yes', 'No', 'Cancel', 'Yes' );
switch answer
case 'Yes'
done = 1;
case 'Cancel'
return
end
end
else
path = '';
if contains( filename, '.csv' )
type = 'Modular';
elseif contains( filename, '.txt' )
type = '100m';
end
end
switch type
case 'Modular'
[ t, x, y, z ] = importVICONData( [ path, filename ] );
case '100m'
[ t, x, y, z, u, v, w ] = importTrimbleData( [ path, filename ] );
end
f = figure( 'MenuBar', 'none', 'ToolBar', 'figure', ...
'DockControls', 'off', 'WindowState', 'maximized', ...
'Name', 'TRUTH DATA', 'NumberTitle', 'off', ...
'CloseRequestFcn', @my_closereq );
[ a1, ax, ay, az ] = plotPHK( t, x, y, z );
done = ~should_edit;
while ~done
answer = questdlg( 'Would you like to remove data?', '', ...
'Yes', 'No', 'No' );
switch answer
case 'Yes'
f_Width = f.Position(3) - f.Position(1) + 1;
f_Height = f.Position(4) - f.Position(2) + 1;
a1_center = [ a1.Position(1) + a1.Position(3)/2, ...
a1.Position(2) + a1.Position(4)/2 ];
ax_center = [ ax.Position(1) + ax.Position(3)/2, ...
ax.Position(2) + ax.Position(4)/2 ];
ay_center = [ ay.Position(1) + ay.Position(3)/2, ...
ay.Position(2) + ay.Position(4)/2 ];
az_center = [ az.Position(1) + az.Position(3)/2, ...
az.Position(2) + az.Position(4)/2 ];
msg = msgbox( 'Click on the datapoint to select it.' );
waitfor( msg )
waitforbuttonpress;
cp = f.CurrentPoint ./ [ f_Width, f_Height ];
dist1 = norm( cp - a1_center );
distx = norm( cp - ax_center );
disty = norm( cp - ay_center );
distz = norm( cp - az_center );
[ ~, idx ] = min( [ dist1, distx, disty, distz ] );
switch idx
case 1
f.CurrentAxes = a1;
case 2
f.CurrentAxes = ax;
case 3
f.CurrentAxes = ay;
case 4
f.CurrentAxes = az;
end
cp = f.CurrentAxes.CurrentPoint;
p1 = cp(1,:);
p2 = cp(2,:);
vec = p2 - p1;
r = [ f.CurrentAxes.Children.XData; ...
f.CurrentAxes.Children.YData; ...
f.CurrentAxes.Children.ZData ]';
vec_dot_rp = vec(1) .* ( r(:,1) - p1(1) ) + ...
vec(2) .* ( r(:,2) - p1(2) ) + ...
vec(3) .* ( r(:,3) - p1(3) );
rp_proj_vec = [ vec(1) .* vec_dot_rp, ...
vec(2) .* vec_dot_rp, ...
vec(3) .* vec_dot_rp ] ./ norm( vec ).^2;
dist = ( r - p1 ) - rp_proj_vec;
% normalizing dist: VERY IMPORTANT
xr = diff( f.CurrentAxes.XLim );
yr = diff( f.CurrentAxes.YLim );
zr = diff( f.CurrentAxes.ZLim );
dist = [ dist(:,1) ./ xr, dist(:,2) ./ yr, dist(:,3) ./ zr ];
dist = sqrt( dist(:,1).^2 + dist(:,2).^2 + dist(:,3).^2 );
idx = dist == min(dist);
p1 = plot3( a1, x(idx), y(idx), z(idx), 'xm' );
px = plot3( ax, t(idx), x(idx), 0.*t(idx), 'xm' );
py = plot3( ay, t(idx), y(idx), 0.*t(idx), 'xm' );
pz = plot3( az, t(idx), z(idx), 0.*t(idx), 'xm' );
answer = questdlg( 'Is this the correct data point?', ...
'SELECTED POINT', 'Yes', 'No', 'Yes' );
if strcmpi( 'No', answer )
delete(p1)
delete(px)
delete(py)
delete(pz)
continue
end
answer = questdlg( 'What should be deleted?', ...
'DELETE POINT', 'Everything Left', 'Just This', ...
'Everything Right', 'Just This' );
delete(p1)
delete(px)
delete(py)
delete(pz)
switch answer
case 'Everything Right'
t = t(1:find(idx));
x = x(1:find(idx));
y = y(1:find(idx));
z = z(1:find(idx));
if strcmpi(type,'100m')
u = u(1:find(idx));
v = v(1:find(idx));
w = w(1:find(idx));
end
case 'Everything Left'
t = t(find(idx):end);
x = x(find(idx):end);
y = y(find(idx):end);
z = z(find(idx):end);
if strcmpi(type,'100m')
u = u(find(idx):end);
v = v(find(idx):end);
w = w(find(idx):end);
end
case 'Just This'
t = t(~idx);
x = x(~idx);
y = y(~idx);
z = z(~idx);
if strcmpi(type,'100m')
u = u(~idx);
v = v(~idx);
w = w(~idx);
end
otherwise
continue
end
clf
[ a1, ax, ay, az ] = plotPHK( t, x, y, z );
case 'No'
done = 1;
end
end
f.CloseRequestFcn = 'closereq';
close(f)
end
function [ a1, ax, ay, az ] = plotPHK( t, p, h, k )
a1 = subplot(1,2,1);
% this will hold a 3D map of the GPS PHK Data
hold on
colormap(fliplr(jet))
scatter3( p, h, k, 1, t )
a1.PlotBoxAspectRatioMode = 'manual';
a1.DataAspectRatioMode = 'manual';
grid on
xlabel( 'Principal Position [m]' )
ylabel( 'Horizontal Position [m]' )
zlabel( 'Zenith Position [m]' )
view( [45,45] )
ax = subplot(3,2,2);
% this will hold an P vs T graph
hold on
scatter3( t, p, 0.*t, 1, t )
grid on
xlabel( 'Time [s]' )
ylabel( 'Principal Position [m]' )
view( [0,90] )
ay = subplot(3,2,4);
% this will hold an H vs T graph
hold on
scatter3( t, h, 0.*t, 1, t )
grid on
xlabel( 'Time [s]' )
ylabel( 'Horizontal Position [m]' )
view( [0,90] )
az = subplot(3,2,6);
% this will hold an K vs T graph
hold on
scatter3( t, k, 0.*t, 1, t )
grid on
xlabel( 'Time [s]' )
ylabel( 'Zenith Position [m]' )
view( [0,90] )
linkaxes( [ ax, ay, az ], 'x' )
end
function my_closereq( src, ~ )
% Close request function
% to display a question dialog box
selection = questdlg( 'Quit?', '', 'Yes', 'No', 'Yes' );
switch selection
case 'Yes'
delete(src)
case 'No'
return
end
end