-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.m
85 lines (69 loc) · 2.01 KB
/
example.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
%% Example: Single Rotation Averaging Problem
% Application of GNC-ADAPT to nonlinear least-squares problem compared to
% other state-of-the-art methods
%
% Editor: Kyungmin John Jung
% Date: 2024-03-12
% Lab: DECAR Group
% Institution: McGilll University
clc; clear; close all; restoredefaultpath;
addpath(genpath('./Algorithms'));
addpath(genpath('./mtimesx'));
addpath(genpath('./Problem'));
addpath(genpath('./utils'));
% seed random
rng(100);
% Problem generation
problem_params.N = 1000; % number of measurements available
problem_params.outlierRatio = 0.5; % outlier ratio
problem_params.noiseSigma = 5; % in degrees
problem = SingleRotationAveragingProblem(problem_params);
%% Run experiment
% To disable the execution of any algorithm feel free to comment out the
% relative section. `displayResults` will show only available results.
% initial condition
initialNoise = 90; % degrees
rotAxis = normalize(randn(3, 1), 'norm');
rotAngle = deg2rad(initialNoise) * randn();
R_init = problem.R_gt * axang2rotm([rotAxis', rotAngle]);
% solve
results.cauchy = problem.solve( ...
'lossFunction', @cauchy, ...
'R_init', R_init ...
);
results.gm = problem.solve( ...
'lossFunction', @gm, ...
'R_init', R_init ...
);
results.adapt = problem.solve( ...
'lossFunction', @adapt, ...
'R_init', R_init ...
);
results.amb = problem.solve( ...
'lossFunction', @amb, ...
'R_init', R_init ...
);
results.gnc_cauchy = problem.solve( ...
'lossFunction', @gnc_adapt, ...
'alphaStar', 0, ... % Cauchy
'R_init', R_init ...
);
results.gnc_gm = problem.solve( ...
'lossFunction', @gnc_adapt, ...
'alphaStar', -2, ... % GM
'R_init', R_init ...
);
results.gnc_adapt = problem.solve( ...
'lossFunction', @gnc_adapt, ...
'R_init', R_init ...
);
results.gnc_amb = problem.solve( ...
'lossFunction', @gnc_amb, ...
'R_init', R_init ...
);
results.gnc_tls = problem.solve( ...
'lossFunction', @gnc_tls, ...
'R_init', R_init ...
);
%% Display Results
displayResults(results, problem);