-
Notifications
You must be signed in to change notification settings - Fork 0
/
displayData_comparason.m
218 lines (181 loc) · 7.14 KB
/
displayData_comparason.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
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
clear;
run displayData_optimal.m
%%
simulationSpeed = 1;
skipToEnd = 1;
plotOnlyUncertanty = 1;
comparasingPlot = 1;
droneRaw = csvread('drone.txt');
icebergRaw = csvread('iceberg.txt');
figure(1);
pbaspect([1 1 1])
communicationRadius = droneRaw(1,1);
droneRaw = droneRaw(2:end,:);
deliminatingLinesTimestep_drone = find(droneRaw(:,1) == -2);
deliminatingLinesTimestep_icebergs = find(icebergRaw(:,1) == -2);
lineStartDrone = 1;
lineStartIceberg = 1;
maxUncertanty = NaN(length(deliminatingLinesTimestep_drone),1);
meanUncertanty = NaN(length(deliminatingLinesTimestep_drone),1);
CM = lines();
if(skipToEnd == 0)
for t = 1:simulationSpeed:length(deliminatingLinesTimestep_drone)
if(t > 1)
pause(0.001);
clf();
figure(1);
pbaspect([1 1 1])
end
subplot(2,3,[1,2,4,5]);
axis([0 1000 0 1000]);
hold on;
%todo read the actuall ship pos
scatter(500,500,'*');
viscircles([500, 500],communicationRadius, 'LineWidth',0.03, 'Color', CM(1,:));
%% icebergsRaw
icebergs = icebergRaw(lineStartIceberg:deliminatingLinesTimestep_icebergs(t)-1,:);
lineStartIceberg = deliminatingLinesTimestep_icebergs(t)+1;
icebergPossitions = icebergs(:,2:3);
icebergSpeeds = icebergs(:,4:5);
scatter(icebergPossitions(:,1),icebergPossitions(:,2), 25, CM(1,:));
quiver(icebergPossitions(:,1),icebergPossitions(:,2),icebergSpeeds(:,1),icebergSpeeds(:,2),0.2,'color',CM(1,:));
text(icebergPossitions(:,1),icebergPossitions(:,2),num2str(round(icebergs(:,6))));
maxUncertanty(t) = max(icebergs(:,6));
meanUncertanty(t) = mean(icebergs(:,6));
%% Drones
drones = droneRaw(lineStartDrone:deliminatingLinesTimestep_drone(t)-1,:);
lineStartDrone = deliminatingLinesTimestep_drone(t)+1;
deliminatingLines = find(drones(:,1) == -1);
%color index 1 is used for icebergsRaw
colorIndex = 2;
j= 1;
for i = deliminatingLines'
drone = drones(j:i-1,:);
dronePos = drone(1,:);
plannedPath = drone(2:end,:);
scatter(dronePos(1),dronePos(2),25 ,CM(colorIndex,:),'filled');
viscircles(dronePos(1:2),communicationRadius, 'LineWidth',0.03,'Color', CM(colorIndex,:), 'EnhanceVisibility', false);
plot(plannedPath(:,1),plannedPath(:,2), 'color',CM(colorIndex,:));
scatter(plannedPath(:,1),plannedPath(:,2), 25 ,CM(colorIndex,:));
j=i+1;
colorIndex = colorIndex+1;
end
subplot(2,3,3);
plot(maxUncertanty);
title('Highest weighted uncertainty');
subplot(2,3,6);
plot(meanUncertanty);
title('Mean weighted uncertainty');
if(t==1)
pause(1);
end
end
else
for t = 1:simulationSpeed:length(deliminatingLinesTimestep_drone)
%subplot(2,3,[1,2,4,5]);
%axis([0 1000 0 1000]);
%hold on;
%todo read the actuall ship pos
%scatter(500,500,'*');
%viscircles([500, 500],communicationRadius, 'LineWidth',0.03, 'Color', CM(1,:));
%% icebergsRaw
icebergs = icebergRaw(lineStartIceberg:deliminatingLinesTimestep_icebergs(t)-1,:);
lineStartIceberg = deliminatingLinesTimestep_icebergs(t)+1;
icebergPossitions = icebergs(:,2:3);
icebergSpeeds = icebergs(:,4:5);
%scatter(icebergPossitions(:,1),icebergPossitions(:,2), 25, CM(1,:));
%quiver(icebergPossitions(:,1),icebergPossitions(:,2),icebergSpeeds(:,1),icebergSpeeds(:,2),0.2,'color',CM(1,:));
%text(icebergPossitions(:,1),icebergPossitions(:,2),num2str(round(icebergs(:,6))));
maxUncertanty(t) = max(icebergs(:,6));
meanUncertanty(t) = mean(icebergs(:,6));
%% Drones
drones = droneRaw(lineStartDrone:deliminatingLinesTimestep_drone(t)-1,:);
lineStartDrone = deliminatingLinesTimestep_drone(t)+1;
deliminatingLines = find(drones(:,1) == -1);
%color index 1 is used for icebergsRaw
%colorIndex = 2;
%j= 1;
%for i = deliminatingLines'
%drone = drones(j:i-1,:);
%dronePos = drone(1,:);
%plannedPath = drone(2:end,:);
%scatter(dronePos(1),dronePos(2),25 ,CM(colorIndex,:),'filled');
%viscircles(dronePos(1:2),communicationRadius, 'LineWidth',0.03,'Color', CM(colorIndex,:), 'EnhanceVisibility', false);
%plot(plannedPath(:,1),plannedPath(:,2), 'color',CM(colorIndex,:));
%scatter(plannedPath(:,1),plannedPath(:,2), 25 ,CM(colorIndex,:));
%j=i+1;
%colorIndex = colorIndex+1;
%end
%subplot(2,3,3);
%plot(maxUncertanty);
%title('Highest uncertanty');
%subplot(2,3,6);
%plot(meanUncertanty);
%title('Mean uncertanty');
%if(t==1)
% pause(1);
%end
end
if(plotOnlyUncertanty == 0)
subplot(2,3,[1,2,4,5]);
axis([0 1000 0 1000]);
hold on;
scatter(500,500,'*');
viscircles([500, 500],communicationRadius, 'LineWidth',0.03, 'Color', CM(1,:));
scatter(icebergPossitions(:,1),icebergPossitions(:,2), 25, CM(1,:));
quiver(icebergPossitions(:,1),icebergPossitions(:,2),icebergSpeeds(:,1),icebergSpeeds(:,2),0.2,'color',CM(1,:));
text(icebergPossitions(:,1),icebergPossitions(:,2),num2str(round(icebergs(:,6))));
%color index 1 is used for icebergsRaw
colorIndex = 2;
j= 1;
for i = deliminatingLines'
drone = drones(j:i-1,:);
dronePos = drone(1,:);
plannedPath = drone(2:end,:);
scatter(dronePos(1),dronePos(2),25 ,CM(colorIndex,:),'filled');
viscircles(dronePos(1:2),communicationRadius, 'LineWidth',0.03,'Color', CM(colorIndex,:), 'EnhanceVisibility', false);
plot(plannedPath(:,1),plannedPath(:,2), 'color',CM(colorIndex,:));
scatter(plannedPath(:,1),plannedPath(:,2), 25 ,CM(colorIndex,:));
j=i+1;
colorIndex = colorIndex+1;
end
end
if(comparasingPlot == 1)
load('uncertantyOptimal.mat');
end
if(plotOnlyUncertanty == 0)
subplot(2,3,3);
else
subplot(1,2,1);
end
plot(maxUncertanty);
title('Highest weighted uncertainty');
if(comparasingPlot == 1)
hold on;
plot(maxUncertanty_optimal);
legend('Decentralized','Benchmark', 'Location', 'southeast')
end
if(plotOnlyUncertanty == 0)
subplot(2,3,6);
else
subplot(1,2,2);
end
plot(meanUncertanty);
title('Mean weighted uncertainty');
if(comparasingPlot == 1)
hold on;
plot(meanUncertanty_optimal);
legend('Decentralized','Benchmark', 'Location', 'southeast')
end
end
%%
averageMax = mean(maxUncertanty)
averageMaxOptimal = mean(maxUncertanty_optimal)
worseMax = averageMax/averageMaxOptimal
averageMean = mean(meanUncertanty)
averageMeanOptimal = mean(meanUncertanty_optimal)
worseMean = averageMean/averageMeanOptimal
%% gjør den til riktig størrelse
set(gcf, 'Position', [500,500,800,350]);
savefig('comparasonPlot.fig');
saveas(gcf,'comparasonPlot','epsc');