-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmove_uncertain_robot.m
87 lines (67 loc) · 1.55 KB
/
move_uncertain_robot.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
%
% Author Patric Jensfelt
%
close all
figure(1)
global tspeed
global rspeed
global run
global reset
global tdStd
global rdaStd
global rdStd
tspeed = 0;
rspeed = 0;
run = 1;
reset = 0;
simulation_parameters;
create_ui
x = 0;
y = 0;
a = 0;
xt = 0;
yt = 0;
at = 0;
h = [];
SIZE = 2;
axis(SIZE*[-1 1 -1 1])
% Factor for calculting the standard deviation in the distance traveled
% noise proportinal to the distance traveled since last iteration
% Make it HUGE to make it show up easily
tdStd = 0.5;
% Factor for calculting the standard deviation in the part of the noise
% on the rotation, proportinal to the delta angle since last iteration
% Make it HUGE to make it show up easily
rdaStd = 0.5;
% Factor for calculting the standard deviation in the part of the noise
% on the rotation, proportinal to the distance traveled since last iteration
% Make it HUGE to make it show up easily
rdStd = 0.5;
while (run)
dnoise = (tspeed*dT*tdStd)*randn;
arnoise = (rspeed*dT*rdaStd)*randn;
atnoise = (tspeed*dT*rdStd)*randn;
xt = xt + tspeed*dT*cos(at);
yt = yt + tspeed*dT*sin(at);
at = at + rspeed*dT;
x = x + (tspeed*dT+dnoise)*cos(a);
y = y + (tspeed*dT+dnoise)*sin(a);
a = a + (rspeed*dT+arnoise) + atnoise;
if reset
x = 0;
y = 0;
a = 0;
xt = 0;
yt = 0;
at = 0;
reset = 0;
end
if ~isempty(h)
delete(h);
end
hold on
h = display_robot(xt,yt,at,'k');
h = [h display_robot(x,y,a,'b')];
hold off
drawnow;
end