-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMRPP_RPP.m
57 lines (53 loc) · 1.87 KB
/
MRPP_RPP.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
function [successFlag,totalCost,computeTime,AllPathCell] = MRPP_RPP(robotNum,mapGrid,StartRobotStates,GoalRobotStates,ctime,planTime)
successFlag=1;
computeTime=0;
totalCost=0;
% reserved temporal-spatial table
currentTSTable = [];
AllPathCell=cell(robotNum,1);
currentTSTable=[];
t1=clock;
for i=1:robotNum
tempTSTable = [];
%avoid higher priority robots' goal stations and lower priority
%robots' start stations
for j=1:robotNum
sb = zeros(planTime,3);
if i<j
sb(:,1:2)=repmat(StartRobotStates(j,1:2),planTime,1);
sb(:,3)=(1:planTime)';
tempTSTable = [tempTSTable;sb];
elseif i>j
sb(:,1:2)=repmat(GoalRobotStates(j,1:2),planTime,1);
sb(:,3)=(1:planTime)';
tempTSTable = [tempTSTable;sb];
else
continue;
end
end
tempTSTable = [tempTSTable;currentTSTable];
tempPath=singlePlannerForPP(mapGrid,StartRobotStates(i,:),GoalRobotStates(i,:),ctime,tempTSTable);
if size(tempPath,1)==1 || size(tempPath,1)>=planTime
successFlag=0;
break;
end
pathLength=size(tempPath,1);
totalCost=totalCost+pathLength;
sb=tempPath(end,:);
%makesure robots stays forever on the goal station.
for j=1:planTime-pathLength
tempPath(pathLength+j,:)=[sb(1,1:3),j+pathLength];
end
AllPathCell{i,1}=tempPath;
tempPath(:,3)=tempPath(:,4);
tempPath(:,4)=[];
currentTSTable=[currentTSTable;tempPath];
end
t2=clock;
computeTime=etime(t2,t1);
if successFlag == 0
computeTime = 0;
totalCost = 0;
AllPathCell=[];
end
end