matlab toolbox 介绍,Matlab Robotic Toolbox使用简介(1)
软件:matlab2014a工具箱:Matlab Robotic Toolbox v9.8这里感谢枫箫提供的机器人工具箱:http://blog.sina.com.cn/u/2707887295本次连载主要以机器人工具箱附带的使用例子为主,提供注释和翻译。希望可以帮助大家更好使用机器人工具箱。安装好MatlabRobotic Toolboxv9.8后,打开MATLAB,查看附带的例子输入rtbde
软件:matlab2014a
工具箱:Matlab Robotic Toolbox v9.8
这里感谢枫箫提供的机器人工具箱:http://blog.sina.com.cn/u/2707887295
本次连载主要以机器人工具箱附带的使用例子为主,提供注释和翻译。希望可以帮助大家更好使用机器人工具箱。
安装好Matlab
Robotic Toolbox
v9.8后,打开MATLAB,查看附带的例子输入rtbdemo,回车,就可以看到简介菜单。
这里逐次介绍每个的使用简介
rtbdemo
------------------------------------------------------------
Many of these demos print tutorial text and MATLAB commmands in the
console window.
Read the text and press to move on to the next command
At the end of the tutorial/demo you can choose the next one from
the graphical menu.
--- runscript
D:\matlab\toolbox\robot\rvctools\robot\demos\rotation.m
% In the field of robotics there are many possible ways of
representing
% orientations of which the most common are:
% - orthonormal【正交】rotation matrices (3x3),正交旋转矩阵
% - three angles (1x3), and
% - quaternions.【四元数】表示法可以参考http://blog.sina.com.cn/u/2707887295
% A rotation of pi/2 about the x-axis can be represented as an
orthonormal rotation
% matrix【绕x轴旋转pi/2的正交旋转矩阵】
>> R = rotx(pi/2)
R =
1.0000 0
0
0 0.0000 -1.0000
0 1.0000 0.0000
% which we can see is a 3x3 matrix.
% Such a matrix has the property that it's columns【列】 (and rows【行】)
are sets of orthogonal
% unit vectors【单位向量】. The determinant of such a
matrix is always 1
>> det(R)
ans =
1
% Let's create a more complex rotation【创作一个更复杂的旋转】
>> R = rotx(30, 'deg') * roty(50, 'deg') * rotz(10,
'deg')
R =
0.6330 -0.1116 0.7660
0.5276 0.7864 -0.3214
-0.5665 0.6076 0.5567
% where this time we have specified the rotation angle in
degrees.【度数】
% Any rotation can be expressed in terms of a single rotation about
some axis
% in space【任何旋转都可以表达为绕空间某一特定轴的单独旋转】
>> [theta,vec] = tr2angvec(R)
theta
1.0610
vec =
0.5322 0.7634 0.3662
% where theta is the angle (in radians【弧度】) and vec is unit vector
representing the
% direction of the rotation
axis【旋转轴方向】.【这里theta是角度(以弧度表示),vec是代表旋转轴方向的单位向量】
% Commonly rotations are represented by Euler angles【欧拉角】
>> eul = tr2eul(R)
eul =
-0.3972 0.9804 0.8204
% which are three angles such that R = rotz(a)*roty(b)*rotz(c), ie.
the rotations
% required about the Z, then then the Y, then the Z axis.
% Rotations are also commonly represented by roll-pitch-yaw
angles
>> rpy = tr2rpy(R)
rpy =
0.5236 0.8727 0.1745
% which are three angles such that R = rotx(r)*roty(p)*rotz(y), ie.
the rotations
% required about the X, then then the Y, then the Z axis.
% We can investigate the effects of rotations about different
axes
% using this GUI based demonstration. The menu
buttons allow the rotation
% axes to be varied【我们可以查看不同轴的旋转效果,通过使用演示的GUI。菜单按钮可以使旋转轴改变】
% close the window when you are done.
>> tripleangle('rpy', 'wait')
% The final useful form is the quaternion which comprises 【包含】4
numbers. We can create
% a quaternion from an orthonormal matrix
>> q = Quaternion(R)
q =
0.86256 < 0.26926, 0.38622, 0.18526 >
% where we can see that it comprises a scalar【标量】 part and a
vector【向量】 part. To convert back【向后转换】
>> q.R
ans =
0.6330 -0.1116 0.7660
0.5276 0.7864 -0.3214
-0.5665 0.6076 0.5567
% which is the same of the value of R we determined
above.【这和我们上面所推算的R是一样的】
% Quaternions are a class and the orientations they represent can
be compounded【复合的】, just
% as we do with rotation matrices by multiplication【乘法运算】.
% First we create two quaternions
>> q1 = Quaternion( rotx(pi/2) )
q1 =
0.70711 < 0.70711, 0, 0 >
>> q2 = Quaternion( roty(pi/2) )
q2 =
0.70711 < 0, 0.70711, 0 >
% then the rotation of q1 followed【跟随的】 by q2 is simply
>> q1 * q2
ans =
0.5 < 0.5, 0.5, 0.5 >
% We can also take the inverse【逆的,反的】 of a Quaternion
>> q1 * inv(q1)
ans =
1 < 0, 0, 0 >
% which results in a null【零位的】 rotation (zero vector part)
------ done --------
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)