-
Notifications
You must be signed in to change notification settings - Fork 5
/
get_observations.m
49 lines (41 loc) · 1.35 KB
/
get_observations.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
function [z,idf]= get_observations(x, lm, idf, rmax)
%function [z,idf]= get_observations(x, lm, idf, rmax)
%
% INPUTS:
% x - vehicle pose [x;y;phi]
% lm - set of all landmarks
% idf - index tags for each landmark
% rmax - maximum range of range-bearing sensor
%
% OUTPUTS:
% z - set of range-bearing observations
% idf - landmark index tag for each observation
%
% Tim Bailey 2004.
[lm,idf]= get_visible_landmarks(x,lm,idf,rmax);
z= compute_range_bearing(x,lm);
%
%
function [lm,idf]= get_visible_landmarks(x,lm,idf,rmax)
% Select set of landmarks that are visible within vehicle's semi-circular field-of-view
dx= lm(1,:) - x(1);
dy= lm(2,:) - x(2);
phi= x(3);
% incremental tests for bounding semi-circle
ii= find(abs(dx) < rmax & abs(dy) < rmax ... % bounding box
& (dx*cos(phi) + dy*sin(phi)) > 0 ... % bounding line
& (dx.^2 + dy.^2) < rmax^2); % bounding circle
% Note: the bounding box test is unnecessary but illustrates a possible speedup technique
% as it quickly eliminates distant points. Ordering the landmark set would make this operation
% O(logN) rather that O(N).
lm= lm(:,ii);
idf= idf(ii);
%
%
function z= compute_range_bearing(x,lm)
% Compute exact observation
dx= lm(1,:) - x(1);
dy= lm(2,:) - x(2);
phi= x(3);
z= [sqrt(dx.^2 + dy.^2);
atan2(dy,dx) - phi];