-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathscan_score.m
58 lines (41 loc) · 1.73 KB
/
scan_score.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
%% Function description: compute score for every pose that depends on scan the consitence with current map
%===============================================================================
% INPUT:
% @p robot pose
% @r new reading of scan
% @mp map
% @params listing in the up one level
% OUTPUT:
% @s score
% DATE: 2018/12/23 wyq
%===============================================================================
function s = scan_score(p, r, mp, params)
a = linspace(-params.max_angle,params.max_angle,params.num_beams);
s = 0;
index1 = r<params.usable_range(2);
index2 = r>params.usable_range(1);
index = index1&index2;
d = r(index)';
a = a(index);
p_end = repmat(p(1:2),1,sum(index)) + [d.*cos(a+p(3));d.*sin(a+p(3))];
map_pnt = world2map(p_end,params);
% find hit move
for i = 1:size(map_pnt,2)
test_pnt = map_pnt(:,i);
for j = 1:size(params.hit_kernel,2)
pnt = test_pnt + params.hit_kernel(:,j);
if mp.visit(pnt(2),pnt(1)) == 0
continue;
%find the closest 'busy'(occupied) cell until next is free
elseif mp.occupy(pnt(2),pnt(1)) > params.occupied_threshold
%trans to actual distance
mu = sum(params.hit_kernel(:,j).^2)*params.grid_size^2;
best_mu = mu;
%the dist min, the score max
s = s + exp(-1/params.gaussian_sigma*best_mu);
%if get the 'occupied', jump the loop
break;
end
end
end
end