Skip to content

Commit 34bf91f

Browse files
committed
make consistent with newest version of common/rvccheck
1 parent d78d927 commit 34bf91f

File tree

1 file changed

+88
-58
lines changed

1 file changed

+88
-58
lines changed

smtbcheck.m

+88-58
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
% Copyright (C) 1993-2019 Peter I. Corke
33
%
44
% This file is part of The Spatial Math Toolbox for MATLAB (SMTB).
5-
%
5+
%
66
% Permission is hereby granted, free of charge, to any person obtaining a copy
77
% of this software and associated documentation files (the "Software"), to deal
88
% in the Software without restriction, including without limitation the rights
@@ -13,7 +13,7 @@
1313
% The above copyright notice and this permission notice shall be included in all
1414
% copies or substantial portions of the Software.
1515
%
16-
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1717
% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
1818
% FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
1919
% COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
@@ -22,72 +22,102 @@
2222
%
2323
% https://github.com/petercorke/spatial-math
2424

25-
% display current versions of MATLAB
26-
year = version('-release');
27-
fprintf('You are using:\n - MATLAB release %s\n', year);
28-
29-
% check how old it is
30-
today = datevec(now);
31-
age = today(1) - str2num(year(1:4));
32-
if age >= 2
33-
fprintf(' ** this is at least %d years old, you may have issues\n', age);
34-
end
25+
function smtbcheck
26+
% display current versions of MATLAB
27+
year = version('-release');
28+
fprintf('You are using:\n - MATLAB release %s\n', year);
3529

36-
% display versions of toolboxes (use unique RTB and MVTB functions)
37-
p = getpath('tr2rpy');
38-
a = ver( p );
39-
rtb = ~isempty(a);
40-
if rtb
41-
if findstr(p, 'Add-Ons')
42-
where = 'mltbx install to Add-Ons';
43-
else
44-
where = 'local (zip,git) install';
30+
% check how old it is
31+
today = datevec(now);
32+
age = today(1) - str2num(year(1:4));
33+
if age >= 2
34+
fprintf(' ** this is at least %d years old, you may have issues\n', age);
4535
end
46-
fprintf(' - %s %s %s [%s]\n', a.Name, a.Version, a.Date, where);
47-
48-
end
49-
p = getpath('idisp');
50-
a = ver( p );
51-
mvtb = ~isempty(a);
52-
if mvtb
53-
if findstr(p, 'Add-Ons')
54-
where = 'mltbx install to Add-Ons';
55-
else
56-
where = 'local (zip,git) install';
36+
37+
%% display versions of toolboxes (use unique RTB and MVTB functions)
38+
39+
%SMTB
40+
smtb = checktoolbox('RTBPose', 'SMTB');
41+
42+
43+
%% check for shadowed files
44+
45+
shadows = {};
46+
47+
shadows = checkshadow(shadows, 'rotx');
48+
shadows = checkshadow(shadows, 'roty');
49+
shadows = checkshadow(shadows, 'rotz');
50+
shadows = checkshadow(shadows, 'angdiff');
51+
52+
if ~isempty(shadows)
53+
fprintf('\n*** Some Toolbox files are "shadowed" and will cause problems with the use of this toolbox ***\n');
54+
for s = shadows'
55+
fprintf(' - toolbox function "%s" is shadowed by the MathWorks file %s\n', s{1}, s{2} );
56+
end
57+
fprintf('Use the pathtool function to:\n 1. move the Toolbox containing the shadowed function to the top of the path\n 2. Delete the problematic MathWorks toolbox (do you really need it?)\n 3. Move the problematic MathWorks toolbox to the end of the path\n')
5758
end
58-
fprintf(' - %s %s %s [%s]\n', a.Name, a.Version, a.Date, where);
5959
end
6060

61-
% check for shadowed files
62-
k = 0;
63-
if rtb
64-
k = k + checkpath('rotx');
65-
k = k + checkpath('roty');
66-
k = k + checkpath('rotz');
67-
k = k + checkpath('angdiff');
68-
end
69-
if mvtb
70-
k = k + checkpath('im2col');
71-
k = k + checkpath('col2im');
72-
k = k + checkpath('angdiff');
61+
function present = checktoolbox(funcname, tbname)
62+
63+
present = true;
64+
65+
p = which(funcname);
66+
if isempty(p)
67+
% toolbox not present
68+
present = false;
69+
return
70+
end
71+
72+
% display versions of toolbox
73+
fprintf('%s (%s)\n', short2long(tbname), p);
74+
v = ver( p );
75+
76+
where = [];
77+
if strcmp(tbname, 'SMTB')
78+
% special case for SMTB, is it standalone or part of RTB or MVTB?
79+
if contains(p, 'vision', 'IgnoreCase', true)
80+
where = 'included with MVTB';
81+
elseif contains(p, 'robot', 'IgnoreCase', true)
82+
where = 'included with RTB';
83+
end
84+
end
85+
if isempty(where)
86+
if findstr(p, 'Add-Ons')
87+
where = 'Add-Ons (installed from mltbx file or Add-On Explorer)';
88+
else
89+
if exist( fullfile(p, '.git'), 'dir' )
90+
where = 'local (git clone)';
91+
else
92+
where = 'local (zip install)';
93+
end
94+
end
95+
end
96+
97+
if ~isempty(v)
98+
fprintf(' - %s%s, %s\n', tbname, v.Version, v.Date);
99+
end
100+
fprintf(' - %s\n', where);
73101
end
74102

75-
if k > 0
76-
fprintf('Some Toolbox files are "shadowed" and will cause problems with the use of this toolbox\n');
77-
fprintf('Use path tool to move this Toolbox to the top of the path\n')
78-
end
79103

80-
function k = checkpath(funcname)
81-
104+
function out = checkshadow(shadows, funcname)
105+
% add to the list if function lives below MATLAB root
82106
funcpath = which(funcname); % find first instance in path
83-
k = 0;
107+
out = shadows;
108+
if startsWith(funcpath, matlabroot) || startsWith(funcpath, 'built-in')
109+
out = [out; {funcname, which(funcname)}];
110+
end
111+
end
84112

85-
good = {'rvc', 'Robotics Toolbox for MATLAB', 'Machine Vision Toolbox for MATLAB'};
86-
if exist(funcname)
87-
if all( cellfun(@(x) isempty(strfind(funcpath, x)), good) )
88-
fprintf('** Toolbox function %s is shadowed by %s\n', funcname, which(funcname) );
89-
k = 1;
90-
end
113+
function fullname = short2long(shortname)
114+
switch shortname
115+
case 'RTB'
116+
fullname = 'Robotics Toolbox for MATLAB';
117+
case 'MVTB'
118+
fullname = 'Machine Vision Toolbox for MATLAB';
119+
case 'SMTB'
120+
fullname = 'Spatial Math Toolbox for MATLAB';
91121
end
92122
end
93123

0 commit comments

Comments
 (0)