root / trunk / code / projects / mapping / matlab / model_sensor.m @ 1606
History | View | Annotate | Download (1.28 KB)
1 | 1148 | justin | function [sensor_model, udata, vdata] = model_sensor |
---|---|---|---|
2 | |||
3 | %Definitions: |
||
4 | 1211 | justin | sensor_model_width = 25; |
5 | 1148 | justin | sensor_model_height = 100; |
6 | 1211 | justin | sensor_bounds_x = 85; %cm |
7 | sensor_bounds_y = 15; %cm |
||
8 | sensor_width = 10; %cm |
||
9 | empty_weight = 0.4; |
||
10 | 1148 | justin | wall_weight = 2.0; |
11 | outside_weight = 1; |
||
12 | |||
13 | %Space creation: |
||
14 | 1211 | justin | Sx = linspace(0, sensor_bounds_x, sensor_model_width); |
15 | 1148 | justin | Sy = linspace(-sensor_bounds_y, sensor_bounds_y, sensor_model_height); |
16 | sensor_model = zeros(size(Sx,1), size(Sy,1), 71); |
||
17 | |||
18 | %k ranges over distances (cm) |
||
19 | for k=10:80 |
||
20 | for j = 1:sensor_model_height; |
||
21 | for i = 1:sensor_model_width; |
||
22 | 1211 | justin | slope = double(k) / double(sensor_width); |
23 | if abs(Sy(j)) < (Sx(i) / slope) && Sx(i) < (k - 2) |
||
24 | sensor_model(j,i,k) = empty_weight; |
||
25 | elseif abs(Sy(j)) < (Sx(i) / slope) && Sx(i) < (k + 2) |
||
26 | sensor_model(j,i,k) = wall_weight; |
||
27 | 1148 | justin | else |
28 | 1211 | justin | sensor_model(j,i,k) = outside_weight; |
29 | 1148 | justin | end |
30 | end |
||
31 | end |
||
32 | 1211 | justin | map(k,1,1) = 100.0; |
33 | 1148 | justin | end |
34 | |||
35 | %Define the sensor model for when no measurement is made (-1) |
||
36 | 1211 | justin | slope = 80 / sensor_width; |
37 | 1148 | justin | for j = 1:sensor_model_height; |
38 | for i = 1:sensor_model_width; |
||
39 | 1211 | justin | if abs(Sy(j)) < Sx(i) / slope && Sx(i) < 80 && Sx(i) > 0 |
40 | sensor_model(j,i,71) = empty_weight; |
||
41 | 1148 | justin | else |
42 | 1211 | justin | sensor_model(j,i,71) = outside_weight; |
43 | 1148 | justin | end |
44 | end |
||
45 | end |
||
46 | |||
47 | 1211 | justin | image(sensor_model(:,:,70).*20); |
48 | |||
49 | udata = [0, 2] * sensor_bounds_x; |
||
50 | vdata = [-1, 1] * sensor_bounds_y; |