-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsolveDtsp.m
46 lines (40 loc) · 1.25 KB
/
solveDtsp.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
function [E, X, Cost] = solveDtsp(V,x,pathOptions,algorithm)
%solveDtsp Solves the DTSP with the DPP solver.
%
% Parameters:
% V Set of vertices n-by-2
% x Start heading in radians
% pathOptions Options for solver (uses TurnRadius and Circuit)
% [algorithm] Algorithm name ('alternating', 'randomized', 'nearest')
% Returns:
% E m-by-2 set of edges representing the tour
% X n-by-1 vector of headings at each vertex
% Cost The total cost of the solution
%
% Note: m = n-1 if Circuit is 'off'
% Find all dependencies
% Add lib and class folders
addpath('lib','class');
% Add nearest neighbor MEX
if exist('dppSolveDTSP') ~= 3
if exist('lib/DubinsPathPlanner') ~= 7
error('Could not find the DubinsPathPlanner folder.');
end
addpath('lib/DubinsPathPlanner');
if exist('dppSolveDTSP') ~= 3
error('Could not find compiled dppSolveDTSP mex file.');
end
end
% Call the MEX file
r = pathOptions.TurnRadius;
returnToInitial = 1;
extraArgs = {};
if (strcmp(pathOptions.Circuit,'off'))
returnToInitial = 0;
extraArgs = {returnToInitial};
end
if nargin > 3
extraArgs = {returnToInitial, algorithm};
end
[E, X, Cost] = dppSolveDtsp(V, x, r, extraArgs{:});
end