-
Notifications
You must be signed in to change notification settings - Fork 1
/
startup_WBC.m
79 lines (56 loc) · 2.34 KB
/
startup_WBC.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
%% startup_WBC.m
%
% Run this script once to permanently add the matlab-wbc library to your MATLAB path.
fprintf('\n## whole-body-controllers ##\n');
fprintf('\nAdding "matlab-wbc" library to pathdef.m...\n\n');
% path to whole-body-controllers
pathToWBC = pwd;
pathToWBC = pathToWBC(1:end-6);
% path to the matlab-wbc library
pathToLibrary = [pathToWBC, filesep, 'library/matlab-wbc'];
if exist(pathToLibrary, 'dir')
addpath(pathToLibrary);
else
error('Path to the "matlab-wbc" library not found or not correct.')
end
% Path to the Matlab userpath
pathToUserpath = userpath;
pathSeparatorLocation = strfind(pathToUserpath, pathsep);
if isempty(pathToUserpath)
answer = input('Empty userpath. Do you want to reset the userpath? Y/N ','s');
if strcmpi(answer,'Y')
userpath('reset');
disp('Resetting userpath..');
pathToUserpath = userpath;
pathSeparatorLocation = strfind(pathToUserpath, pathsep);
else
error('Please set the userpath before running this script');
end
elseif size(pathSeparatorLocation, 2) > 1
answer = input('Multiple userpath. Do you want to reset the userpath? Y/N ','s');
if strcmpi(answer,'Y')
userpath('reset');
disp('Resetting userpath..');
pathToUserpath = userpath;
pathSeparatorLocation = strfind(pathToUserpath, pathsep);
else
error('Please set a single userpath before running this script');
end
end
% check again the userpath
if isempty(pathToUserpath)
error('userpath is still empty. Please set the userpath before running this script');
elseif size(pathSeparatorLocation, 2) > 1
error('There are still multiple userpath. Please set a single userpath before running this script');
end
if (~isempty(pathSeparatorLocation))
pathToUserpath(pathSeparatorLocation) = [];
end
fprintf('Saving paths to %s\n\n', [pathToUserpath, filesep, 'pathdef.m']);
if (~savepath([pathToUserpath, filesep, 'pathdef.m']))
fprintf(['A file called pathdef.m has been created in your %s folder.\n', ...
'This should be enough to permanently add matlab-wbc to ', ...
'your MATLAB installation.\n'], pathToUserpath);
else
disp('There was an error generating the pathdef.m. Please manually add the matlab-wbc folder to your matlabpath');
end