RTTRDEMO Transforms and quaternion demo
0001 %RTTRDEMO Transforms and quaternion demo 0002 0003 % Copyright (C) 1993-2002, by Peter I. Corke 0004 % $Log: not supported by cvs2svn $ 0005 % Revision 1.2 2002-04-01 11:47:18 pic 0006 % General cleanup of code: help comments, see also, copyright, remnant dh/dyn 0007 % references, clarification of functions. 0008 % 0009 % $Revision: 1.1 $ 0010 echo on 0011 % 0012 % In the field of robotics there are many possible ways of representing 0013 % positions and orientations, but the homogeneous transformation is well 0014 % matched to MATLABs powerful tools for matrix manipulation. 0015 % 0016 % Homogeneous transformations describe the relationships between Cartesian 0017 % coordinate frames in terms of translation and orientation. 0018 0019 % A pure translation of 0.5m in the X direction is represented by 0020 transl(0.5, 0.0, 0.0) 0021 % 0022 % a rotation of 90degrees about the Y axis by 0023 troty(pi/2) 0024 % 0025 % and a rotation of -90degrees about the Z axis by 0026 trotz(-pi/2) 0027 % 0028 % these may be concatenated by multiplication 0029 t = transl(0.5, 0.0, 0.0) * troty(pi/2) * trotz(-pi/2) 0030 0031 % 0032 % If this transformation represented the origin of a new coordinate frame with respect 0033 % to the world frame origin (0, 0, 0), that new origin would be given by 0034 0035 t * [0 0 0 1]' 0036 pause % any key to continue 0037 % 0038 % the orientation of the new coordinate frame may be expressed in terms of 0039 % Euler angles 0040 tr2eul(t) 0041 % 0042 % or roll/pitch/yaw angles 0043 tr2rpy(t) 0044 pause % any key to continue 0045 % 0046 % It is important to note that tranform multiplication is in general not 0047 % commutative as shown by the following example 0048 trotx(pi/2) * trotz(-pi/8) 0049 trotz(-pi/8) * trotx(pi/2) 0050 % 0051 % 0052 pause % any key to continue 0053 echo off