-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSensorModel.m
More file actions
46 lines (39 loc) · 1.15 KB
/
SensorModel.m
File metadata and controls
46 lines (39 loc) · 1.15 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
function SenseData = SensorModel(X)
% ***********************************************************
% --------------- SENSOR MODEL --------------
% DESCRIPTION:
% Scan threw six LM given as map,
% here each LM is distinct
%
% ARGUEMNT:
% X : actual state, [X, Y, Theta]'
% LM : land mark position
%
% RETURN:
% Sensordata : each row [flag, distance, relative angle]
% flag = 1 if corresponding LM detected
% --------------------------------------------
% ***********************************************************
LM_X = [-20 -20 -5 30 30 8];
LM_Y = [-25 0 25 -25 0 25];
LMc = length(LM_X);
SenseData = zeros(LMc,3);
% Sensor Noise Covariance
Q = [
0.02 0.00;
0.00 0.02;
];
for id = 1:LMc
% A radius based detection, use physical distance!
q = sqrt((LM_X(id) - X(1))^2 + (LM_Y(id) - X(2))^2);
% if the landmark is in the range of sensing area
if q < 12.0
ran = mvnrnd([q atan2(LM_Y(id) - X(2), ...
LM_X(id) - X(1)) - X(3)
], Q);
SenseData(id,1) = 1; % is sensed
SenseData(id,2) = ran(1);
SenseData(id,3) = ran(2);
end
end
end