-
Notifications
You must be signed in to change notification settings - Fork 1
/
StrombomTracking.m
37 lines (30 loc) · 1.08 KB
/
StrombomTracking.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
function Output = StrombomTracking(SheepDogVehicleSpeedLimit, TargetX, TargetY, Xold, Yold, SheepDogDirectionXold, SheepDogDirectionYold, MinX, MinY, MaxX, MaxY,SheepDogVelocity, SafetyDistance,maximumDistance)
%Author: Hussein Abbass
%LastModified: 07-Aug-2020
%Explanation: This function implements the very basic strombom movement
%algorithm. It does not take into account the vehicle model and modulation
%of speed
DirectionX = TargetX - Xold;
DirectionY = TargetY - Yold;
Distance = hypot(DirectionX,DirectionY);
Speed = min(Distance,SheepDogVehicleSpeedLimit)';
SheepDogDirectionX = DirectionX / Distance;
SheepDogDirectionY = DirectionY / Distance;
ModualtedSheepDogVelocity=Speed;
DirectionX = ModualtedSheepDogVelocity * SheepDogDirectionX;
DirectionY = ModualtedSheepDogVelocity * SheepDogDirectionY;
Xnew = Xold + DirectionX;
Ynew = Yold + DirectionY;
if Xnew < MinX
Xnew = MinX;
end
if Xnew > MaxX
Xnew = MaxX;
end
if Ynew < MinY
Ynew = MinY;
end
if Ynew > MaxY
Ynew = MaxY;
end
Output = [Xnew,Ynew,SheepDogDirectionX,SheepDogDirectionY];