-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathavoid_collision.m
47 lines (37 loc) · 1.56 KB
/
avoid_collision.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
function [modified_trajec,new_first,right] = avoid_collision(first,waypoint_lead,min_dis, min_init,turn_right, mod)
%Function for avoiding collision between two leaders during their
%trajectories
%used in program : Two leader follower with union
modified_trajec=[];
switch first
case 1
modified_trajec(1)=waypoint_lead(1)+mod(1);
modified_trajec(2)=waypoint_lead(2)+mod(2);
new_first=2;
right=0;
case 2
if min_dis<=min_init
modified_trajec(1)=waypoint_lead(1)-mod(1);
modified_trajec(2)=waypoint_lead(2)-mod(2);
new_first=3;
right=0;
else
modified_trajec(1)=waypoint_lead(1)+mod(1);
modified_trajec(2)=waypoint_lead(2)-mod(2);
new_first=3;
right=1;
end
case 3
if turn_right==0
modified_trajec(1)=waypoint_lead(1)-mod(1);
modified_trajec(2)=waypoint_lead(2)-mod(2);
right=0;
new_first=3;
elseif turn_right==1
modified_trajec(1)=waypoint_lead(1)+mod(1);
modified_trajec(2)=waypoint_lead(2)-mod(2);
right=0;
new_first=3;
end
end
end