Matlab Robotic Toolbo工具箱学习笔记

上传人:jin****ng 文档编号:110347597 上传时间:2022-06-18 格式:DOC 页数:18 大小:724.50KB
返回 下载 相关 举报
Matlab Robotic Toolbo工具箱学习笔记_第1页
第1页 / 共18页
Matlab Robotic Toolbo工具箱学习笔记_第2页
第2页 / 共18页
Matlab Robotic Toolbo工具箱学习笔记_第3页
第3页 / 共18页
亲,该文档总共18页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
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,Inversekinematics,Jacobians,Inverse dynamics,Forward dynamics,Symbolic,Code generation)3、Mobile(Driving to apose,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) 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);%旋转矩阵用四元数表示p1耳9sin 一 a20 sin cos20sin 一 cos p2(6) q = Quaternion(R);一个有固定点的刚体通过绕该点的某个轴转 过特定角度可达到任何姿态n cos tz J + eos /? /-!- cos / k标量部分包括一个实数单位1和三个虚数单位 Xk另一种表示法:乩 尸),尸代表矢量部分转轴的方向可以表示成一个单位矢量则描述该转动的四元数可以表示成:四元数既反映了转动的月向又反映了转动的幅值.矢量部分四元数的表示:3e q cos + sin220=cog + sin0cos /e1 + sin cos 0ef 7 + am C05 y - k2222%将四元数转化为旋转矩阵(7) q.R;%界面,可以是“rpy”,“eluer”角度单位为度。(8) tripleangle(rpy);0.00.505General/Transformations-0.6%沿x轴平移0.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;%定义初始点及终点位置pl = 2;p = tpoly(pO, pl, 50);% 取步长为 50figure(l);plot(p);%绘图,可以看到在初始点及终点的一、二阶导均为零p,pd,pdd二 tpoly(p0, p1, 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);TirrBTEr白血IIIII-a5!01S20a3DJ3-4DWTm%另外一种方法:p,pd,pdd二 lspb(p0, p1, 50);figure(3);subplot(3,1,1); plot(p); xlabel(Time); ylabel(p);subplot(3,1,2); plot(pd); xlabel(Time); ylabel(pd);% 可以看到速度是呈21,61.40.30.60.210204050plot(p)%对于齐次变换矩阵的情况TO = 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(:,:,l);%初始位姿矩阵tenth二T(:,:,10);%第十个位姿矩阵figure(5);tranimate(T);%动画演示坐标系自初始点运动到目标点的过程Matlab Robotic Toolbox 工具箱学习笔记(二)Arm/Robots机器人是由多个连杆连接而成的,机器人关节分为旋转关节和移动关节。创建机 器人的两个最重要的函数是:Link和SerialLink。1、Link 类一个Link包含了机器人的运动学参数、动力学参数、刚体惯性矩参数、电机和 传动参数。操作函数:%A连杆变换矩阵% RP 关节类型:R或P% friction 摩擦力% nofriction 摩擦力忽略% dyn显示动力学参数% islimit测试关节是否超出软限制% isrevolute测试是否为旋转关节% isprismatic测试是否为移动关节% display连杆参数以表格形式显示% char转为字符串运动学参数:% theta关节角度% d连杆偏移量% a连杆长度% alpha连杆扭角% sigma旋转关节为0,移动关节为1% mdh 标准的D&H为0,否则为1% offset关节变量偏移量% qlim 关节变量范围min max动力学参数:% m连杆质量% r连杆相对于坐标系的质心位置3x1% I连杆的惯性矩阵(关于连杆重心)3x3% B粘性摩擦力(对于电机)1x1或2x1% Tc库仑摩擦力1x1或2x1电机和传动参数:% G 齿轮传动比% Jm电机惯性矩(对于电机)2、SerialLink 类操作函数:% plot以图形形式显示机器人% teach驱动机器人% isspherical测试机器人是否有球腕关节% islimit测试机器人是否抵达关节极限% fkine前向运动学求解% ikine6s6旋转轴球腕关节机器人的逆向运动学求解%ikine33旋转轴机器人的逆向运动学求解% ikine采用迭代方法的逆向运动学求解%jacobO在世界坐标系描述的雅克比矩阵%jacobn在工具坐标系描述的雅克比矩阵% maniplty 可操纵性度% jtraj关节空间轨迹% accel关节加速度% coriolis关节柯氏力% dyn显示连杆的动力学属性% fdyn关节运动% friction摩擦力% gravload关节重力% inertia关节惯性矩阵% nofriction 设置摩擦力为0% rne关节的力/力矩% payload在末端坐标系增加负载% perturb随机扰动连杆的动力学参数属性:% links连杆向量(lxN)% gravity 重力的方向gx gy gz% base 机器人基座的位姿(4x4)% tool机器人的工具变换矩阵T6 to tool tip (4x4)% qlim 关节范围qmin qmax (Nx2)% offset 偏置(Nxl)% name机器人名字(在图形中显示)% manuf注释,制造商名% comment 注释,总评% plotopt options for plot() method (cell array)% n 关节数% config机器人结构字符串,例如RRRRRR% mdh运动学中约定的布尔数(0=DH, 1=MDH)怎样创建一个机器人?%Link调用格式:%(1) L = Link()创建一个带默认参数的连杆(2) L = Link(Ll)复制连杆 L1(3) L = Link(OPTIONS)创建一个指定运动学、动力学参数的连杆OPTIONS可以是:% theta,TH joint angle, if not specified joint is revolute% d,D joint extension, if not specified joint is prismatic% a,A joint offset (default 0)% alpha,A joint twist (default 0)% standard defined using standard D&H parameters (default).% modified defined using modified D&H parameters.% offset,0 joint variable offset (default 0)% qlim,L joint limit (default )% I,I link inertia matrix (3x1, 6x1 or 3x3)% r,R link centre of gravity (3x1)% m,M link mass (lxl)% G,G motor gear ratio (default 0)% B,Bjoint friction, motor referenced (default 0)% Jm,Jmotor inertia, motor referenced (default 0)% Tc,T Coulomb friction, motor referenced (lxl or 2x1), (default 0 0)% revolute for a revolute joint (default)% prismatic for a prismatic joint p% standard for standard D&H parameters (default).% modified for modified D&H parameters.% sym consider all parameter values as symbolic not numeric 注:不能同时指定“theta 和“d”连杆的惯性矩阵(3x3)是对称矩阵,可以写成3x3矩阵,也可以是Ixx Iyy Izz Ixy IyzIxz所有摩擦均针对电机而不是负载 齿轮传动比只用于传递电机的摩擦力和惯性矩给连杆坐标系。%SerialLink调用格式:%(1 )R = SerialLink(LINKS, OPTIONS),OPTIONS 可以是:name、comment、manufacturer base、tool、gravity、plotopt(2) R = SerialLink(DH, OPTIONS),矩阵 DH 的构成:每个关节一行,每一行为theta d a alpha(默认为旋转关节),第五列(sigma)为可选列,sigma=0 (默认)为旋转关节,sigma=1 为移动关节(3) R = SerialLink(OPTIONS)没有连杆的机器人(4) R = SerialLink(Rl R2 ., OPTIONS)机器人连接,将R2的基座连接到R1的末端.(5) R = SerialLink(R1, options)复制机器人R1%L1 = Link(d, 0, a, 1, 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;%查看连杆数目 bot.fkine(0.1 0.2);% 前向运动学 bot.plot(0.1 0.2);% 绘制机器人定义完连杆和机器人便可以求机器人前和逆向运动学、动力学等等。L1.参数或属性():查看连杆的参数或属性L1.操作函数(参数):操作连杆参数bot .属性():查看机器人的属性bot .操作函数(参数):操作机器人,可以进行前向、逆向运动学求解等实例:Stanford ManipulatorD-H参数表:clear;Linkdia彳100902(h0+903沪000400-90y500+906血00沪clc;LI = Link(d, 0, a, 0, alpha, -pi/2);%定义连杆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 = Link(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)% 前向运动学bot =robot (6 axisj RRPRRR, stdDH)9- W- W r? -BS- 彳- 9| j | theta |d |a alpha10|!qs0|1qe|0|0|0!-1.5711.5719 -1.571 1.5710grav =0 base =1000tool =10000010001009.81001001000010001forward_kinematic50.0971-0.45330,88602-06310.9199-0.3806-0.09390 68780.37980.30600.4540104041&001.0000求出末端的齐次变换矩阵:clear;clc;LI = Link(d, 0, a, 0, alpha, -pi/2,sym);% 定义连杆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, 0, a, 0, alpha, pi/2,sym);L6 = Link(d, d6, a, 0, alpha, 0,sym);bot = SerialLink(Ll L2 L3 L4 L5 L6);% 连接连杆syms theta1 theta2 d3 theta4 theta5 theta6;forward_kinematics=bot.fkine(theta1 theta2 d3 theta4 theta5 theta6)% 前向运动学Stanford arm的运动学逆解:clear;clc;clear L%th d a alphaL(1) = Link( 000-pi/20);%定义连杆L(2) = Link( 010pi/20);L(3) = Link( 00001);L(4) = Link( 000-pi/20);L(5) = Link( 000pi/20);L(6) = Link( 01000);bot = SerialLink(L, name, Stanford arm);% 连接连杆T=transl(l,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_kinematics(5);theta6=inverse_kinematics(6);forward_kinematics=bot.fkine(theta1 theta2 d3 theta4 theta5 theta6)% 前向运动学, 验证结果的准确性.%求解结果为T与forward_kinematics 一致。正确。求解Stanford arm在世界坐标系描述的雅克比矩阵clear;clc;clear LL(1) = Link( 000-pi/20);%定义连杆L(2) = Link( 010pi/20);L(3) = Link( 00001);L(4) = Link( 000-pi/20);L(5) = Link( 000pi/20);L(6) = Link( 01000);bot = SerialLink(L, name, Stanford arm);% 连接连杆 syms theta1 theta2 d3 theta4 theta5 theta6;J0=vpa(bot.jacob0(theta1 theta2 d3 theta4 theta5 theta6),4) 求平面二自由度机器人在世界坐标系描述的雅克比矩阵%th d a alpha92?/oyiD-H参数表:Linkeoo00clear;clc;clear LL(l) = Link(d,O,a,al,alpha,O,sym);% 定义连杆L(2) = Link(d,0,a,a2,alpha,0,sym);bot = SerialLink(L, name, Planar 2-dof robot);% 连接连杆 syms theta1 theta2;J0=bot.jacob0(theta1 theta2);J0=simplify(J0)求得:J0 =-a2*sin(theta1 + theta2) - a1*sin(theta1), -a2*sin(theta1 + theta2)a2*cos(theta1 + theta2) + a1*cos(theta1), a2*cos(theta1 + theta2)0,00,00,01,1
展开阅读全文
相关资源
相关搜索

最新文档


当前位置:首页 > 办公文档 > 活动策划


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!