Basic foundation of robot simulation (Based on MATLAB)

一:基本变换

1. 平移: T=transl(0.5,0,0)%分别沿着xyz轴的平移## 标题

>> T=transl(0.5,0,0)  %x方向平移0.5个单位长度

T =

1.0000         0         0    0.5000
     0    1.0000         0         0
     0         0    1.0000         0
     0         0         0    1.0000

2.旋转:

(1)得到3x3阶矩阵: rotx(a) roty(b) rotz©%分别绕xyz轴的旋转

>> T = roty(pi/2)

T =

0.9996         0    0.0274
     0    1.0000         0

-0.0274 0 0.9996

(2)得到4x4阶矩阵:trotx(a) troty(b) trotz©%分别绕xyz轴的旋转

>> trotx(pi/2)

ans =

1.0000         0         0         0
     0    0.9996   -0.0274         0
     0    0.0274    0.9996         0
     0         0         0    1.0000

3.复合变换: 平移加旋转

>> trotx(pi/2)

ans =

1.0000         0         0         0
     0    0.9996   -0.0274         0
     0    0.0274    0.9996         0
     0         0         0    1.0000

二:创建机器人对象

1.Link类

A Link object holds all information related to a robot joint and link such as kinematics parameters, rigid-body inertial parameters, motor and transmission parameters.

1.1 Link类相应函数:

A               连杆变换矩阵

RP            关节类型: 'R' 或 'P'
friction      摩擦力
nofriction    摩擦力忽略
dyn           显示动力学参数
islimit       测试关节是否超出软限制

isrevolute    测试是否为旋转关节

isprismatic   测试是否为移动关节
display       连杆参数以表格形式显示
char          转为字符串

1.2 link类的运动学,动力学属性参数

  theta    关节角度

  d        连杆偏移量
  a        连杆长度
  alpha    连杆扭角
  sigma    旋转关节为0,移动关节为1
  mdh      标准的D&H为0,否则为1
  offset   关节变量偏移量(例如绕Z轴的旋转量)
  qlim     关节变量范围[min max]

  m: 质量 
  r: 质心 
  I: 惯性张量 
  B: 粘性摩擦 
  Tc: 静摩擦 
  G: 减速比 
  Jm: 转子惯量

2.SerialLink类

定义:A concrete class that represents a serial-link arm-type robot. Each link and joint in the chain is described by a Link-class object using Denavit-Hartenberg parameters (standard or modified).

2.1 SerialLink相应函数:

SerialLink(L1 … Ln) 建立机器人关节连接

plot(theta)显示机器人图形(theta=[x0 … xn])x为关节变量,如角度

2.2 SerialLink的相应属性:

links :连杆向量 
gravity :重力加速度 
base :基座标系 
tool:与基座标系的变换矩阵 
qlim :关节极限位置 
offset :关节偏移量 
name :机器人的名字 
manuf :制造者的名字 
comment: 注释

n :关节数 
config: 关节配置,如‘RRRRRR’ 
mdh :D-H矩阵类型 
theta :D-H参数 
d :D-H参数 
a :D-H参数 
alpha: D-H参数

3. 建立机器人

3.1 第一种建立方式(标准DH)

  %定义机器人关节连杆参数,默认为标准DH
    L1 = Link('d', 0, 'a', 0, 'alpha', pi/2);
    L2 = Link('d', 0, 'a', 0.5, 'alpha', 0,'offset',pi/2);
    L3 = Link('d', 0, 'a', 0, 'alpha', pi/2,'offset',pi/4);
    L4 = Link('d', 1, 'a', 0, 'alpha', -pi/2);
    L5 = Link('d', 0, 'a', 0, 'alpha', pi/2);
    L6 = Link('d', 1, 'a', 0, 'alpha', 0);
    robot=SerialLink([L1,L2,L3,L4,L5,L6]); %用定义好的关节建立机器人
    robot.display();  %显示建立的机器人的DH参数
    theta=[0 0 0 0 0 0]; 	%6个关节的角度变量值都设为0,可以更改
    robot.plot(theta); 	%显示机器人的图像

此处一直没有成功用此方式调出改进型dh,希望知道的大神能告知一下

3.2 第二种建立方式(标准DH和改进DH)

L1 =  Link([ pi/4, 0, 0, 0, 0], 'modified');
L2 =  Link([ pi/2, 0.2, 0.1, 0 ,0], 'modified');
L3 =  Link([ 0, 0.1, 0.2, 0 ,0], 'modified');
robot=SerialLink([L1,L2,L3]); %用定义好的关节建立机器人
robot.display();  %显示建立的机器人的DH参数
theta=[0 0 0]; 	%6个关节的角度变量值都设为0,可以更改
robot.plot(theta); 	%显示机器人的图像

此处Link语法为:

 L = Link(DH, OPTIONS)
            %  - DH = [THETA D A ALPHA SIGMA OFFSET] where SIGMA=0 for a revolute and 1
            %    for a prismatic joint; and OFFSET is a constant displacement between the
            %    user joint variable and the value used by the kinematic model.
            %  - DH = [THETA D A ALPHA SIGMA] where OFFSET is zero.
            %  - DH = [THETA D A ALPHA], joint is assumed revolute and OFFSET is zero.

但theta的值在定义时我改变后没有效果,而在下方的theta=[0 0 0]中可以通过改变0的值改变相应的theta值

3.3 标准型DH和改进型DH的区别
在这里插入图片描述

作者:陈记小铺
来源:CSDN
原文:https://blog.csdn.net/qq_27170195/article/details/79918359
版权声明:本文为博主原创文章,转载请附上博文链接!

猜你喜欢

转载自blog.csdn.net/qq_37761964/article/details/89553675