forked from wangting0310njtech/Multi-robot-SLAM-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLLC.m
More file actions
45 lines (30 loc) · 707 Bytes
/
LLC.m
File metadata and controls
45 lines (30 loc) · 707 Bytes
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
function simrobot = LLC(simrobot,xEnt,dist)
xy0 = getpos(simrobot);
xy1 = xEnt;
distT = sqrt((xy0(1,1)-xy1(1,1))^2+(xy0(1,2)-xy1(1,2))^2);
rot = atan2(xy1(2)-xy0(2),xy1(1)-xy0(1))*180/pi;
if (rot<0)
rot = 360 + rot;
end
ang = gethead(simrobot);
angR = rot - ang;
if (abs(angR) > 180)
angR = angR - (angR/abs(angR))*360;
end
tr=0.7;
tl=0.7;
if angR > 5
tl=0.4;
tr=0.9;
elseif angR < -5
tl=0.9;
tr=0.4;
end
[a,b] = min(dist);
if a(1) > 10 || sum(a)==0
simrobot = setvel(simrobot,[tl tr]);
elseif b(1)>length(dist)/2 - 1
simrobot = setvel(simrobot,[-1.6 1.6]);
else
simrobot = setvel(simrobot,[-1.6 1.6]);
end