-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathanalysis.m
276 lines (216 loc) · 6.33 KB
/
analysis.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
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
close all
clear all;
% load('sim_result_iekf_map3.mat')
load('sim_result.mat')
IEKF_pre_trajectory = sim_result.EKF_pre_trajectory;
load('sim_result_color_noise_map3.mat')
EKF_pre_trajectory_color = sim_result.EKF_pre_trajectory;
load('sim_result_asy_map3.mat')
EKF_pre_trajectory_asy = sim_result.EKF_pre_trajectory;
load('sim_result_less_landmark_map3.mat')
EKF_pre_trajectory_ls = sim_result.EKF_pre_trajectory;
% load('sim_result_ekf_map3.mat')
% load('sim_result_less_landmark_map3.mat')
load('sim_result_color_noise_map3.mat')
ture_trajectory = sim_result.ture_trajectory;
model_pre_trajectory = sim_result.model_pre_trajectory;
EKF_pre_trajectory = sim_result.EKF_pre_trajectory;
landmarks = sim_result.landmarks;
wp = sim_result.wp;
length = size(ture_trajectory,2);
figure
axis equal
hold on;
% 画出landmarks
scatter( landmarks(1, :), landmarks(2, :), 'b*' )
% 画出历史轨迹
truep = plot( ture_trajectory(1, :), ture_trajectory(2, :), 'k--','linewidth',3);
% 画出历史EKF预测轨迹
ekfp = plot( EKF_pre_trajectory(1, :), EKF_pre_trajectory(2, :), 'r','linewidth',3 );
% 画出历史model预测轨迹
modelp = plot( model_pre_trajectory(1, :), model_pre_trajectory(2, :), 'b-.','linewidth',3 );
% 画出车的位姿
xtrue = ture_trajectory(:,length-1);
draw_car(xtrue,5,'k');
% EKF预测位姿
x = EKF_pre_trajectory(:,length-1);
draw_car(x,5,'r');
% 模型预测位姿
x_model_pre = model_pre_trajectory(:,length-1);
draw_car(x_model_pre,5,'g');
%图例
legend([truep ekfp,modelp],'true','ekf','model');
hold off;
e_ekf = EKF_pre_trajectory - ture_trajectory;
e_ekf(3,:) = pi_to_pi(e_ekf(3,:));
e_model = model_pre_trajectory - ture_trajectory;
e_model(3,:) = pi_to_pi(e_model(3,:));
e_ekf = abs(e_ekf);
e_model = abs(e_model);
fig2 = figure;
hold on
ticks = 1:1:length;
subplot(3,1,1)
hold on
plot(ticks,e_ekf(1,:),'linewidth',2);
plot(ticks,e_model(1,:),'linewidth',2);
xlabel("ticks")
ylabel("|x-error|")
subplot(3,1,2)
hold on
plot(ticks,e_ekf(2,:),'linewidth',2);
plot(ticks,e_model(2,:),'linewidth',2);
xlabel("ticks")
ylabel("|y-error|")
subplot(3,1,3)
hold on
plot(ticks,pi_to_pi(e_ekf(3,:)),'linewidth',2);
plot(ticks,pi_to_pi(e_model(3,:)),'linewidth',2);
xlabel("ticks")
ylabel("|\phi-error|")
legend('ekf-error','model-error');
ekf_eN2 = zeros(1,length);
model_eN2 = zeros(1,length);
for i=1:1:length
ekf_eN2(i) = norm(e_ekf(:,i),2);
model_eN2(i) = norm(e_model(:,i),2);
end
hold off
fig3 = figure;
hold on
plot(ticks,ekf_eN2,'linewidth',2);
plot(ticks,model_eN2,'linewidth',2);
xlabel("ticks")
ylabel("error")
legend('ekf-error','model-error');
e_ekf_ls = EKF_pre_trajectory_ls - ture_trajectory;
e_ekf_ls(3,:) = pi_to_pi(e_ekf_ls(3,:));
e_ekf_ls = abs(e_ekf_ls);
fig4 = figure;
hold on
ticks = 1:1:length;
subplot(3,1,1)
hold on
plot(ticks,e_ekf(1,:),'linewidth',2);
plot(ticks,e_ekf_ls(1,:),'linewidth',2);
xlabel("ticks")
ylabel("|x-error|")
subplot(3,1,2)
hold on
plot(ticks,e_ekf(2,:),'linewidth',2);
plot(ticks,e_ekf_ls(2,:),'linewidth',2);
xlabel("ticks")
ylabel("|y-error|")
subplot(3,1,3)
hold on
plot(ticks,pi_to_pi(e_ekf(3,:)),'linewidth',2);
plot(ticks,pi_to_pi(e_ekf_ls(3,:)),'linewidth',2);
xlabel("ticks")
ylabel("|\phi-error|")
legend('ekf','ekf-less-observation');
ekf_ls_eN2 = zeros(1,length);
for i=1:1:length
ekf_ls_eN2(i) = norm(e_ekf_ls(:,i),2);
end
fig5 = figure;
hold on
plot(ticks,ekf_eN2,'linewidth',2);
plot(ticks,ekf_ls_eN2,'linewidth',2);
xlabel("ticks")
ylabel("error")
legend('ekf-error','ekf-less-observation');
fig6 = figure;
axis equal
hold on;
% 画出landmarks
scatter( landmarks(1, :), landmarks(2, :), 'b*' );
% 画出历史轨迹
truep = plot( ture_trajectory(1, :), ture_trajectory(2, :), 'k--','linewidth',3);
% 画出历史EKF预测轨迹
ekfp = plot( EKF_pre_trajectory(1, :), EKF_pre_trajectory(2, :), 'r','linewidth',3 );
ekfpls = plot( EKF_pre_trajectory_ls(1, :), EKF_pre_trajectory_ls(2, :), 'b-.','linewidth',3);
%图例
legend([truep,ekfp ekfpls],'true','ekf','ekf-less-observation');
fig7 = figure;
axis equal
hold on;
% 画出landmarks
scatter( landmarks(1, :), landmarks(2, :), 'b*' );
% 画出历史轨迹
truep = plot( ture_trajectory(1, :), ture_trajectory(2, :), 'k--','linewidth',3);
% 画出历史EKF预测轨迹
ekfp = plot( EKF_pre_trajectory(1, :), EKF_pre_trajectory(2, :), 'r','linewidth',3 );
ekfasyp = plot( EKF_pre_trajectory_asy(1, :), EKF_pre_trajectory_asy(2, :), 'b-.','linewidth',3);
%图例
legend([truep ekfp,ekfasyp],'true','ekf','ekf-asynchronous');
fig8 = figure;
axis equal
hold on;
% 画出landmarks
scatter( landmarks(1, :), landmarks(2, :), 'b*' );
% 画出历史轨迹
truep = plot( ture_trajectory(1, :), ture_trajectory(2, :), 'k--','linewidth',3);
% 画出历史EKF预测轨迹
ekfp = plot( EKF_pre_trajectory(1, :), EKF_pre_trajectory(2, :), 'r','linewidth',3 );
ekfcolorp = plot( EKF_pre_trajectory_color(1, :), EKF_pre_trajectory_color(2, :), 'b-.','linewidth',3);
%图例
legend([truep ekfp,ekfcolorp],'true','ekf','ekf-color');
fig9 = figure;
axis equal
hold on;
% 画出landmarks
scatter( landmarks(1, :), landmarks(2, :), 'b*' );
% 画出历史轨迹
truep = plot( ture_trajectory(1, :), ture_trajectory(2, :), 'k--','linewidth',3);
% 画出历史EKF预测轨迹
ekfp = plot( EKF_pre_trajectory(1, :), EKF_pre_trajectory(2, :), 'r','linewidth',3 );
iekfcolorp = plot( IEKF_pre_trajectory(1, :), IEKF_pre_trajectory(2, :), 'b-.','linewidth',3);
%图例
legend([truep ekfp,iekfcolorp],'true','ekf','iekf');
e_iekf = IEKF_pre_trajectory - ture_trajectory;
e_iekf(3,:) = pi_to_pi(e_iekf(3,:));
e_iekf = abs(e_iekf);
fig10 = figure;
hold on
ticks = 1:1:length;
subplot(3,1,1)
hold on
plot(ticks,e_ekf(1,:),'linewidth',2);
plot(ticks,e_iekf(1,:),'linewidth',2);
xlabel("ticks")
ylabel("|x-error|")
subplot(3,1,2)
hold on
plot(ticks,e_ekf(2,:),'linewidth',2);
plot(ticks,e_iekf(2,:),'linewidth',2);
xlabel("ticks")
ylabel("|y-error|")
subplot(3,1,3)
hold on
plot(ticks,pi_to_pi(e_ekf(3,:)),'linewidth',2);
plot(ticks,pi_to_pi(e_iekf(3,:)),'linewidth',2);
xlabel("ticks")
ylabel("|\phi-error|")
legend('ekf-error','iekf-error');
iekf_eN2 = zeros(1,length);
for i=1:1:length
iekf_eN2(i) = norm(e_iekf(:,i),2);
end
hold off
fig11 = figure;
hold on
plot(ticks,ekf_eN2,'linewidth',2);
plot(ticks,iekf_eN2,'linewidth',2);
xlabel("ticks")
ylabel("error")
legend('ekf-error','iekf-error');
% mean(model_eN2(:))
% mean(ekf_eN2(:))
% mean(ekf_ls_eN2(:))
% mean(e_ekf_ls(3,:))
% mean(e_ekf_ls(2,:))
% mean(e_ekf_ls(1,:))
%
% mean(e_ekf(3,:))
% mean(e_ekf(2,:))
% mean(e_ekf(1,:))