-
Notifications
You must be signed in to change notification settings - Fork 35
/
CompareTrajectoriesToData.m
123 lines (82 loc) · 2.61 KB
/
CompareTrajectoriesToData.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
%% load data
clear
addpath('/home/abarry/realtime/scripts/logs');
%% setup loading variables
date = '2015-10-08';
name = 'field-test';
log_number = '10';
stabilization_trajectory = 0;
hostname = 'odroid-gps3';
trajectory_library = 'traj-archive/oct8-from-data-obstacle-ready.mat';
use_simulation = false;
%% load trajectory library
disp(['Loading ' trajectory_library '...']);
load(trajectory_library);
disp('done.');
%% load log data
dir = [date '-' name '/' hostname '/'];
filename = ['lcmlog_' strrep(date, '-', '_') '_' log_number '.mat'];
dir_prefix = '/home/abarry/rlg/logs/';
dir = [ dir_prefix dir ];
addpath('/home/abarry/realtime/scripts/logs');
disp(['Loading ' filename '...']);
loadDeltawing
disp('done.');
%% remove trajectories on the ground
[t_starts_unfiltered, t_ends_unfiltered] = FindActiveTimes(u.logtime, u.is_autonomous, 0.5);
t_starts = [];
t_ends = [];
for i = 1 : length(t_starts_unfiltered)
[~, idx] = min(abs(est.logtime - t_starts_unfiltered(i)));
[~, idx_end] = min(abs(est.logtime - t_ends_unfiltered(i)));
this_alt = est.pos.z(idx);
this_alt_end = est.pos.z(idx_end);
this_alt_mid = est.pos.z( round((idx_end-idx)/2) + idx );
this_alt_max = max(est.pos.z(idx:idx_end));
if (this_alt > 5 || this_alt_end > 5 || this_alt_mid > 7.5 || this_alt_max > 7.5)
t_starts = [t_starts t_starts_unfiltered(i)];
t_ends = [t_ends t_ends_unfiltered(i)];
else
disp(['t = ' num2str(t_starts_unfiltered(i)) ' to ' num2str(t_ends_unfiltered(i)) ' filtered for being on the ground.']);
end
end
%% simulate
if use_simulation
for i = 1:length(t_starts)
xtrajsim{i} = SimulateTrajectoryAgainstData(u, est, parameters, t_starts(i), t_ends(i));
end
else
xtrajsim = {};
end
%% plot
for i = 1:length(t_starts)
if use_simulation
TrajectoryToDataComparisonPlotter(u, est, tvlqr_out, lib, t_starts(i), t_ends(i), stabilization_trajectory);
else
TrajectoryToDataComparisonPlotter(u, est, tvlqr_out, lib, t_starts(i), t_ends(i), stabilization_trajectory);
end
pause
end
%% create plots for papers/talks
%tmin = 125.4;
tmin = 85;
tmax = 87.5;
for i = 1 : 5
figure(i)
for j = 1 : 3
subplot(3,1,j)
xlim([tmin tmax]);
end
end
%% save files
name_str = '2015-10-08_10';
disp(['Saving ' name_str '...']);
SaveComparison([name_str '-x'], 1, 1);
SaveComparison([name_str '-y'], 1, 2);
SaveComparison([name_str '-z'], 1, 3);
SaveComparison([name_str '-roll'], 2, 1);
SaveComparison([name_str '-pitch'], 2, 2);
SaveComparison([name_str '-yaw'], 2, 3);
SaveComparison([name_str '-u-left'], 3, 1);
SaveComparison([name_str '-u-right'], 3, 2);
disp('done.');