forked from priseborough/InertialNav
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlotCcodeOutput.m
More file actions
383 lines (362 loc) · 10.9 KB
/
PlotCcodeOutput.m
File metadata and controls
383 lines (362 loc) · 10.9 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
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
%% Load data
close all;
clear all;
StateDataOut = load('StateDataOut.txt');
EulDataOut = load('EulDataOut.txt');
CovDataOut = load('CovDataOut.txt');
RefVelPosDataOut = load('RefVelPosDataOut.txt');
VelPosFuse = load('VelPosFuse.txt');
MagFuse = load('MagFuse.txt');
TasFuse = load('TasFuse.txt');
gpsraw_available = 0;
if exist('GPSrawOut.txt', 'file') == 2
GPSraw = load('GPSrawOut.txt');
gpsraw_available = 1;
else
% Fake zero data in case people do not check
% if the data is available - compatibility
GPSraw = zeros(size(RefVelPosDataOut, 1), 7);
end
xmin = max([StateDataOut(1,1),EulDataOut(1,1),CovDataOut(1,1),RefVelPosDataOut(1,1),VelPosFuse(1,1),MagFuse(1,1),TasFuse(1,1)]);
xmax = min([max(StateDataOut(:,1)),max(EulDataOut(:,1)),max(CovDataOut(:,1)),max(RefVelPosDataOut(:,1)),max(VelPosFuse(:,1)),max(MagFuse(:,1)),max(TasFuse(:,1))]);
rad2deg = 180/pi;
dirName = '../plots/';
% remove repeated GPS data points
lastRow = RefVelPosDataOut(1,:);
for i = 2:length(RefVelPosDataOut)
sameRow = ((sum(RefVelPosDataOut(i,:) == lastRow)) == 6);
if sameRow
RefVelPosDataOut(i,:) = NaN(1,7);
else
lastRow = RefVelPosDataOut(i,:);
end
end
RefVelPosDataOut = RefVelPosDataOut(any(~isnan(RefVelPosDataOut),2),:);
%% Euler Angles
fileName = 'EulerAngleEstimates';
for i = 1:length(EulDataOut)
if EulDataOut(i,7) > pi
EulDataOut(i,7) = EulDataOut(i,7) - 2*pi;
end
end
figure;
subplot(3,1,1);
plot(EulDataOut(:,1),EulDataOut(:,2)*rad2deg, 'b');
hold on;
plot(EulDataOut(:,1),EulDataOut(:,3)*rad2deg, 'r');
legend('Proposed', 'Onboard');
xlim([xmin,xmax]);
grid on;
ylim([-100 100]);
xlabel('time (sec)');ylabel('roll (deg)');
title('Euler Angle Estimates');
subplot(3,1,2);
plot(EulDataOut(:,1),EulDataOut(:,4)*rad2deg, 'b');
hold on;
plot(EulDataOut(:,1),EulDataOut(:,5)*rad2deg, 'r');
legend('Proposed', 'Onboard');
xlim([xmin,xmax]);
grid on;
ylim([-100 100]);
xlabel('time (sec)');ylabel('pitch (deg)');
subplot(3,1,3);
plot(EulDataOut(:,1),EulDataOut(:,6)*rad2deg, 'b');
hold on;
plot(EulDataOut(:,1),EulDataOut(:,7)*rad2deg, 'r');
legend('Proposed', 'Onboard');
xlim([xmin,xmax]);
grid on;
ylim([-200 200]);
xlabel('time (sec)');ylabel('yaw (deg)');
saveas(gcf,strcat(dirName,fileName,'.jpg'));
print(gcf, '-djpeg', strcat(dirName,fileName,'.jpg'), '-r200');
%% NED velocity
fileName = 'VelocityEstimates';
figure;
subplot(3,1,1);
plot(RefVelPosDataOut(:,1),RefVelPosDataOut(:,2),'r');
xlim([xmin,xmax]);
hold on;
plot(StateDataOut(:,1),StateDataOut(:,6),'b');
if gpsraw_available
hold on;
plot(GPSraw(:,1),GPSraw(:,5),'g');
end
hold off;
grid on;
xlabel('time (sec)');ylabel('North Velocity (m/s)');
title('NED Velocity Estimates');
if gpsraw_available
legend('Onboard', 'Proposed', 'GPS raw');
else
legend('Onboard', 'Proposed');
end
subplot(3,1,2);
plot(RefVelPosDataOut(:,1),RefVelPosDataOut(:,3),'r');
xlim([xmin,xmax]);
hold on;
plot(StateDataOut(:,1),StateDataOut(:,7),'b');
if gpsraw_available
hold on;
plot(GPSraw(:,1),GPSraw(:,6),'g');
end
hold off;
grid on;
xlabel('time (sec)');ylabel('East Velocity (m/s)');
if gpsraw_available
legend('Onboard', 'Proposed', 'GPS raw');
else
legend('Onboard', 'Proposed');
end
subplot(3,1,3);
plot(RefVelPosDataOut(:,1),RefVelPosDataOut(:,4),'r');
xlim([xmin,xmax]);
hold on;
plot(StateDataOut(:,1),StateDataOut(:,8),'b');
if gpsraw_available
hold on;
plot(GPSraw(:,1),GPSraw(:,7),'g');
end
hold off;
grid on;
xlabel('time (sec)');ylabel('Down Velocity (m/s)');
if gpsraw_available
legend('Onboard', 'Proposed', 'GPS raw');
else
legend('Onboard', 'Proposed');
end
set(gcf,'PaperUnits','inches','PaperPosition',[0 0 8 6])
saveas(gcf,strcat(dirName,fileName,'.fig'));
print(gcf, '-djpeg', strcat(dirName,fileName,'.jpg'), '-r200');
%% NE Position and Height
fileName = 'PositionEstimates';
figure;
subplot(3,1,1);
plot(RefVelPosDataOut(:,1),RefVelPosDataOut(:,5),'r');
xlim([xmin,xmax]);
hold on;
plot(StateDataOut(:,1),StateDataOut(:,9),'b');
hold off;
grid on;
xlabel('time (sec)');ylabel('North Position (m)');
title('NED Position Estimates');
subplot(3,1,2);
plot(RefVelPosDataOut(:,1),RefVelPosDataOut(:,6),'r');
xlim([xmin,xmax]);
hold on;
plot(StateDataOut(:,1),StateDataOut(:,10),'b');
hold off;
grid on;
xlabel('time (sec)');ylabel('East Position (m)');
subplot(3,1,3);
plot(RefVelPosDataOut(:,1),RefVelPosDataOut(:,7),'r');
xlim([xmin,xmax]);
hold on;
plot(StateDataOut(:,1),-StateDataOut(:,11),'b');
hold off;
grid on;
xlabel('time (sec)');ylabel('Height (m)');
saveas(gcf,strcat(dirName,fileName,'.fig'));
print(gcf, '-djpeg', strcat(dirName,fileName,'.jpg'), '-r200');
%% Gyro Bias
fileName = 'GyroBiasEstimates';
figure;
dt = median(diff(StateDataOut(:,1)));
subplot(3,1,1);
plot(StateDataOut(:,1),StateDataOut(:,12)*rad2deg*60/dt);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('X bias (deg/min)');
title('Gyro Bias Error Estimates');
subplot(3,1,2);
plot(StateDataOut(:,1),StateDataOut(:,13)*rad2deg*60/dt);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('Y bias (deg/min)');
subplot(3,1,3);
plot(StateDataOut(:,1),StateDataOut(:,14)*rad2deg*60/dt);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('Z bias (deg/min)');
saveas(gcf,strcat(dirName,fileName,'.fig'));
print(gcf, '-djpeg', strcat(dirName,fileName,'.jpg'), '-r200');
%% Accelerometer Bias
fileName = 'AccelBiasEstimate';
figure;
plot(StateDataOut(:,1),StateDataOut(:,15)/dt);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('Z bias (m/s^2)');
title('Accelerometer Z Bias Error Estimate');
saveas(gcf,strcat(dirName,fileName,'.fig'));
print(gcf, '-djpeg', strcat(dirName,fileName,'.jpg'), '-r200');
%% Wind Velocity
fileName = 'WindVelEstimates';
figure;
subplot(2,1,1);
plot(StateDataOut(:,1),StateDataOut(:,16));
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('North Velocity (m/s)');
title('Wind Velocity Estimates');
subplot(2,1,2);
xlim([xmin,xmax]);
plot(StateDataOut(:,1),StateDataOut(:,17));
grid on;
xlabel('time (sec)');ylabel('East Velocity (m/s)');
saveas(gcf,strcat(dirName,fileName,'.fig'));
print(gcf, '-djpeg', strcat(dirName,fileName,'.jpg'), '-r200');
%% NED Magnetic Field
fileName = 'EarthMagEstimates';
figure;
subplot(3,1,1);
plot(StateDataOut(:,1),StateDataOut(:,18)*1024);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('North Flux (mgauss)');
title('Earth Magnetic Field Estimates');
subplot(3,1,2);
plot(StateDataOut(:,1),StateDataOut(:,19)*1024);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('East Flux (mgauss)');
subplot(3,1,3);
plot(StateDataOut(:,1),StateDataOut(:,20)*1024);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('Down Flux (mgauss)');
saveas(gcf,strcat(dirName,fileName,'.fig'));
print(gcf, '-djpeg', strcat(dirName,fileName,'.jpg'), '-r200');
%% XYZ Magnetic Field
fileName = 'BodyMagEstimates';
figure;
subplot(3,1,1);
plot(StateDataOut(:,1),StateDataOut(:,21)*1024);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('X Flux (mgauss)');
title('Body Fixed Magnetic Field Bias Estimates');
subplot(3,1,2);
plot(StateDataOut(:,1),StateDataOut(:,22)*1024);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('Y Flux (mgauss)');
subplot(3,1,3);
plot(StateDataOut(:,1),StateDataOut(:,23)*1024);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('Z Flux (mgauss)');
saveas(gcf,strcat(dirName,fileName,'.fig'));
print(gcf, '-djpeg', strcat(dirName,fileName,'.jpg'), '-r200');
%% Terrain Offset
fileName = 'TerrainPosOffset';
figure;
plot(StateDataOut(:,1),StateDataOut(:,24));
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('terrain offset (m)');
title('Terrain Vertical Position Offset');
saveas(gcf,strcat(dirName,fileName,'.fig'));
print(gcf, '-djpeg', strcat(dirName,fileName,'.jpg'), '-r200');
%% Velocity Innovations
fileName = 'VelInnovations';
figure;
subplot(3,1,1);
plot(VelPosFuse(:,1),[VelPosFuse(:,2),-sqrt(VelPosFuse(:,3)),sqrt(VelPosFuse(:,3))]);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('North (m/s)');
title('Velocity Measurement Innovations');
subplot(3,1,2);
plot(VelPosFuse(:,1),[VelPosFuse(:,4),-sqrt(VelPosFuse(:,5)),sqrt(VelPosFuse(:,5))]);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('East (m/s)');
subplot(3,1,3);
plot(VelPosFuse(:,1),[VelPosFuse(:,6),-sqrt(VelPosFuse(:,7)),sqrt(VelPosFuse(:,7))]);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('Down (m/s)');
saveas(gcf,strcat(dirName,fileName,'.fig'));
print(gcf, '-djpeg', strcat(dirName,fileName,'.jpg'), '-r200');
%% Position Innovations
fileName = 'PosInnovations';
figure;
subplot(3,1,1);
plot(VelPosFuse(:,1),[VelPosFuse(:,8),-sqrt(VelPosFuse(:,9)),sqrt(VelPosFuse(:,9))]);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('North (m)');
title('Position Measurement Innovations');
subplot(3,1,2);
plot(VelPosFuse(:,1),[VelPosFuse(:,10),-sqrt(VelPosFuse(:,11)),sqrt(VelPosFuse(:,11))]);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('East (m)');
subplot(3,1,3);
plot(VelPosFuse(:,1),[VelPosFuse(:,12),-sqrt(VelPosFuse(:,13)),sqrt(VelPosFuse(:,13))]);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('Down (m)');
saveas(gcf,strcat(dirName,fileName,'.fig'));
print(gcf, '-djpeg', strcat(dirName,fileName,'.jpg'), '-r200');
%% Magnetometer Innovations
fileName = 'MagInnovations';
figure;
subplot(3,1,1);
plot(MagFuse(:,1),[MagFuse(:,2),-sqrt(MagFuse(:,3)),sqrt(MagFuse(:,3))]*1024);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('X Flux (mgauss)');
title('Magnetometer Measurement Innovations');
subplot(3,1,2);
plot(MagFuse(:,1),[MagFuse(:,4),-sqrt(MagFuse(:,5)),sqrt(MagFuse(:,5))]*1024);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('Y Flux (mgauss)');
subplot(3,1,3);
plot(MagFuse(:,1),[MagFuse(:,6),-sqrt(MagFuse(:,7)),sqrt(MagFuse(:,7))]*1024);
xlim([xmin,xmax]);
grid on;
xlabel('time (sec)');ylabel('Z Flux (mgauss)');
saveas(gcf,strcat(dirName,fileName,'.fig'));
print(gcf, '-djpeg', strcat(dirName,fileName,'.jpg'), '-r200');
%% Airspeed Innovations
fileName = 'AirSpeedInnovations';
figure;
plot(TasFuse(:,1),[TasFuse(:,2),-sqrt(TasFuse(:,3)),sqrt(TasFuse(:,3))]);
grid on;
xlabel('time (sec)');ylabel('airspeed (m/s)');
title('Airspeed Measurement Innovations');
saveas(gcf,strcat(dirName,fileName,'.fig'));
print(gcf, '-djpeg', strcat(dirName,fileName,'.jpg'), '-r200');
%% AHRS Diagnostic
% xmin = 310;
% xmax = 330;
% figure;
% subplot(4,1,1);
% plot(EulDataOut(:,1),EulDataOut(:,4:5)*rad2deg);
% xlim([xmin,xmax]);
% grid on;
% xlabel('time (sec)');ylabel('pitch (deg)');
% title('AHRS Diagnostic');
% subplot(4,1,2);
% plot(RefVelPosDataOut(:,1),RefVelPosDataOut(:,7),'r');
% xlim([xmin,xmax]);
% hold on;
% plot(StateDataOut(:,1),-StateDataOut(:,11),'b');
% hold off;
% grid on;
% xlabel('time (sec)');ylabel('Height (m)');
% subplot(4,1,3);
% plot(EulDataOut(:,1),EulDataOut(:,8));
% xlim([xmin,xmax]);
% grid on;
% ylim([0 1.0]);
% xlabel('time (sec)');ylabel('AHRS Error RP');
% subplot(4,1,4);
% plot(EulDataOut(:,1),EulDataOut(:,9));
% xlim([xmin,xmax]);
% grid on;
% ylim([0 1.0]);
% xlabel('time (sec)');ylabel('AHRS Error Yaw');