Matlab Robotic Toolbox工具箱学习笔记(一)

Matlab Robotic Toolbox工具箱学习笔记(一)

软件:matlab2013a

工具箱:Matlab Robotic Toolbox v9.8

Matlab Robotic Toolbox工具箱学习笔记根据Robot Toolbox demonstrations目录,将分三大部分阐述:

1、General(Rotations,Transformations,Trajectory)

2、Arm(Robot,Animation,Forwarw kinematics,Inverse kinematics,Jacobians,Inverse dynamics,Forward dynamics,Symbolic,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)[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);

%旋转矩阵用四元数表示

[学习笔记]Matlab <wbr>Robotic <wbr>Toolbox工具箱学习笔记(一)
[学习笔记]Matlab <wbr>Robotic <wbr>Toolbox工具箱学习笔记(一)
(6)q = Quaternion(R);

%将四元数转化为旋转矩阵

(7)q.R;

 %界面,可以是“rpy”,“eluer”角度单位为度。
(8)tripleangle('rpy');

[学习笔记]Matlab <wbr>Robotic <wbr>Toolbox工具箱学习笔记(一)
General/Transformations

%沿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/Trajectory

clear;
clc;
p0 = -1;% 定义初始点及终点位置
p1 = 2;
p = tpoly(p0, p1, 50);% 取步长为50
figure(1);
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');
[学习笔记]Matlab <wbr>Robotic <wbr>Toolbox工具箱学习笔记(一)

%另外一种方法:
[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');% 可以看到速度是呈梯形
subplot(3,1,3); plot(pdd); xlabel('Time'); ylabel('pdd');

[学习笔记]Matlab <wbr>Robotic <wbr>Toolbox工具箱学习笔记(一)

%三维的情况:
p = mtraj(@tpoly, [0 1 2], [2 1 0], 50);
figure(4);
plot(p)
[学习笔记]Matlab <wbr>Robotic <wbr>Toolbox工具箱学习笔记(一)

%对于齐次变换矩阵的情况
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);%动画演示坐标系自初始点运动到目标点的过程

  • 8
    点赞
  • 61
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值