So I'm trying to compute some homogeneous transformation matrices using Peter Corke's Robotics toolbox, however when I try to use the "trchain" command:
syms a1 q1 q2
trchain('Rz(q1)Tz(a1)Ry(q2)',[q1 q2])
I get the following output:
Error using rotz
Expected GAMMA to be one of these types:
double
Instead its type was sym.
Error in sigdatatypes.validateAngle (line 22)
validateattributes(x,{'double'},{'finite','nonnan','nonempty','real'},...
Error in rotz (line 30)
sigdatatypes.validateAngle(gamma,'rotz','GAMMA',{'scalar'});
Error in trotz (line 36)
T = [rotz(t, varargin{:}) [0 0 0]'; 0 0 0 1];
Error in trchain (line 93)
T = T * trotz(arg);
I looked online and came across a few things (E.g. ensuring that Phase Array Toolbox is installed) but nothing is working.
The same problem appears if I try using "rotz" by itself and not within the "trchain" command. Also, the "rotz" function works perfectly fine for numeric arguments.
Any help would be very welcome - thank you!
EDIT -- A new error!
Upon trying the code again, (even though it worked fine the other day), I am now getting another message:
Error using ROUNDN
Expected X to be one of these types:
single, double
Instead its type was sym.
Error in roundn (line 31)
validateattributes(x, {'single', 'double'}, {}, 'ROUNDN', 'X')
Error in rotz (line 18)
R = roundn(R, -15);
Error in trotz (line 36)
T = [rotz(t, varargin{:}) [0 0 0]'; 0 0 0 1];
Error in trchain (line 93)
T = T * trotz(arg);
Error in kinematics1 (line 3)
trchain('Rz(q1)Tz(a1)Ry(q2)',[q1 q2])
The code is exactly the same as above. The version of Matlab I am using is R2018a and the version of Robotics Toolbox is 10.3. Also, Phased Array Toolbox is not installed.
Hope you can help again...thank you
You say that you have installed the Phased Array Toolbox but you should NOT have installed that product because it also brings functions rotx, roty, rotz, clashing with the Corke Toolbox. See http://petercorke.com/wordpress/toolboxes/faq where the standard error is a mismatch between units radians and degree, with the Symbolic Toolbox obviously more errors occur, see text there:
You are using functions with the same name as Robotics Toolbox for MATLAB functions
but which are not from the Robotics Toolbox for MATLAB.
The usual culprit is the MATLAB Phased Array System Toolbox. To test this
>> which rotx
which shows you the filesystem path to rotx.m.
I do not have the Phased Array System Toolbox to really check, but my rotz.m from Corke has comments up to line 30, whereas your error message has code there. The code in the functions trchain and trotz is the same like in your errors.
So uninstall the Phased Array System Toolbox. If this does not help: Please state the versions of the Robotics Toolbox and MATLAB your are using. Your commands work fine on my MATLAB 2016a with the following Robotics Toolbox version:
Robotics, Vision & Control: (c) Peter Corke 1992-2011 http://www.petercorke.com
- Robotics Toolbox for MATLAB (release 10.2)
- ARTE contributed code: 3D models for robot manipulators (D:\_ROB\software\rvctools\robot\data\ARTE)
- pHRIWARE (release 1.1): pHRIWARE is Copyrighted by Bryan Moutrie (2013-2018) (c)
giving the result
ans =
[ cos(q1)*cos(q2), -sin(q1), cos(q1)*sin(q2), 0]
[ cos(q2)*sin(q1), cos(q1), sin(q1)*sin(q2), 0]
[ -sin(q2), 0, cos(q2), a1]
[ 0, 0, 0, 1]