MATLAB ROBOTTOOL
rtdemo 演示
目录
一、rtdemo 机器人工具箱演示.................................................2
二、transfermations 坐标转换................................................... 2
三、Trajectory 齐次方程.............................................................8
四、forward kinematics 运动学正解...................................... 12
四、Animation 动画................................................................. 18
五、Inverse Kinematics 运动学逆解........................................ 23
六、 Jacobians 雅可比---矩阵与速度..................................... 32
七、Inverse Dynamics 逆向动力学.......................................... 45
八、Forward Dynamics 正向动力学.........................................52
一、rtdemo 机器人工具箱演示
>> rtdemo
%
二、transfermations 坐标转换
% In the field of robotics there are many possible ways of
representing
% positions
and
orientations,
but
the
homogeneous
transformation is well
% matched to MATLABs powerful tools for matrix manipulation.
%
% Homogeneous transformations describe the relationships
between Cartesian
% coordinate frames in terms of translation and orientation.
% A pure translation of 0.5m in the X direction is represented
by
transl(0.5, 0.0, 0.0)
ans =
1.0000
0
0
0
0
1.0000
0
0
0
0
1.0000
0.5000
0
0
0
1.0000
%
% a rotation of 90degrees about the Y axis by
roty(pi/2)
ans =
0.0000
0
1.0000
0
1.0000
0
0
0
-1.0000
0
0
0
0.0000
0
0
1.0000
%
% and a rotation of -90degrees about the Z axis by
rotz(-pi/2)
ans =
0.0000
-1.0000
1.0000
0.0000
0
0
0
0
0
0
1.0000
0
0
0
0
1.0000
%
% these may be concatenated by multiplication
t = transl(0.5, 0.0, 0.0) * roty(pi/2) * rotz(-pi/2)
t =
0.0000
-1.0000
0.0000
0.0000
1.0000
0.5000
0
0
-0.0000
-1.0000
0.0000
0
0
0
0
1.0000
%
% If this transformation represented the origin of a new
coordinate frame with respect
% to the world frame origin (0, 0, 0), that new origin would be
t * [0 0 0 1]'
given by
ans =
0.5000
0
0
1.0000
pause % any key to continue
%
% the orientation of
the new coordinate frame may be
expressed in terms of
% Euler angles
tr2eul(t)
ans =
%
0
1.5708
-1.5708
% or roll/pitch/yaw angles
tr2rpy(t)
ans =
-1.5708
0.0000
-1.5708
pause % any key to continue
%
% It is important to note that tranform multiplication is in
general not
% commutative as shown by the following example
rotx(pi/2) * rotz(-pi/8)
ans =
0.9239
0.3827
0
-0.0000
-0.3827
0.0000
0.9239
-1.0000
0.0000
0
0
0
0
0
0
1.0000
rotz(-pi/8) * rotx(pi/2)
ans =
0.9239
0.0000
-0.3827
-0.3827
0.0000
-0.9239
0
0
%
%
pause % any key to continue
echo off
0
0
0
1.0000
0.0000
0
0
1.0000
三、Trajectory 齐次方程
% The path will move the robot from its zero angle pose to the
upright (or
% READY) pose.
%
% First create a time vector, completing the motion in 2 seconds
with a
% sample interval of 56ms.
t = [0:.056:2];
pause % hit any key to continue
%
% A polynomial trajectory between the 2 poses is computed
using jtraj()
%
q = jtraj(qz, qr, t);
pause % hit any key to continue
%
% For this particular trajectory most of the motion is done by
joints 2 and 3,