-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMain_Numerical_Stability.m
More file actions
182 lines (169 loc) · 4.57 KB
/
Main_Numerical_Stability.m
File metadata and controls
182 lines (169 loc) · 4.57 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
close all;
clc;
clear;
addpath others;
addpath SRPnL;
noise=0;
N=100000;
nLine=10;
rateOutlier=0;
Uc=1;
A=zeros(N,1);
name={'Numerical Stability','Numerical Stability by Refining Step'};
f= { @SRPnL1, @SRPnL};
color= {'b','r'};
method_list= struct('name', name, 'f', f, 'r', A, 't', A,...
'color', color);
counter=0;
for i=1:N
% generating experiment data;
D = generateData( nLine, noise, rateOutlier,Uc);
for j=1:length(method_list)
try
[R_cw, T_cw]=method_list(j).f(D.p1, D.p2, D.P1_w, D.P2_w);
catch
%fprintf([' The solver - ',method_list(k).name,' - encounters internal errors! \n']);
break;
end
[rotation_error,position_error]=cal_error(R_cw,T_cw,D.R_cw,D.T_cw);
method_list(j).r(i)= rotation_error;
method_list(j).t(i)= position_error;
end
counter = counter + 1;
if counter == 500
counter = 0;
display(['Iteration ' num2str(i) ' of ' num2str(N)]);
end
end
disp('------------Mean errors------------')
%the mean error of each algorithm;
for k=1:length(method_list)
disp(method_list(k).name);
disp('Rotation Error (rad)');
disp(mean(method_list(k).r));
disp(' Translation Error (m) ');
disp(mean(method_list(k).t));
end
for k= 1:length(method_list)
method_list(k).r(method_list(k).r==0) = [];
method_list(k).t(method_list(k).t==0) = [];
end
figure(1);
set(gcf, 'position', [100 200 500 500]);
box on;
hold on;
for k=1:length(method_list)
[h1,b1] = hist(log10(method_list(k).r),40);
bar(b1,h1,method_list(k).color);
% plot(b1,h1,'color',method_list(k).color,'LineWidth',2.5);
end
set(gca,'FontSize',14);
xlabel('Log_{10} Absolute Rotation Error');
ylabel('Number of Counts');
legend(name);
figure(2);
set(gcf, 'position', [100 200 500 500]);
box on;
hold on;
for k=1:length(method_list)
[h1,b1] = hist(log10(method_list(k).r),40);
% bar(b1,h1,method_list(k).color);
plot(b1,h1,'color',method_list(k).color,'LineWidth',2.5);
end
set(gca,'FontSize',14);
xlabel('Log_{10} Absolute Rotation Error');
ylabel('Number of Counts');
legend(name);
figure(3);
set(gcf, 'position', [700 200 500 500]);
box on;
hold on;
for k=1:length(method_list)
[h2,b2] = hist(log10(method_list(k).t),40);
bar(b2,h2,method_list(k).color);
% plot(b2,h2,'color',method_list(k).color,'LineWidth',2.5);
end
set(gca,'FontSize',14);
xlabel('Log_{10} Absolute Translation Error');
ylabel('Number of Counts');
legend(name);
figure(4);
set(gcf, 'position', [700 200 500 500]);
box on;
hold on;
for k=1:length(method_list)
[h2,b2] = hist(log10(method_list(k).t),40);
% bar(b2,h2,method_list(k).color);
plot(b2,h2,'color',method_list(k).color,'LineWidth',2.5);
end
set(gca,'FontSize',14);
xlabel('Log_{10} Absolute Translation Error');
ylabel('Number of Counts');
legend(name);
figure(5);
set(gcf, 'position', [100 200 500 500]);
box on;
hold on;
for k=1:length(method_list)
[h1,b1] = hist(log10(method_list(k).r),40);
bar(b1,h1,method_list(k).color);
% axis([-10,0,0,150]);
% plot(b1,h1,'color',method_list(k).color,'LineWidth',2.5);
end
set(gca,'FontSize',14);
xlabel('Log_{10} Absolute Rotation Error');
ylabel('Number of Counts');
legend(name);
figure(6)
subplot(1,2,1);
box on;
hold on;
for k=1:length(method_list)
[h1,b1] = hist(log10(method_list(k).r),40);
bar(b1,h1,method_list(k).color);
% plot(b1,h1,'color',method_list(k).color,'LineWidth',2.5);
end
set(gca,'FontSize',14);
xlabel('Log_{10} Absolute Rotation Error');
ylabel('Number of Counts');
legend(name);
subplot(1,2,2);
box on;
hold on;
for k=1:length(method_list)
[h1,b1] = hist(log10(method_list(k).r),40);
bar(b1,h1,method_list(k).color);
% axis([-10,0,0,150]);
% plot(b1,h1,'color',method_list(k).color,'LineWidth',2.5);
end
set(gca,'FontSize',14);
xlabel('Log_{10} Absolute Rotation Error');
ylabel('Number of Counts');
legend(name);
figure(7);
subplot(1,2,1);
box on;
hold on;
for k=1:length(method_list)
[h2,b2] = hist(log10(method_list(k).t),20);
bar(b2,h2,method_list(k).color);
% axis([-18,0,0,3500]);
% plot(b2,h2,'color',method_list(k).color,'LineWidth',2.5);
end
set(gca,'FontSize',14);
xlabel('Log_{10} Absolute Rotation Error');
ylabel('Number of Counts');
legend(name);
subplot(1,2,2);
box on;
hold on;
for k=1:length(method_list)
[h2,b2] = hist(log10(method_list(k).t),20);
bar(b2,h2,method_list(k).color);
% axis([-10,0,0,150]);
% plot(b2,h2,'color',method_list(k).color,'LineWidth',2.5);
end
set(gca,'FontSize',14);
xlabel('Log_{10} Absolute Translation Error');
ylabel('Number of Counts');
legend(name);