-
Notifications
You must be signed in to change notification settings - Fork 3
/
init_app.m
128 lines (109 loc) · 4.06 KB
/
init_app.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
% Initialize the app upon selection of a dataset. Draw landmarks |
% Initialize parameters | Set Visualization mode
function init_app(app, root, mapfile, dataset_id)
%% initialize parameters
global t % global simulation time
global M % number of particles
t = 0;
global R % covariance matrix of the motion model
global Q % covariance matrix of the measurement model
global lambda_psi % threshold on average likelihood for outlier detection
% default parameters for chosen dataset for reset button in app
global default_R
global default_Q
global default_lambda_psi % threshold on average likelihood for outlier detection
% global localization or tracking problem
global global_localization
% Dataset 1
if dataset_id == 1
default_R = [0.1^2, 0, 0; 0, 0.1^2, 0; 0, 0, (2*pi/360)^2];
default_Q = [0.1^2, 0; 0, (2*pi/360)^2];
default_lambda_psi = 2;
global_localization = 0;
M = 1000;
% Dataset 2
elseif dataset_id == 2
default_R = [0.1^2, 0, 0; 0, 0.1^2, 0; 0, 0, (2*pi/360)^2];
default_Q = [0.1^2, 0; 0, (2*pi/360)^2];
default_lambda_psi = 2;
global_localization = 0;
M = 1000;
else
disp('Dataset does not exist!')
end
% set global parameters to default values
R = default_R;
Q = default_Q;
lambda_psi = default_lambda_psi;
% display values in spinners
app.xySpinner.Value = sqrt(R(1, 1));
app.thetaSpinner.Value = round(sqrt(R(3, 3)) / (2*pi) * 360);
app.rSpinner.Value = sqrt(Q(1, 1));
app.thetaSpinner_2.Value = round(sqrt(Q(2, 2)) / (2*pi) * 360);
% display number of particles
app.ParticlesSlider.Value = M;
app.ParticleEditField.Value = M;
% set global localization switch
if global_localization
app.GlobalTrackingSwitch.Value = 'Global';
else
app.GlobalTrackingSwitch.Value = 'Tracking';
end
% set outlier detection switch
if lambda_psi > 0
% outlier detection enabled
app.OutlierSwitch.Value = 'On';
app.OutlierSpinner.Visible = 'on';
app.OutlierSpinner.Value = lambda_psi;
else
% outlier detection disabled
app.OutlierSwitch.Value = 'Off';
app.OutlierSpinner.Value = lambda_psi;
end
%% initialize and draw map
map_data = load([root mapfile]);
global map
global landmark_ids
global N
map = map_data(:,2:3)'; % map including the coordinates of all landmarks | shape 2Xn for n landmarks
landmark_ids = map_data(:,1)'; % contains the ID of each landmark | shape 1Xn for n landmarks
N = length(landmark_ids);
% include margin around landmarks
margin = 10;
xmin = min(map(1, :)) - margin;
xmax = max(map(1, :)) + margin;
ymin = min(map(2, :)) - margin;
ymax = max(map(2, :)) + margin;
% draw map
cla(app.SimulationAxis)
plot(app.SimulationAxis, map(1, :), map(2, :), 'ko')
hold (app.SimulationAxis, 'on');
axis(app.SimulationAxis, [xmin xmax ymin ymax])
%% initialize simulation mode
global RESAMPLE_MODE % use ground-truth data instead of ML data association
global DATA_ASSOCIATION % perform batch update instead of sequential update
% set default values
DATA_ASSOCIATION = 'On';
RESAMPLE_MODE = 2;
% update switches
app.DataAssociationSwitch.Value = DATA_ASSOCIATION;
if RESAMPLE_MODE == 0
app.OffButton.Value = 1;
elseif RESAMPLE_MODE == 1
app.MultinomialButton.Value = 1;
else
app.SystematicButton.Value = 1;
end
%% visualization mode
global show_measurements % display a laser beam for each measurement
global show_ground_truth % display groud truth position
global show_odometry % display position according to odometry information
% set default values
show_measurements = true;
show_ground_truth = false;
show_odometry = false;
% update check boxes
app.CheckBox1.Value = show_measurements;
app.CheckBox2.Value = show_ground_truth;
app.CheckBox3.Value = show_odometry;
end