五连杆机械臂求正解逆解

本文详细介绍了五连杆机器人基于D-H参数的正解和逆解算法。正解通过D-H参数计算关节旋转角度与平移距离之间的关系,而逆解则从末端坐标和欧拉角出发,求解各关节角度。通过建立数学模型并利用矩阵变换,最终得出关节角度的解析解。这种方法对于理解机器人运动学和控制系统设计具有重要意义。
摘要由CSDN通过智能技术生成
D-H参数表
+---+-----------+-----------+-----------+-----------+-----------+
| j |     theta |         d |         a |     alpha |    offset |
+---+-----------+-----------+-----------+-----------+-----------+
|  1|         q1|         0|         L1|     1.5708|          0|
|  2|         q2|          0|       L2|          0|          0|
|  3|         q3|          0|       L3|          0|          0|
|  4|         q4|          0|        L4|     1.5708|          0|
|  5|         q5|          0|        L5|          0|          0|
+---+-----------+-----------+-----------+-----------+-----------+

在这里插入图片描述

五连杆如图所示
正解用D-H参数相乘

L1=0.5; L2=0.7;L3=0.8;L4=0.7;L5=0.5;
p1 = [pi/4 0 L1  pi/2]; 
p2 = [pi/4 0 L2 0];
p3 = [pi/4 0 L3 0];
p4 = [0 0 L4  pi/2]; 
p5 = [pi/4 0 L5 0];

para = [p1;p2;p3;p4;p5];
pos = fk(para)

function T = fk(links)
    %正解
    %已知关节角求变换矩阵
    %  theta        kinematic: joint angle  绕Z轴旋转角度
    %  d            kinematic: link offset  绕Z轴平移距离
    %  a            kinematic: link length  绕X轴平移距离
    %  alpha        kinematic: link twist   绕X轴旋转角度

    T=diag([1 1 1 1]);   %单位阵
    si=size(links);  
    
    for i=1:si(1)   %行数
        T_link=T_para(links(i,:));
        T=T*T_link;
    end
end
function T = T_para(p)
%由连杆参数转化为转化矩阵
%theta:绕Z轴旋转角度; a:绕X轴平移距离; d:绕Z轴平移距离; alpha:绕X轴旋转角度
%返回4维矩阵
theta=p(1);d=p(2);a=p(3);alpha=p(4);
    T=[cos(theta),-sin(theta)*cos(alpha),sin(theta)*sin(alpha),a*cos(theta);
        sin(theta),cos(theta)*cos(alpha),-cos(theta)*sin(alpha),a*sin(theta);
        0,sin(alpha),cos(alpha),d;
        0,0,0,1];
end

逆解就解方程了

已知末端坐标及欧拉角和杆长 x y z R P Y L1 L2 L3 L4 L5  求五杆的转角 th1 th2 th3 th4 th5
 为了减少变量个数,alpha及 offset作为已知参数给出
由末端坐标及欧拉角求得末端的变换矩阵 T
[ cos(P)*cos(Y), cos(Y)*sin(P)*sin(R) - cos(R)*sin(Y), sin(R)*sin(Y) + cos(R)*cos(Y)*sin(P), x]
[ cos(P)*sin(Y), cos(R)*cos(Y) + sin(P)*sin(R)*sin(Y), cos(R)*sin(P)*sin(Y) - cos(Y)*sin(R), y]
[       -sin(P),                        cos(P)*sin(R),                        cos(P)*cos(R), z]
[             0,                                    0,                                    0, 1]

%连杆参数
p1 = [th1 0 L1 pi/2]; 
p2 = [th2 0 L2 0];
p3 = [th3 0 L3 0];
p4 = [th4 0 L4  pi/2]; 
p5 = [th5 0 L5 0];
%转化矩阵
T1 = T_para(p1);
T2 = T_para(p2);
T3 = T_para(p3);
T4 = T_para(p4);
T5 = T_para(p5);

%T1的逆设为T1_inv ,其余类比
T1_inv = inv(T1 )
T5_inv = inv(T5);

由 T = T1*T2*T3*T4*T5
T1_inv  * T = T2*T3*T4*T5
T1_inv  * T  = 
[  cos(P)*cos(Y - th1),   sin(th1)*(cos(R)*cos(Y) + sin(P)*sin(R)*sin(Y)) - cos(th1)*(cos(R)*sin(Y) - cos(Y)*sin(P)*sin(R)), cos(th1)*(sin(R)*sin(Y) + cos(R)*cos(Y)*sin(P)) - sin(th1)*(cos(Y)*sin(R) - cos(R)*sin(P)*sin(Y)), x*cos(th1) - L1 + y*sin(th1)]
[              -sin(P),                                                                                       cos(P)*sin(R),                                                                                     cos(P)*cos(R),                            z]
[ -cos(P)*sin(Y - th1), - cos(th1)*(cos(R)*cos(Y) + sin(P)*sin(R)*sin(Y)) - sin(th1)*(cos(R)*sin(Y) - cos(Y)*sin(P)*sin(R)), cos(th1)*(cos(Y)*sin(R) - cos(R)*sin(P)*sin(Y)) + sin(th1)*(sin(R)*sin(Y) + cos(R)*cos(Y)*sin(P)),      x*sin(th1) - y*cos(th1)]
[                    0,                                                                                                   0,                                                                                                 0,                            1]
 
 T2*T3*T4*T5=
[ cos(th2 + th3 + th4)*cos(th5), -cos(th2 + th3 + th4)*sin(th5),  sin(th2 + th3 + th4), L3*cos(th2 + th3) + L2*cos(th2) + L4*cos(th2 + th3)*cos(th4) - L4*sin(th2 + th3)*sin(th4) - L5*cos(th5)*(sin(th2 + th3)*sin(th4) - cos(th2 + th3)*cos(th4))]
[ sin(th2 + th3 + th4)*cos(th5), -sin(th2 + th3 + th4)*sin(th5), -cos(th2 + th3 + th4), L3*sin(th2 + th3) + L2*sin(th2) + L4*cos(th2 + th3)*sin(th4) + L4*sin(th2 + th3)*cos(th4) + L5*cos(th5)*(cos(th2 + th3)*sin(th4) + sin(th2 + th3)*cos(th4))]
[                      sin(th5),                       cos(th5),                     0,                                                                                                                                                 L5*sin(th5)]
[                             0,                              0,                     0,                                                                                                                                                           1]

 
 由两者三行四列相等:
   L5*sin(th5) =  x*sin(th1) - y*cos(th1)
求得th1与th5关系

 由两者1行1列与2行1列 得到
 sin(th2 + th3 + th4) =    -sin(P)/cos(th5)
 cos(th2 + th3 + th4) =  cos(P)*cos(Y - th1) / cos(th5);
由于 sin(th2 + th3 + th4)与 cos(th2 + th3 + th4) 有多种表示方式,在此取不包含R的表达式

又有   T1_inv  * T* T5_inv  = T2*T3*T4
T1_inv  * T* T5_inv = 
[ sin(th5)*(cos(th1)*(cos(R)*sin(Y) - cos(Y)*sin(P)*sin(R)) - sin(th1)*(cos(R)*cos(Y) + sin(P)*sin(R)*sin(Y))) + cos(P)*cos(th5)*cos(Y - th1),   cos(P)*sin(th5)*cos(Y - th1) - cos(th5)*(cos(th1)*(cos(R)*sin(Y) - cos(Y)*sin(P)*sin(R)) - sin(th1)*(cos(R)*cos(Y) + sin(P)*sin(R)*sin(Y))), cos(th1)*(sin(R)*sin(Y) + cos(R)*cos(Y)*sin(P)) - sin(th1)*(cos(Y)*sin(R) - cos(R)*sin(P)*sin(Y)), x*cos(th1) - L5*(cos(P)*cos(Y)*cos(th1) + cos(P)*sin(Y)*sin(th1)) - L1 + y*sin(th1)]
[                                                                                                  - sin(P)*cos(th5) - cos(P)*sin(R)*sin(th5),                                                                                                      cos(P)*sin(R)*cos(th5) - sin(P)*sin(th5),                                                                                     cos(P)*cos(R),                                                                       z + L5*sin(P)]
[ sin(th5)*(cos(th1)*(cos(R)*cos(Y) + sin(P)*sin(R)*sin(Y)) + sin(th1)*(cos(R)*sin(Y) - cos(Y)*sin(P)*sin(R))) - cos(P)*cos(th5)*sin(Y - th1), - cos(th5)*(cos(th1)*(cos(R)*cos(Y) + sin(P)*sin(R)*sin(Y)) + sin(th1)*(cos(R)*sin(Y) - cos(Y)*sin(P)*sin(R))) - cos(P)*sin(th5)*sin(Y - th1), cos(th1)*(cos(Y)*sin(R) - cos(R)*sin(P)*sin(Y)) + sin(th1)*(sin(R)*sin(Y) + cos(R)*cos(Y)*sin(P)),      x*sin(th1) - y*cos(th1) - L5*(cos(P)*cos(Y)*sin(th1) - cos(P)*sin(Y)*cos(th1))]
[                                                                                                                                           0,                                                                                                                                             0,                                                                                                 0,                                                                                   1]
 
 T2*T3*T4 = 
[ cos(th2 + th3 + th4), 0,  sin(th2 + th3 + th4), L3*cos(th2 + th3) + L2*cos(th2) + L4*cos(th2 + th3 + th4)]
[ sin(th2 + th3 + th4), 0, -cos(th2 + th3 + th4), L3*sin(th2 + th3) + L2*sin(th2) + L4*sin(th2 + th3 + th4)]
[                    0, 1,                     0,                                                         0]
[                    0, 0,                     0,                                                         1]

由两者三行四列相等:
x*sin(th1) - y*cos(th1) - L5*(cos(P)*cos(Y)*sin(th1) - cos(P)*sin(Y)*cos(th1)) = 0
则 th1 = atan( (y-L5*cos(P)*sin(Y))/(x-L5*cos(P)*cos(Y)) ) 
所以  th5=asin( (x*sin(th1)-y*cos(th1)) / L5);

因为五杆只有五个转动副,理应只能控制五个未知量,所以一个末端坐标应该由其它表示
由两者二行二列相等
 cos(P)*sin(R)*cos(th5) - sin(P)*sin(th5) = 0
 得到 R =asin( sin(P)*sin(th5)/cos(P)/cos(th5) );
在此可以得到R,但由于sinR已知时 cosR有双解 所以不使用存在cosR的等式

 由二者1行4列与2行4列 联立解方程
 L3*cos(th2 + th3) + L2*cos(th2) + L4*cos(th2 + th3 + th4) =   x*cos(th1) - L5*(cos(P)*cos(Y)*cos(th1) + cos(P)*sin(Y)*sin(th1)) + y*sin(th1)
  L3*sin(th2 + th3) + L2*sin(th2) + L4*sin(th2 + th3 + th4) =   z - L1 + L5*sin(P)
令
m1 = z - L1  + L5*sin(P) - L4* sin(th2 + th3 + th4) ;
n1=x*cos(th1) - L5*(cos(P)*cos(Y)*cos(th1) + cos(P)*sin(Y)*sin(th1)) + y*sin(th1) - L4*cos(th2 + th3 + th4);

方程简化为
m1 - L2*sin(th2) = L3*sin(th2 + th3)
n1 -  L2*cos(th2) = L3*cos(th2 + th3)
两边平方相加,得
2*m1*L2*sin(th2) + 2*n1*L2*cos(th2) =m1*m1+n1*n1+L2*L2 - L3*L3
令:
m2=2*m1*L2;
n2=2*n1*L2;
k=m1^2+n1^2+L2^2-L3^2;
解这个方程,可以通过平方消去sin或者cos,如果消去的是sin,则使用acos可以求得th2,得到
th2 =acos(( 2*n2*k-sqrt(4*n2^2*k^2-4*(k^2-m2^2)*(m2^2+n2^2)) ) / ( 2*(m2^2+n2^2) ));
或者 th2 =acos(( 2*n2*k + sqrt(4*n2^2*k^2-4*(k^2-m2^2)*(m2^2+n2^2)) ) / ( 2*(m2^2+n2^2) ));
求解th3与th4时同样使用acos,这样使用求解角度范围在0~pi是唯一的
再代入方程,得
 th3 =acos((n1 - L2*cos(th2))/L3) -th2;
 th4=acos(cos234)-th2-th3; %cos234为 cos(th2 + th3 + th4) 
求解完毕

则可以由 x y z  P Y 求五杆的转角 th1 th2 th3 th4 th5
有多解 ,而此处没有讨论角度范围,所以该方法适合求解角度范围在0~pi

如果消去的是cos,则使用asin可以求得th2,
det =4*m2^2*k^2-4*(k^2-n2^2)*(m2^2+n2^2);
th2(1) =asin(( 2*m2*k-sqrt(det) ) / ( 2*(m2^2+n2^2) ));
th2(2) =asin(( 2*m2*k+sqrt(det) ) / ( 2*(m2^2+n2^2) ));
th3 =asin((m1 -L2*sin(th2))/L3) -th2;
th4=asin(sin234)-th2-th3;
c= [th1,th2(1),th3(1),th4(1),th5];
该方法适合求解角度范围在-pi/2~pi/2
  • 1
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 自由度机械臂的正运动学计算公式如下: 设机械臂个关节分别为θ1、θ2、θ3、θ4、θ5,机械臂末端执行器的位置为(x,y,z),末端执行器的姿态用三个欧拉角α、β、γ表示。则正运动学计算公式为: x = a5 * cos(θ1+θ2+θ3+θ4+θ5) * cos(α) - d4 * sin(θ1+θ2+θ3+θ4+θ5) * sin(α) + a4 * cos(θ1+θ2+θ3+θ4) * cos(α) - d3 * sin(θ1+θ2+θ3+θ4) * sin(α) + a3 * cos(θ1+θ2+θ3) * cos(α) - d2 * sin(θ1+θ2+θ3) * sin(α) + a2 * cos(θ1+θ2) * cos(α) - d1 * sin(θ1+θ2) * sin(α) + a1 * cos(θ1) * cos(α) y = a5 * cos(θ1+θ2+θ3+θ4+θ5) * sin(α) + d4 * sin(θ1+θ2+θ3+θ4+θ5) * cos(α) + a4 * cos(θ1+θ2+θ3+θ4) * sin(α) + d3 * sin(θ1+θ2+θ3+θ4) * cos(α) + a3 * cos(θ1+θ2+θ3) * sin(α) + d2 * sin(θ1+θ2+θ3) * cos(α) + a2 * cos(θ1+θ2) * sin(α) + d1 * sin(θ1+θ2) * cos(α) + a1 * cos(θ1) * sin(α) z = a5 * sin(θ1+θ2+θ3+θ4+θ5) + d4 * cos(θ1+θ2+θ3+θ4+θ5) + a4 * sin(θ1+θ2+θ3+θ4) + d3 * cos(θ1+θ2+θ3+θ4) + a3 * sin(θ1+θ2+θ3) + d2 * cos(θ1+θ2+θ3) + a2 * sin(θ1+θ2) + d1 * cos(θ1+θ2) + a1 * sin(θ1) 其中,a1~a5为机械臂每个关节的长度,d1~d4为机械臂每个关节的偏移量,α为末端执行器相对于机械臂最后一个关节的姿态角度。 ### 回答2: 自由度机械臂的正运动学计算公式是用来计算机械臂末端执行器在给定关节角度下的位置和姿态的数学公式。这里,我们以一个典型的自由度机械臂为例,给出其正运动学计算公式。 假设机械臂个关节分别为j1、j2、j3、j4和j5,分别对应的关节角度为Θ1、Θ2、Θ3、Θ4和Θ5,末端执行器在笛卡尔坐标系下的位置为(x, y, z),姿态为(α, β, γ),这里α表示绕x轴旋转的角度,β表示绕y轴旋转的角度,γ表示绕z轴旋转的角度。 机械臂的正运动学计算公式可以分为两部分,一部分是机械臂的位置计算,另一部分是姿态计算。 位置计算部分可以使用正弦定理和余弦定理来计算。具体公式如下: x = a1 * cos(Θ1) + a2 * cos(Θ1 + Θ2) + a3 * cos(Θ1 + Θ2 + Θ3) y = a1 * sin(Θ1) + a2 * sin(Θ1 + Θ2) + a3 * sin(Θ1 + Θ2 + Θ3) z = d1 + d2 + d3 姿态计算部分可以使用旋转矩阵来计算。具体公式如下: R = Rot_z(γ) * Rot_y(β) * Rot_x(α) 其中Rot_x(α)、Rot_y(β)和Rot_z(γ)分别表示绕x轴、y轴和z轴旋转的旋转矩阵。 最后,将位置和姿态结合起来,得到机械臂末端执行器在给定关节角度下的位置和姿态: T = [x, y, z, α, β, γ] ### 回答3: 自由度机械臂的正运动学计算公式可以通过以下方式得到。 首先,我们需要定义每个关节的长度和偏移量,用L1、L2、L3、L4、L5表示,然后定义每个关节的角度,用θ1、θ2、θ3、θ4、θ5表示。 正运动学计算公式可以通过DH(Denavit-Hartenberg)参数表达。DH参数是一种常用的表示坐标转换关系的方法。 我们首先定义坐标系,每个关节之间有一个坐标系。 首先,我们定义基座标系O0XYZ,与地面平面重合,X轴指向前方,Y轴指向左方,Z轴指向上方。 然后,我们定义第一个关节的坐标系O1Z1YZ0X,Z1轴与O0Z轴重合,Y1轴与O0Y轴垂直,指向左侧。 接下来,我们定义第二个关节的坐标系O2Z2Y2Z1,Z2轴与O1Z1轴重合,Y2与O1Y1轴垂直。 然后,我们定义第三个关节的坐标系O3Z3Y3Z2,Z3轴与O2Z2轴重合,Y3与O2Y2轴垂直。 接着,我们定义第四个关节的坐标系O4Z4Y4Z3,Z4轴与O3Z3轴重合,Y4与O3Y3轴垂直。 最后,我们定义第个关节的坐标系O5Z5Y5Z4,Z5轴与O4Z4轴重合,Y5与O4Y4轴平行。 通过定义这些坐标系和坐标变换矩阵,我们可以得到正运动学计算公式,即: T = T01 * T12 * T23 * T34 * T45 * T5E 其中,T01到T5E分别是从基座标系到每个关节坐标系的变换矩阵,T表示从基座标系到末端执行器的变换矩阵。 具体的计算公式可以通过坐标变换矩阵的乘法来得到,这些计算公式是基于DH 参数表和坐标变换矩阵的定义推导得出的。 通过这个正运动学计算公式,我们可以根据给定的关节角度和DH参数来计算出机械臂末端执行器的位置和姿态。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值