s matlab toolbox,Matlab Robotic Toolbox工具箱学习笔记(一 )
Matlab Robotic Toolbox工具箱學(xué)習(xí)筆記(一)
軟件:matlab2013a
工具箱:Matlab Robotic Toolbox v9.8
Matlab Robotic Toolbox工具箱學(xué)習(xí)筆記根據(jù)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軸旋轉(zhuǎn)pi/2得到的旋轉(zhuǎn)矩陣
(1)r = rotx(pi/2);
%matlab默認(rèn)的角度單位為弧度,這里可以用度數(shù)作為單位
(2)R = rotx(30, 'deg') * roty(50, 'deg') * rotz(10,
'deg');
%求出R等效的任意旋轉(zhuǎn)變換的旋轉(zhuǎn)軸矢量vec和轉(zhuǎn)角theta
(3)[theta,vec] = tr2angvec(R);
%旋轉(zhuǎn)矩陣用歐拉角表示,R = rotz(a)*roty(b)*rotz(c)
(4)eul = tr2eul(R);
%旋轉(zhuǎn)矩陣用roll-pitch-yaw角表示, R = rotx(r)*roty(p)*rotz(y)
(5)rpy = tr2rpy(R);
%旋轉(zhuǎn)矩陣用四元數(shù)表示
(6)q = Quaternion(R);
%將四元數(shù)轉(zhuǎn)化為旋轉(zhuǎn)矩陣
(7)q.R;
%界面,可以是“rpy”,“eluer”角度單位為度。
(8)tripleangle('rpy');
General/Transformations
%沿x軸平移0.5,繞y軸旋轉(zhuǎn)pi/2,繞z軸旋轉(zhuǎn)-pi/2
(1)t = transl(0.5, 0.0, 0.0) * troty(pi/2)
* trotz(-pi/2)
%將齊次變換矩陣轉(zhuǎn)化為歐拉角
(2)tr2eul(t)
%將齊次變換矩陣轉(zhuǎn)化為roll、pitch、yaw角
(3) tr2rpy(t)
General/Trajectory
clear;
clc;
p0 = -1;% 定義初始點(diǎn)及終點(diǎn)位置
p1 = 2;
p = tpoly(p0, p1, 50);% 取步長(zhǎng)為50
figure(1);
plot(p);%繪圖,可以看到在初始點(diǎn)及終點(diǎn)的一、二階導(dǎo)均為零
[p,pd,pdd] = tpoly(p0, p1, 50);%得到位置、速度、加速度
%p為五階多項(xiàng)式,速度、加速度均在一定范圍內(nèi)
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);
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)
%對(duì)于齊次變換矩陣的情況
T0 = transl(0.4, 0.2, 0) * trotx(pi);% 定義初始點(diǎn)和目標(biāo)點(diǎn)的位姿
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);%第十個(gè)位姿矩陣
figure(5);
tranimate(T);%動(dòng)畫(huà)演示坐標(biāo)系自初始點(diǎn)運(yùn)動(dòng)到目標(biāo)點(diǎn)的過(guò)程
總結(jié)
以上是生活随笔為你收集整理的s matlab toolbox,Matlab Robotic Toolbox工具箱学习笔记(一 )的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: php 订单过期处理,PHP实现处理过期
- 下一篇: php pg connect,pg_co