Matlab Robotic Toolbox工具箱学习笔记_第1页
Matlab Robotic Toolbox工具箱学习笔记_第2页
Matlab Robotic Toolbox工具箱学习笔记_第3页
Matlab Robotic Toolbox工具箱学习笔记_第4页
Matlab Robotic Toolbox工具箱学习笔记_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Matlab Robotic Toolbox工具箱学习笔记(一)软件:matlab2013a工具箱:Matlab Robotic Toolbox v9.8Matlab Robotic Toolbox工具箱学习笔记根据Robot Toolbox demonstrations目录,将分三大部分阐述:1、General(Rotations,Transformations,Trajectory)2、Arm(Robot,Animation,Forwarw kinematics,Inverse kinematics,Jacobians,Inverse dynamics,Forward dynamics,S

2、ymbolic,Code generation)3、Mobile(Driving to a pose,Quadrotor,Braitenberg,Bug,D*,PRM,SLAM,Particle filter)General/Rotations%绕x轴旋转pi/2得到的旋转矩阵(1)r = rotx(pi/2);%matlab默认的角度单位为弧度,这里可以用度数作为单位(2)R = rotx(30, 'deg') * roty(50, 'deg') * rotz(10, 'deg');%求出R等效的任意旋转变换的旋转轴矢量vec和转角theta(

3、3)theta,vec = tr2angvec(R);%旋转矩阵用欧拉角表示,R = rotz(a)*roty(b)*rotz(c)(4)eul = tr2eul(R);%旋转矩阵用roll-pitch-yaw角表示, R = rotx(r)*roty(p)*rotz(y)(5)rpy = tr2rpy(R);%旋转矩阵用四元数表示(6)q = Quaternion(R);%将四元数转化为旋转矩阵(7)q.R; %界面,可以是“rpy”,“eluer”角度单位为度。(8)tripleangle('rpy');General/Transformations%沿x轴平移0

4、.5,绕y轴旋转pi/2,绕z轴旋转-pi/2 (1)t = transl(0.5, 0.0, 0.0) * troty(pi/2) * trotz(-pi/2)%将齐次变换矩阵转化为欧拉角(2)tr2eul(t)%将齐次变换矩阵转化为roll、pitch、yaw角(3) tr2rpy(t)General/Trajectoryclear;clc;p0 = -1;% 定义初始点及终点位置p1 = 2;p = tpoly(p0, p1, 50);% 取步长为50figure(1);plot(p);%绘图,可以看到在初始点及终点的一、二阶导均为零p,pd,pdd = tpoly(p0, p

5、1, 50);%得到位置、速度、加速度%p为五阶多项式,速度、加速度均在一定范围内figure(2);subplot(3,1,1); plot(p); xlabel('Time'); ylabel('p');subplot(3,1,2); plot(pd); xlabel('Time'); ylabel('pd');subplot(3,1,3); plot(pdd); xlabel('Time'); ylabel('pdd');%另外一种方法:p,pd,pdd = lspb(p0, p1, 50);

6、figure(3);subplot(3,1,1); plot(p); xlabel('Time'); ylabel('p');subplot(3,1,2); plot(pd); xlabel('Time'); ylabel('pd');% 可以看到速度是呈梯形subplot(3,1,3); plot(pdd); xlabel('Time'); ylabel('pdd');%三维的情况:p = mtraj(tpoly, 0 1 2, 2 1 0, 50);figure(4);plot(p)%对于齐次变

7、换矩阵的情况T0 = transl(0.4, 0.2, 0) * trotx(pi);% 定义初始点和目标点的位姿T1 = transl(-0.4, -0.2, 0.3) * troty(pi/2) * trotz(-pi/2);T = ctraj(T0, T1, 50);first=T(:,:,1);%初始位姿矩阵tenth=T(:,:,10);%第十个位姿矩阵figure(5);tranimate(T);%动画演示坐标系自初始点运动到目标点的过程Matlab Robotic Toolbox工具箱学习笔记(二)Arm/Robots机器人是由多个连杆连接而成的,机器人关节分为旋转关节和移动关节

8、。创建机器人的两个最重要的函数是:Link和SerialLink。1、Link类一个Link包含了机器人的运动学参数、动力学参数、刚体惯性矩参数、电机和传动参数。操作函数:%A               连杆变换矩阵%  RP            关节类型: 'R' 或 '

9、;P'%  friction      摩擦力%  nofriction    摩擦力忽略%  dyn           显示动力学参数%  islimit       测试关节是否超出软限制%  isrevo

10、lute    测试是否为旋转关节%  isprismatic   测试是否为移动关节%  display       连杆参数以表格形式显示%  char          转为字符串运动学参数:%  theta    关节角度%

11、0; d        连杆偏移量%  a        连杆长度%  alpha    连杆扭角%  sigma    旋转关节为0,移动关节为1%  mdh      标准的D&H为0,否则为1%&

12、#160; offset   关节变量偏移量%  qlim     关节变量范围min max动力学参数:%  m        连杆质量%  r        连杆相对于坐标系的质心位置3x1%  I     

13、0;  连杆的惯性矩阵(关于连杆重心)3x3%  B        粘性摩擦力(对于电机)1x1或2x1%  Tc       库仑摩擦力1x1或2x1电机和传动参数:%  G        齿轮传动比%  Jm     

14、;  电机惯性矩(对于电机)2、SerialLink类操作函数:%  plot          以图形形式显示机器人%  teach         驱动机器人%  isspherical   测试机器人是否有球腕关节%  islimit   &#

15、160;   测试机器人是否抵达关节极限%  fkine         前向运动学求解%  ikine6s       6旋转轴球腕关节机器人的逆向运动学求解%  ikine3        3旋转轴机器人的逆向运动学求解%  ikine 

16、;        采用迭代方法的逆向运动学求解%  jacob0        在世界坐标系描述的雅克比矩阵%  jacobn        在工具坐标系描述的雅克比矩阵%  maniplty      可操纵性度%  

17、jtraj         关节空间轨迹%  accel         关节加速度%  coriolis      关节柯氏力%  dyn           显示连杆的动力学属性%

18、60; fdyn          关节运动%  friction      摩擦力%  gravload      关节重力%  inertia       关节惯性矩阵%  nofriction  

19、;  设置摩擦力为0%  rne           关节的力/力矩%  payload       在末端坐标系增加负载%  perturb       随机扰动连杆的动力学参数属性:%  links    

20、  连杆向量(1xN)%  gravity    重力的方向gx gy gz%  base       机器人基座的位姿(4x4)%  tool       机器人的工具变换矩阵 T6 to tool tip (4x4)%  qlim       关

21、节范围qmin qmax (Nx2)%  offset     偏置(Nx1)%  name       机器人名字(在图形中显示)%  manuf      注释, 制造商名%  comment    注释, 总评%  plotopt   

22、0;options for plot() method (cell array)%  n           关节数%  config      机器人结构字符串, 例如 'RRRRRR'%  mdh         运动学中约定的布尔数 (0=DH,

23、1=MDH)怎样创建一个机器人?  %Link调用格式: %             (1) L = Link() 创建一个带默认参数的连杆             (2)L = Link(L1)复制连杆L1        

24、60;    (3)L = Link(OPTIONS) 创建一个指定运动学、动力学参数的连杆            OPTIONS可以是:            % 'theta',TH   joint angle, if not specified joint is re

25、volute            % 'd',D        joint extension, if not specified joint is prismatic            % 'a',A   &#

26、160;    joint offset (default 0)            % 'alpha',A    joint twist (default 0)            % 'standard'   

27、defined using standard D&H parameters (default).            % 'modified'   defined using modified D&H parameters.            % 'offset',O

28、0;  joint variable offset (default 0)            % 'qlim',L     joint limit (default )            % 'I',I    

29、    link inertia matrix (3x1, 6x1 or 3x3)            % 'r',R        link centre of gravity (3x1)            % &#

30、39;m',M        link mass (1x1)            % 'G',G        motor gear ratio (default 0)          

31、60; % 'B',B        joint friction, motor referenced (default 0)            % 'Jm',J       motor inertia, motor referenced (default 0)  

32、;          % 'Tc',T       Coulomb friction, motor referenced (1x1 or 2x1), (default 0 0)            % 'revolute'   for a rev

33、olute joint (default)            % 'prismatic'  for a prismatic joint 'p'            % 'standard'   for standard D&H parameters

34、 (default).            % 'modified'   for modified D&H parameters.            % 'sym'        consider all

35、 parameter values as symbolic not numeric            注:不能同时指定“theta”和“d”               连杆的惯性矩阵(3x3)是对称矩阵,可以写成3x3矩阵,也可以是Ixx Iyy Izz Ixy Iyz Ixz    

36、;           所有摩擦均针对电机而不是负载               齿轮传动比只用于传递电机的摩擦力和惯性矩给连杆坐标系。 %SerialLink调用格式: %            &

37、#160;(1)R = SerialLink(LINKS, OPTIONS),OPTIONS可以是:'name'、'comment'、'manufacturer'         'base'、'tool'、'gravity'、'plotopt'        (2)R = SerialLink(DH, OPTION

38、S),矩阵DH的构成:每个关节一行,每一行为theta d a alpha         (默认为旋转关节),第五列(sigma)为可选列,sigma=0(默认)为旋转关节,sigma=1为移动关节               (3) R = SerialLink(OPTIONS) 没有连杆的机器人     

39、;          (4)R = SerialLink(R1 R2 ., OPTIONS) 机器人连接, 将R2的基座连接到R1的末端.               (5)R = SerialLink(R1, options) 复制机器人R1% L1 = Link('d', 0, 'a', 1, '

40、;alpha', pi/2);%定义连杆1,没有写theta说明theta为关节变量 L1.a;%查看a的值 L1.d;%查看d的值%还可以L1.RP,L1.display,L1.mdh,L1.isprismatic,L1.isrevolute等等,这样就可以查看一些默认值 L2 = Link('d', 0, 'a', 1, 'alpha', 0); bot = SerialLink(L1 L2, 'name', 'my robot'); bot.n;%查看

41、连杆数目 bot.fkine(0.1 0.2);%前向运动学 bot.plot(0.1 0.2);%绘制机器人定义完连杆和机器人便可以求机器人前和逆向运动学、动力学等等。L1.参数或属性():查看连杆的参数或属性L1.操作函数(参数):操作连杆参数bot.属性():查看机器人的属性bot.操作函数(参数):操作机器人,可以进行前向、逆向运动学求解等实例:Stanford ManipulatorD-H参数表:clear;clc; L1 = Link('d', 0, 'a', 0, 'alpha', -pi/2);%定义

42、连杆 L2 = Link('d', 1, 'a', 0, 'alpha', pi/2); L3 = Link('theta', 0, 'a', 0, 'alpha', 0); L4 = Link('d', 0, 'a', 0, 'alpha', -pi/2); L5 = Link('d', 0, 'a', 0, 'alpha', pi/2); L6 = L

43、ink('d', 1, 'a', 0, 'alpha', 0); bot = SerialLink(L1 L2 L3 L4 L5 L6);%连接连杆 bot.display();%显示D-H参数表 forward_kinematics=bot.fkine(-0.2 0.1 10 0.1 1 2)%前向运动学求出末端的齐次变换矩阵:clear;clc; L1 = Link('d', 0, 'a', 0, 'alpha', -pi/2,'sym')

44、;%定义连杆 L2 = Link('d', 'd2', 'a', 0, 'alpha', pi/2,'sym'); L3 = Link('theta', 0, 'a', 0, 'alpha', 0,'sym'); L4 = Link('d', 0, 'a', 0, 'alpha', -pi/2,'sym'); L5 = Link('d'

45、;, 0, 'a', 0, 'alpha', pi/2,'sym'); L6 = Link('d', 'd6', 'a', 0, 'alpha', 0,'sym'); bot = SerialLink(L1 L2 L3 L4 L5 L6);%连接连杆 syms theta1 theta2 d3 theta4 theta5 theta6; forward_kinematics=bot.fkine(theta1 theta2 d3

46、theta4 theta5 theta6)%前向运动学 Stanford arm的运动学逆解:clear;clc;clear L%             th    d       a    alphaL(1) = Link( 0     0 &#

47、160;     0   -pi/2     0);%定义连杆L(2) = Link( 0     1       0    pi/2     0);L(3) = Link( 0     0 

48、0;     0    0        1);L(4) = Link( 0     0       0   -pi/2     0);L(5) = Link( 0     0&#

49、160;      0    pi/2     0);L(6) = Link( 0     1       0    0        0);bot = SerialLink(L, 'name'

50、, 'Stanford arm');%连接连杆T=transl(1,2,3)*trotz(60,'deg')*troty(30,'deg')*trotz(90,'deg')inverse_kinematics=bot.ikine(T,'pinv');%逆向运动学theta1=inverse_kinematics(1);theta2=inverse_kinematics(2);d3=inverse_kinematics(3);theta4=inverse_kinematics(4);theta5=inverse_ki

51、nematics(5);theta6=inverse_kinematics(6);forward_kinematics=bot.fkine(theta1 theta2 d3 theta4 theta5 theta6)%前向运动学,验证结果的准确性.%求解结果为T与forward_kinematics一致。正确。求解Stanford arm在世界坐标系描述的雅克比矩阵clear;clc;clear L%             th   

52、 d       a    alphaL(1) = Link( 0     0       0   -pi/2     0);%定义连杆L(2) = Link( 0     1    

53、60;  0    pi/2     0);L(3) = Link( 0     0       0    0        1);L(4) = Link( 0     0  &#

54、160;    0   -pi/2     0);L(5) = Link( 0     0       0    pi/2     0);L(6) = Link( 0     1   

55、60;   0    0        0);bot = SerialLink(L, 'name', 'Stanford arm');%连接连杆syms theta1 theta2 d3 theta4 theta5 theta6;J0=vpa(bot.jacob0(theta1 theta2 d3 theta4 theta5 theta6),4)求平面二自由度机器人在世界坐标系描述的雅克比矩阵D-H参数表:clear;clc;clear LL(1) = Link('d',0,'a','a1','alpha',0,'sym');%定义连杆L(2) = Link('d',0,'a','a2','alpha',0,'sym');bot = SerialLink(L, 'name', 'Planar 2-dof

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论