
目錄
1. Matlab機器人工具箱
2. 創建MDH單機械臂
3. 創建MDH雙臂機器人
UR構型雙臂
如何進行軌跡仿真
4. MDH-雙臂機器人
1. Matlab機器人工具箱
官方網站Robotics Toolbox | Peter Corke
下載,使用Matlab打開安裝即可

機械臂檔案SerialLink
2. 創建MDH單機械臂
clear;
clc;
%建立機器人模型
% theta d a alpha offset
% L1=Link([0 0.4 0.025 pi/2 0 -pi/2 ]); %定義連桿的D-H引數
% L2=Link([pi/2 0 0.56 0 0 pi/2 ]);
% L3=Link([0 0 0.035 pi/2 0 0 ]);
% L4=Link([0 0.515 0 pi/2 0 0 ]);
% L5=Link([pi 0 0 pi/2 0 0 ]);
% L6=Link([0 0.08 0 0 0 0 ]);
% theta | d | a | alpha | type| offset |
L(1)=Link([0 -72 150 0 0 pi/2 ],'modified'); % 關節1這里的最后一個量偏置
L(2)=Link([0 0 22 pi/2 0 -pi/2 ],'modified');
L(3)=Link([0 0 285 0 0 -pi/2 ],'modified');
L(4)=Link([0 220 3.5 -pi/2 0 0 ],'modified');
robot=SerialLink(L,'name',''); %連接連桿,機器人取名manman
robot.plot([-pi/2,-10*pi/180,-12*pi/180,0]);%輸出機器人模型,后面的角為輸出時的theta姿態
其中,Link、Seriallink等函式可參考官方API說明SerialLink
引數解釋
classdef Link < matlab.mixin.Copyable
properties
% kinematic parameters
theta % kinematic: link angle
d % kinematic: link offset
alpha % kinematic: link twist
a % kinematic: link length
jointtype % revolute='R', prismatic='P' -- should be an enum
mdh % standard DH=0, MDH=1
offset % joint coordinate offset
name % joint coordinate name
flip % joint moves in opposite direction
% dynamic parameters
m % dynamic: link mass
r % dynamic: position of COM with respect to link frame (3x1)
I % dynamic: inertia of link with respect to COM (3x3)
Jm % dynamic: motor inertia
B % dynamic: motor viscous friction (1x1 or 2x1)
Tc % dynamic: motor Coulomb friction (1x2 or 2x1)
G % dynamic: gear ratio
qlim % joint coordinate limits (2x1)
end
創建實體
% Examples::
% A standard Denavit-Hartenberg link
% L3 = Link('d', 0.15005, 'a', 0.0203, 'alpha', -pi/2);
% since 'theta' is not specified the joint is assumed to be revolute, and
% since the kinematic convention is not specified it is assumed 'standard'.
%
% Using the old syntax
% L3 = Link([ 0, 0.15005, 0.0203, -pi/2], 'standard');
% the flag 'standard' is not strictly necessary but adds clarity. Only 4 parameters
% are specified so sigma is assumed to be zero, ie. the joint is revolute.
%
% L3 = Link([ 0, 0.15005, 0.0203, -pi/2, 0], 'standard');
% the flag 'standard' is not strictly necessary but adds clarity. 5 parameters
% are specified and sigma is set to zero, ie. the joint is revolute.
%
% L3 = Link([ 0, 0.15005, 0.0203, -pi/2, 1], 'standard');
% the flag 'standard' is not strictly necessary but adds clarity. 5 parameters
% are specified and sigma is set to one, ie. the joint is prismatic.
%
% For a modified Denavit-Hartenberg revolute joint
% L3 = Link([ 0, 0.15005, 0.0203, -pi/2, 0], 'modified');

3. 創建MDH雙臂機器人
參考知乎專欄:OpenRobotSL - 知乎、Matlab雙臂機器人建模仿真 - 知乎
實際上,如果就把雙臂中的每個臂當做單個的機械臂進行規劃,那么用matlab進行雙臂建模就沒有太大必要,只需要對每個單臂進行單獨規劃即可,但是,如果涉及到雙臂之間的協同軌跡規劃,如上圖所示,這時用matlab進行雙臂建模仿真就會顯得事半功倍,本文先只介紹雙臂在matlab中的正運動學建模,后續會補充在matlab中如何進行雙臂軌跡規劃,
具體創建雙臂機器人程序如下文所示,詳細請移步該文章查看Matlab雙臂機器人建模仿真 - 知乎
此時腰關節連桿坐標系就是基坐標系X0Y0Z0,此時的肩關節坐標系X2Y2Z2就是單臂機器人的基坐標系,然后就從肩關節坐標系開始建立單臂的DH坐標系,也可以認為是單獨的腰關節連桿坐標系+單臂的DH坐標系,需要注意的是建立整體DH坐標系時腰關節與肩關節之間需要加-pi/2角度偏置,目的是將puma560構型的機械臂垂下去,下圖中的虛線X2即為不加偏置的肩關節坐標系,實線X2即為加了偏置角度后的肩關節坐標系,d=肩寬/2,
對應的matlab正運動學仿真如下所示:
腰關節與肩關節之間也可以不加偏置角度,這樣的話,兩個坐標系之間的轉換就可以畫成如下所示,
對應的matlab正運動學仿真如下所示:
UR構型雙臂
本文UR采用標準DH建模,建模程序全網可搜,標準DH坐標系建立如下,
分析上圖,黑色坐標系X0Y0Z0是世界坐標系,也可認為這是腰關節坐標系,紅色虛線坐標系X1Y1Z1是肩關節坐標系(也就是UR的基坐標系{0}),此時腰關節與肩關節不存在角度偏置,matlab仿真建模就是如下所示
亮藍色實線坐標系X1Y1Z1是加了pi/2偏置角度后的肩關節坐標系,matlab建模仿真如下所示
如何進行軌跡仿真
進行軌跡仿真的最重要一點就是,如何將世界(全域坐標系)坐標系下(也為腰關節坐標系)的軌跡映射到肩關節坐標系(機械臂的基坐標系)下,弄明白這一點,使用matlab進行雙臂軌跡演算法驗證就簡單很多了~
以PUMA560腰關節與肩關節有-pi/2角度偏置的雙臂構型為例,如下圖所示,
世界(全域,也為腰關節)坐標系下的位姿表示為$^0_{n}T$,這就是我們演算法驗證時所給定的軌跡位姿,都是相對于世界坐標系的;現在的問題就是,將軌跡位姿映射到肩關節(機械臂基坐標系)下,也就是求$^2_{n}T$,這個就很簡單了,即$^2_{n}T=inv(^0_{2}T)^0_{n}T$,$^0_{2}T$即為單臂基坐標系相對于腰關節坐標系的姿態變換矩陣,根據腰關節和肩關節之間的坐標變換,可以分析得出,腰關節坐標系先繞X1軸(自己的)旋轉pi/2,再繞動軸Z1旋轉-pi/2,最后再沿著動軸Z1移動d長度,故$^0_{2}T=trotx(90)trotz(-90)*transz(d)$,按照上述步驟即可將全域坐標系下的位姿映射到單臂區域坐標系下了,
4. MDH-雙臂機器人

4軸雙臂機器人MDH引數表格

代碼示例
% 2021年9月9日
% 雙臂飛行機器人,機械臂4Dof運動學模型及作業空間繪制
% haowanghk@gmail.com
clear all;
clc;
% theta | d | a | alpha | type| offset |
L(1)=Link([0 -0.072 0.150 0 0 pi/2 ],'modified'); % 關節1這里的最后一個量偏置
L(2)=Link([0 0 0.022 pi/2 0 -pi/2 ],'modified');
L(3)=Link([0 0 0.285 0 0 -pi/2 ],'modified');
L(4)=Link([0 0.22 0.0035 -pi/2 0 0 ],'modified');
% L(5)=Link([0 0 0 -pi/2 0 ],'modified');
% L(6)=Link([0 0 0 pi/2 0 ],'modified');
% 0.262
p560L=SerialLink(L,'name','LEFT');
p560L.tool=[0 -1 0 0;
1 0 0 0;
0 0 1 0 ;
0 0 0 1;];
R(1)=Link([0 -0.072 -0.15 0 0 pi/2 ],'modified'); % 關節1這里的最后一個量偏置
R(2)=Link([0 0 0.022 pi/2 0 -pi/2 ],'modified');
R(3)=Link([0 0 0.285 0 0 -pi/2 ],'modified');
R(4)=Link([0 0.22 0.0035 -pi/2 0 0 ],'modified');
% R(5)=Link([0 0 0 -pi/2 0 ],'modified');
% R(6)=Link([0 0 0 pi/2 0 ],'modified');
% 0.262
p560R=SerialLink(R,'name','RIGHT');
p560R.tool=[0 -1 0 0;
1 0 0 0;
0 0 1 0 ;
0 0 0 1;];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% platform
platform=SerialLink([0 0 0 0],'name','platform','modified');%虛擬腰部關節
platform.base=[1 0 0 0;
0 1 0 0;
0 0 1 0 ;
0 0 0 1;]; %基座高度
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% R
pR=SerialLink([platform,p560R],'name','R'); % 單獨右臂模型,加裝底座
pR.display();
view(3)
hold on
grid on
axis([-1.5, 1.5, -1.5, 1.5, -1.0, 1.5])
pR.plot([0 pi/4 pi/4 0 0]) % 第一個量固定為0,目的是為了模擬腰關節,左臂下同
hold on
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% L
pL=SerialLink([platform,p560L],'name','L'); % 單獨左臂模型,加裝底座
pL.display();
pL.plot([0 -pi/4 pi/4 0 0])
hold on
右臂連桿引數表格

左臂連桿引數表格

創建結果

示教

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/299507.html
標籤:其他
下一篇:JAVA SE 8安裝與配置









