[Matlab six-degree-of-freedom robot] kinematics positive solution (with complete code of MATLAB robot positive solution)

Past review

【Summary】

related resources:

Summary of [Matlab Six Degrees of Freedom Robot] Series Articles \fcolorbox{green}{aqua}{[Matlab Six Degrees of Freedom Robot] Series Article Summary }[ M a t l a b six degrees of freedom robot ] series of articles   summary

【Main line】

  1. Define standard and improved DH parameters, and establish a robot model.
  2. Correct solution of kinematics
  3. Construction of Robot Workspace Based on Monte Carlo Method

【Supplementary explanation】

  1. Understanding of Flexible Workspaces and Accessible Workspaces
  2. Detailed establishment steps of modified DH parameters (modified Denavit-Hartenberg)
  3. Questions about parameterization of rotation (Euler angles, attitude angles, quaternions)
  4. The Explanation of Double Variable Function atan2(x,y)
  5. Some Problems Concerning Inverse Solution of Robot Kinematics

foreword

This article introduces the problems related to the positive solution of robot kinematics, how to understand the forward kinematics, and use the DH parameters to solve the positive solution of robot kinematics.


The following is the text of this article, including the understanding of the meaning of the positive solution and the step-by-step analysis of the code.

text

1. Correct solution of kinematics

Definition: Knowing the motion parameters of each joint, find the pose of the end effector relative to the reference coordinate system.

Solving steps:

  • The connecting rods are connected end to end;
  • Determine the homogeneous transformation matrix between the connecting rods;
  • Get the final total transformation matrix.

And the unknowns in the total transformation matrix are only theRotation angle, so the end Cartesian space coordinates of the six-DOF robot can be obtained by obtaining the rotation angle.

1. Homogeneous transformation matrix

In the previous article Matlab established a six-degree-of-freedom robot model, it explained in detail how to define the DH parameters of the robot and how to set zi z_{i}ziAxis, etc., only part of the content is described here.
Sign convention for DH parameters

DH Convention Parameters notation convention
i ii joint angle 关节转角
d d d link offset 连杆偏移
a a a link length 连杆长度
α ( alpha ) α(alpha)a ( a l p h a ) link twist 连杆扭角
Rules of procedure for formulating DH parameters
  • parameter aaa is axisz 0 z_{0}z0和轴z 1 z_{1}z1Between along the axis x 1 x_{1}x1the measured distance;
  • Angle α αα is perpendicular tox 1 x_{1}x1The axis z measured in the plane z 0 z_{0}z0sum z 1 z_{1}z1angle between. Angle α αThe positive value of α is defined as fromz 0 z_{0}z0to z 1 z_{1}z1, determined by the right-hand rule;
  • parameter ddd is from the origino 0 o_{0}o0to axis x 1 x_{1}x1give z 0 z_{0}z0the distance between intersection points along z 0 z_{0}z0The axis is measured;
  • i iθ is perpendicular toz 0 z_{0}z0Measured from x 0 in the plane of x_{0}x0to x 1 x_{1}x1Angle.

After understanding the above symbol conventions and program rules, on this basis, each homogeneous transformation matrix T i T_{i}Tican be expressed as a product of fundamental matrices,

  • 对于标准型D-H参数
    Thatproduct order如下:
    i − 1 T i = R o t ( z , θ i ) × T r a n s ( z , d i ) × T r a n s ( x , a i ) × R o t ( x , α i ) ^{i-1}T_i =Rot(z_,θ_i)×Trans(z,d_i)×Trans(x_,a_i)×Rot(x,α_i) i1Ti=Rot(z,ii)×Trans(zdi)×Trans(xai)×Rot(xαi)
    Universal homogeneous transformation matrixAs follows:
    i − 1 T i = ^{i-1}T_i =i1Ti= [ c o s θ i − s i n θ i c o s α i s i n θ i s i n α i a i c o s θ i s i n θ i c o s θ i c o s α i − c o s θ i s i n α i a i s i n θ i 0 s i n α i c o s α i d i 0 0 0 1 ] \left[ \begin{matrix} cosθ_i&-sinθ_icosα_i&sinθ_isinα_i&a_{i}cosθ_i \\ sinθ_i&cosθ_icosα_i&-cosθ_isinα_i&a_{i}sinθ_i\\ 0&sinα_i&cosα_i&d_{i} \\ 0&0&0&1 \end{matrix} \right] cosθisinθi00sinθic o s αicosθic o s αiI n α _i0sinθiI n α _icosθiI n α _ic o s αi0aicosθiaisinθidi1
  • 对于改进型D-H参数
    Thatproduct order如下:
    i − 1 T i = R o t ( x i , α i − 1 ) × T r a n s ( x i , a i − 1 ) × R o t ( z i , θ i ) × T r a n s ( z i , d i ) ^{i-1}T_i =Rot(x_{i},α_{i-1})×Trans(x_{i},a_{i-1})×Rot(z_{i},θ_i)×Trans(z_{i},d_i) i1Ti=Rot(xi, ai1)×Trans(xiai1)×Rot(zi,ii)×Trans(zidi)
    Universal homogeneous transformation matrixAs follows:
    i − 1 T i = ^{i-1}T_i =i1Ti= [ c o s θ i − s i n θ i 0 a i s i n θ i c o s α i c o s θ i c o s α i − s i n α i − s i n α i d i s i n θ i s i n α i c o s θ i s i n α i c o s α i c o s α i d i 0 0 0 1 ] \left[ \begin{matrix} cosθ_i&-sinθ_i&0&a_{i} \\ sinθ_icosα_{i}&cosθ_icosα_{i}&-sinα_{i}&-sinα_{i}d_{i} \\ sinθ_isinα_{i}&cosθ_isinα_{i}&cosα_{i}&cosα_{i}d_{i} \\ 0&0&0&1 \end{matrix} \right] cosθisinθic o s αisinθiI n α _i0sinθicosθic o s αicosθiI n α _i00- s i n αic o s αi0ai- s i n αidic o s αidi1

2. Total transformation

OKDH parameter establishment methodAfter constructing the DH parameters of each joint, they are substituted into their respective general homogeneous transformation matrices to obtain 0 T 1 ^{0}T_10 T1 1 T 2 ^{1}T_2 1T2 2 T 3 ^{2}T_3 2T _3 3 T 4 ^{3}T_4 3T _4 4 T 5 ^{4}T_5 4 T5 5 T 6 ^{5}T_6 5T6There are six matrices in total. Here the author chooses theImproved DH parameters, so the respective matrices are as follows:
0 T 1 = ^{0}T_1 =0 T1= [ cos θ 1 − sin θ 1 0 a 1 cos α 1 sin θ 1 cos α 1 cos θ 1 − sin α 1 − d 1 sin α 1 sin α 1 sin θ 1 sin α 1 cos θ 1 cos α 1 d 1 cos α 1 0 0 0 1 ] \left[ \begin{matrix} cos θ_1&-sinθ_1&0&a_1 \\ cosα_1sinθ_1&cosα_1cosθ_1&-sinα_1&-d_{1}sinα_1\\ sinα_{1}sinθ_1&sinα_{1}cosθ_1&cosα_{1}&d_{1}cosα_{1} \\ 0&0&0&1 \end{matrix} \right]cosθ1c o s α1sinθ1I n α _1sinθ10sinθ1c o s α1cosθ1I n α _1cosθ100- s i n α1c o s α10a1d1I n α _1d1c o s α11
1 T 2 = ^{1}T_2 = 1T2= [ cos θ 2 − sin θ 2 0 a 2 cos α 2 sin θ 2 cos α 2 cos θ 2 − sin α 2 − d 2 sin α 2 sin α 2 sin θ 2 sin α 2 cos θ 2 cos α 2 d 2 cos α 2 0 0 0 1 ] \left[ \begin{matrix} cos θ_2&-sinθ_2&0&a_2 \\ cosα_2sinθ_2&cosα_2cosθ_2&-sinα_2&-d_{2}sin_2\\ sinα_{2}sinθ_2&sinα_{2}cosθ_2&cosα_{2}&d_{2} cosα_{2}\\ 0&0&0&1 \end{matrix} \right]cosθ2c o s α2sinθ2I n α _2sinθ20sinθ2c o s α2cosθ2I n α _2cosθ200- s i n α2c o s α20a2d2I n α _2d2c o s α21
2 T 3 = ^{2}T_3 = 2T _3= [ cos θ 3 − sin θ 3 0 a 3 cos α 3 sin θ 3 cos α 3 cos θ 3 − sin α 3 − d 3 sin α 3 sin α 3 sin θ 3 sin α 3 cos θ 3 cos α 3 d 3 cos α 3 0 0 0 1 ] \left[ \begin{matrix} cos θ_3&-sinθ_3&0&a_3 \\ cosα_3sinθ_3&cosα_3cosθ_3&-sinα_3&-d_{3}sinα_3\\ sinα_{3}sinθ_3&sinα_{3}cosθ_3&cosα_{3}&d_{3} cosα_{3}\\ 0&0&0&1 \end{matrix} \right]cosθ3c o s α3sinθ3I n α _3sinθ30sinθ3c o s α3cosθ3I n α _3cosθ300- s i n α3c o s α30a3d3I n α _3d3c o s α31
3 T 4 = ^{3}T_4 = 3T _4= [ cos θ 4 − sin θ 4 0 a 4 cos α 4 sin θ 4 cos α 4 cos θ 4 − sin α 4 − d 4 sin α 4 sin α 4 sin θ 4 sin α 4 cos θ 4 cos α 4 d 4 cos α 4 0 0 0 1 ] \left[ \begin{matrix} cos θ_4&-sinθ_4&0&a_4 \\ cosα_4sinθ_4&cosα_4cosθ_4&-sinα_4&-d_{4}sin_4\\ sinα_{4}sinθ_4&sinα_{4}cosθ_4&cosα_{4}&d_{4} cosα_{4}\\ 0&0&0&1 \end{matrix} \right]cosθ4c o s α4sinθ4I n α _4sinθ40sinθ4c o s α4cosθ4I n α _4cosθ400- s i n α4c o s α40a4d4I n α _4d4c o s α41
4 T 5 = ^{4}T_5 = 4 T5= [ cos θ 5 − sin θ 5 0 a 5 cos α 5 sin θ 5 cos α 5 cos θ 5 − sin α 5 − d 5 sin α 5 sin α 5 sin θ 5 sin α 5 cos θ 5 cos α 5 d 5 cos α 5 0 0 0 1 ] \left[ \begin{matrix} cos θ_5&-sinθ_5&0&a_5 \\ cosα_5sinθ_5&cosα_5cosθ_5&-sin_5&-d_{5}sin_5\\ sinα_{5}sinθ_5&sinα_{5}cosθ_5&cosα_{5}&d_{5} cosα_{5}\\ 0&0&0&1 \end{matrix} \right]cosθ5c o s α5sinθ5I n α _5sinθ50sinθ5c o s α5cosθ5I n α _5cosθ500- s i n α5c o s α50a5d5I n α _5d5c o s α51
5 T 6 = ^{5}T_6 = 5T6= [ cos θ 6 − sin θ 6 0 a 6 cos α 6 sin θ 6 cos α 6 cos θ 6 − sin α 6 − d 6 sin α 6 sin α 6 sin θ 6 sin α 6 cos θ 6 cos α 6 d 6 cos α 6 0 0 0 1 ] \left[ \begin{matrix} cos θ_6&-sinθ_6&0&a_6 \\ cosα_6sinθ_6&cosα_6cosθ_6&-sinα_6&-d_{6}sinα_6\\ sinα_{6}sinθ_6&sinα_{6}cosθ_6&cosα_{6}&d_{6} cosα_{6}\\ 0&0&0&1 \end{matrix} \right]cosθ6c o s α6sinθ6I n α _6sinθ60sinθ6c o s α6cosθ6I n α _6cosθ600- s i n α6c o s α60a6d6I n α _6d6c o s α61

Multiply the six homogeneous transformation matrices in order to get the six-degree-of-freedom robotTotal transform:
0 T 6 = ^{0}T_6 = 0 T6= 0 T 1 × ^{0}T_1× 0 T1× 1 T 2 × ^{1}T_2× 1T2× 2 T 3 × ^{2}T_3× 2T _3× 3 T 4 × ^{3}T_4× 3T _4× 4 T 5 × ^{4}T_5× 4 T5× 5 T 6 = ^{5}T_6= 5T6= [ summary zpz 0 0 0 1 ] \left[ \begin{matrix} n_x&o_x&a_x&p_x \\ n_y&o_y&a_y&p_y\\ n_z&o_z&a_z&p_z \\ 0&0&0&1 \end{matrix} \right]nxnynz0oxoyoz0axayaz0pxpypz1

2. Code implementation

1. Define the parameters of each connecting rod

The definition of symbolic variables for connecting rod parameters istwo ways,code show as below:

the first wayis to define all parameters as unknowns

syms   theta1   d1    a1     alpha1;
syms   theta2   d2    a2     alpha2;
syms   theta3   d3    a3     alpha3;
syms   theta4   d4    a4     alpha4;
syms   theta5   d5    a5     alpha5;
syms   theta6   d6    a6     alpha6;

But because setting too many unknowns will lead to the result of the total transformation is too lengthy, so set herethe second wayTo avoid complicated results, please refer to Matlab in the previous article to establish a six-degree-of-freedom robot model for the following parameters

%连杆偏移
d1 = 398;
d2 = -0.299;
d3 = 0;
d4 = 556.925;
d5 = 0;
d6 = 165;
%连杆长度
a1 = 0;
a2 = 168.3;
a3 = 650.979;
a4 = 156.240;
a5 = 0;
a6 = 0;
%连杆扭角
alpha1 = 0;
alpha2 = pi/2;
alpha3 = 0;
alpha4 = pi/2;
alpha5 = -pi/2;
alpha6 = pi/2;
%由于我们需要分析各轴θi所对应的机器人末端位置
%因此theta1 theta2 theta3 theta4 theta5 theta6仍设为未知量
syms theta1 theta2 theta3 theta4 theta5 theta6

With the above parameter settings, the next parameterhomogeneous transformation matrixsetting.

2. Homogeneous transformation matrix and total transformation

Firstly, each parameter is summarized into a unified matrix, which is convenient for the subsequent parameter analysis.quote

% 参数矩阵取名为MDH
MDH = [theta1          d1       a1       alpha1;
       theta2+pi/2     d2       a2       alpha2;    
       theta3          d3       a3       alpha3;
       theta4          d4       a4       alpha4;
       theta5          d5       a5       alpha5;
       theta6          d6       a6       alpha6];

Notice! ! !Since the author's 6DOF robot has aJoint Variable Offset, the offset is the key that causes theta2the need to add in MDH pi/2.

Next, refer to the value of the parameter matrix in the homogeneous transformation matrix, and define the homogeneous transformation matrix of each joint. The code is as follows:

T01=[cos(MDH(1,1))               -sin(MDH(1,1))                 0              MDH(1,3);
     sin(MDH(1,1))*cos(MDH(1,4))  cos(MDH(1,1))*cos(MDH(1,4))  -sin(MDH(1,4)) -sin(MDH(1,4))*MDH(1,2);
     sin(MDH(1,1))*sin(MDH(1,4))  cos(MDH(1,1))*sin(MDH(1,4))   cos(MDH(1,4))  cos(MDH(1,4))*MDH(1,2);
      0                           0                             0              1];
T12=[cos(MDH(2,1))               -sin(MDH(2,1))                 0              MDH(2,3);
     sin(MDH(2,1))*cos(MDH(2,4))  cos(MDH(2,1))*cos(MDH(2,4))  -sin(MDH(2,4)) -sin(MDH(2,4))*MDH(2,2);
     sin(MDH(2,1))*sin(MDH(2,4))  cos(MDH(2,1))*sin(MDH(2,4))   cos(MDH(2,4))  cos(MDH(2,4))*MDH(2,2);
      0                           0                             0              1];
T23=[cos(MDH(3,1))               -sin(MDH(3,1))                 0              MDH(3,3);
     sin(MDH(3,1))*cos(MDH(3,4))  cos(MDH(3,1))*cos(MDH(3,4))  -sin(MDH(3,4)) -sin(MDH(3,4))*MDH(3,2);
     sin(MDH(3,1))*sin(MDH(3,4))  cos(MDH(3,1))*sin(MDH(3,4))   cos(MDH(3,4))  cos(MDH(3,4))*MDH(3,2);
      0                           0                             0              1];
T34=[cos(MDH(4,1))               -sin(MDH(4,1))                 0              MDH(4,3);
     sin(MDH(4,1))*cos(MDH(4,4))  cos(MDH(4,1))*cos(MDH(4,4))  -sin(MDH(4,4)) -sin(MDH(4,4))*MDH(4,2);
     sin(MDH(4,1))*sin(MDH(4,4))  cos(MDH(4,1))*sin(MDH(4,4))   cos(MDH(4,4))  cos(MDH(4,4))*MDH(4,2);
      0                           0                             0              1];
T45=[cos(MDH(5,1))               -sin(MDH(5,1))                 0              MDH(5,3);
     sin(MDH(5,1))*cos(MDH(5,4))  cos(MDH(5,1))*cos(MDH(5,4))  -sin(MDH(5,4)) -sin(MDH(5,4))*MDH(5,2);
     sin(MDH(5,1))*sin(MDH(5,4))  cos(MDH(5,1))*sin(MDH(5,4))   cos(MDH(5,4))  cos(MDH(5,4))*MDH(5,2);
      0                           0                             0              1];
T56=[cos(MDH(6,1))               -sin(MDH(6,1))                 0              MDH(6,3);
     sin(MDH(6,1))*cos(MDH(6,4))  cos(MDH(6,1))*cos(MDH(6,4))  -sin(MDH(6,4)) -sin(MDH(6,4))*MDH(6,2);
     sin(MDH(6,1))*sin(MDH(6,4))  cos(MDH(6,1))*sin(MDH(6,4))   cos(MDH(6,4))  cos(MDH(6,4))*MDH(6,2);
      0                           0                             0              1];

Through the above, we can see that the total transformation code is as follows:

T06 = T01*T12*T23*T34*T45*T56;

3. Code running results

In the code example, we will refer to θi θ_iiiProceed as followsassignment

theta1 = pi/3;
theta2 = pi/4;
theta3 = pi/5;
theta4 = pi/3;
theta5 = pi/4;
theta6 = pi/5;

After running the program, as shown in the figure below After the simulation
Results of T06
of the previous article , the result is shown in the figure belowrobot.teach()
Simulation results


Summarize

The above is the content of forward kinematics. This article introduces in detail how to understand forward kinematics and the implementation of code. The robot toolbox provides functions and methods on how to deal with the length of the connecting rod and the twist of the connecting rod.

references

  1. Matlab Robot Toolbox (1) - Establishment, Drawing and Forward and Inverse Kinematics of Robots
  2. Establishing the Kinematics Positive Solution of Robot by DH Parameter Method
  3. Six-axis robot matlab write kinematics positive solution function (DH model)
  4. [Robotics] Planar 2R Robot (1) - Positive Kinematics

Guess you like

Origin blog.csdn.net/AlbertDS/article/details/110631364