Industrial Robot Kinematics and Matlab Forward and Inverse Solution Algorithm Study Notes (Summary of a plenary session with heart) (2)


CSDN reminds me that there are too many words, and I can’t post one article, so I have to split it up

about

  • Standard DH model
  • Improved DH model
  • robot kinematics

For details, see the first article:

→→→ [Industrial Robot Kinematics and Matlab Forward and Inverse Solution Algorithm Study Notes (Summary of a Plenary Session) (1)]

❤ 2023.6.19 ❤

insert image description here

Robot Inverse Kinematics

※ Meaning and connection of algebraic solution, geometric solution, analytical solution (closed solution), numerical solution

Speaking of which, I was quite dizzy when I first encountered these concepts. After communicating with others, I found that I was not the only one who was dizzy. People often confuse the concepts and make mistakes.

Next, please ChatGPT to answer first

insert image description here

Then I summarize

Both algebraic solution and geometric solution belong to analytical solution (closed solution) . Their characteristic is that specific equations can be listed and the obtained results are accurate. The difference is that the algebraic solution is based on the characteristics of the matrix, and the unknown is solved by establishing a system of equations through the method of equal specific elements; while the geometric solution is to establish a system of equations through the geometric relationship of the robot to solve the unknown.

Only robots with specific configurations have analytical solutions, but fortunately, most of the robots we usually use are of specific configurations.

The numerical solution corresponds to the analytical solution, and the characteristic is that the calculation process relies on iteration, and the obtained result is an approximate solution. It is applicable to all robots, including special configurations and general configurations, and is mostly used on robots that do not have an analytical solution.


For the ZK-500 robot, because it belongs to a special configuration in which the rear three axes intersect at one point, the analytical method is used here to find the inverse solution of the robot.

First, the pose description matrix is ​​written as follows

6 0 T = [ 0 0 0 1 ] = 1 0 T ( θ 1 ) 2 1 T ( θ 2 ) 3 2 T ( θ 3 ) 4 3 T ( θ 4 ) 5 4 T ( θ 5 ) T ( θ 6 ) {_6^0}T=\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]={_1^0}T\left( \theta_1\right)\ _2^1T\left(\theta_2\right)\ _3^2T\left(\theta_3\right)\ _4^3T\left(\theta_4\right)\ _5^4T\left(\theta_5 \right)\_6^5T\left(\theta_6\right)60T= nxnynz0oxoyoz0axayaz0pxpypz1 =10T( i1) 21T( i2) 32T( i3) 43T( i4) 54T( i5) 65T( i6)

△ Algebraic solution for θ 1 \theta_1i1 θ 2 \theta_2 i2 θ 3 \theta_3 i3

※Reference materials

→→→ [MD-H model kinematics forward solution, inverse solution and verification of attitude angle]
This is really a treasure author

→→→Introduction to Robotics (John J Craig)


※ About why use atan2() function to solve

A t a n 2 ( ) \mathrm{Atan2}\left(\right) Atan2( ) , this function is the same asA tan ( ) \mathrm{Atan}\left(\right)Atan( ) is the same as arctangent, but its value range is( − π , π ) (-\pi,\pi)( π ,π ) , you can get the quadrant corresponding to the angle, which is the enhanced version ofA tan ( ) \mathrm{Atan}\left(\right)Atan()

For details, please refer to
→→→ atan2()
→→→ atan2 vs atan

As for why this function is used, I was also very confused at this point. After calculating the sin value or cos value of some corners, theoretically, the arcsine/arccosine function can be used to solve the corresponding angle. Why bother? Find sin and cos at the same time, and then divide and use atan2() to solve it?

After searching for information, I saw this article

→→→ [Why is it better to use the double-variable arctangent function atan2 instead of the arc/cosine function for the inverse solution of robot kinematics?

Let me sum it up, the general meaning is that it is not impossible to use the arcsine/arccosine function directly, but their range of values ​​is relatively small, and the joint range of the robot can reach ( − π , π ) (-\pi,\pi )( π ,π ) , if you use the arcsine/arccosine function to solve it, you need to fully consider the value range of different poses and then make a judgment. And the value range of the atan2() function is( − π , π ) (-\pi,\pi)( π ,π ) , in many cases the extra judgment process is omitted.

And the arcsin()/arccos() function lacks definition at some special points, which will lead to the error amplification of the calculation result, but the atan2() function does not have this problem.

atan2() function definition

insert image description here

  • Problems needing attention when using atan2() function

But according to the article [Why is it best to use the two-variable arctangent function atan2 instead of the arc/cosine function for the inverse solution of robot kinematics? As mentioned, it is not foolproof after using atan2(), and some problems need to be paid attention to:
1. The definition when x=0, y=0
2. The jump of the value of the function when x or y passes through 0

See the above article for specific solutions


○ Solving for θ 1 \theta_1i1

First, include θ 1 \theta_1 in the above formulai1part of the shift to the left side of the equation

[ 1 0 T ( θ 1 ) ] − 1   6 0 T = 2 1 T ( θ 2 )   3 2 T ( θ 3 )   4 3 T ( θ 4 )   5 4 T ( θ 5 )   6 5 T ( θ 6 ) {\left[{_1^0}T\left(\theta_1\right)\right]^{-1}}\ _6^0T={_2^1}T\left(\theta_2\right)\ _3^2T\left(\theta_3\right)\ _4^3T\left(\theta_4\right)\ _5^4T\left(\theta_5\right)\ _6^5T\left(\theta_6\right) [10T( i1)]1 60T=21T( i2) 32T( i3) 43T( i4) 54T( i5) 65T( i6)

1 0 T {_1^0} T10To find the inverse of T , the equation is written as follows

[ c 1 s 1 0 0 − s 1 c 1 0 0 0 0 1 − d 1 0 0 0 1 ] [ equation zpz 0 0 0 1 ] = 6 1 T \left[\begin{matrix}c_1&s_1&0&0\\-s_1&c_1&0&0 \\0&0&1&-d_1\\0&0&0&1\\\end{matrix}\right]\left[\begin{matrix}n_x&o_x&a_x&p_x\\n_y&o_y&p_y\\n_z&o_z&a_z&p_z\\\0&0&0&1\\\end{matrix}\right]={_6^ 1}T c1s100s1c100001000d11 nxnynz0oxoyoz0axayaz0pxpypz1 =61T

Solve for 6 1 T {_6^1}T61After T , by observing the matrix on both sides of the equation, make the elements (2,4) equal to get

− s 1 p x + c 1 p y = 0 -s_1p_x+c_1p_y=0 s1px+c1py=0


  • 【How to get this equation】

There is a lot of content in this solution process, so let me use matlab to calculate it. . .

  • Matrix on the left side of the equation (each square bracket represents a row)
[nx*cos(Q1) + ny*sin(Q1), 
 ox*cos(Q1) + oy*sin(Q1), 
 ax*cos(Q1) + ay*sin(Q1), 
 px*cos(Q1) + py*sin(Q1)]
 
[ny*cos(Q1) - nx*sin(Q1), 
 oy*cos(Q1) - ox*sin(Q1), 
 ay*cos(Q1) - ax*sin(Q1), 
 py*cos(Q1) - px*sin(Q1)]
 
[nz,oz,az,pz - d1]

[0,0,0,1]

  • Matrix on the right side of the equation (each square bracket represents a row)
[- cos(Q6)*(sin(Q2 + Q3)*sin(Q5) - cos(Q2 + Q3)*cos(Q4)*cos(Q5)) - cos(Q2 + Q3)*sin(Q4)*sin(Q6),   
 sin(Q6)*(sin(Q2 + Q3)*sin(Q5) - cos(Q2 + Q3)*cos(Q4)*cos(Q5)) - cos(Q2 + Q3)*cos(Q6)*sin(Q4), 
 sin(Q2 + Q3)*cos(Q5) + cos(Q2 + Q3)*cos(Q4)*sin(Q5), 
 a1 + a3*cos(Q2 + Q3) + d4*sin(Q2 + Q3) + a2*cos(Q2)]
 
[- cos(Q4)*sin(Q6) - cos(Q5)*cos(Q6)*sin(Q4),
 cos(Q5)*sin(Q4)*sin(Q6) - cos(Q4)*cos(Q6),
 sin(Q4)*sin(Q5),
 0]
 
[cos(Q6)*(cos(Q2 + Q3)*sin(Q5) + sin(Q2 + Q3)*cos(Q4)*cos(Q5)) - sin(Q2 + Q3)*sin(Q4)*sin(Q6), 
 - sin(Q6)*(cos(Q2 + Q3)*sin(Q5) + sin(Q2 + Q3)*cos(Q4)*cos(Q5)) - sin(Q2 + Q3)*cos(Q6)*sin(Q4), 
 sin(Q2 + Q3)*cos(Q4)*sin(Q5) - cos(Q2 + Q3)*cos(Q5),      
 a3*sin(Q2 + Q3) - d4*cos(Q2 + Q3) + a2*sin(Q2)]
 
[0,0,0,1]
 

Sure enough, it contains θ 1 \theta_1i1(here Q 1 Q_1Q1) among the elements (2,4) is the best calculation. . .


In the formula, px p_xpxpy p_ypyare known, then θ 1 \theta_1i1Can be expressed as:

θ 1 = A tan 2 (py, px) \theta_1=\mathrm{Atan2}\left(p_y,p_x\right)i1=Atan2(py,px)

It should be noted that the input variable is first py p_ypythen px p_xpxFor tan ⁡ θ = pypx \tan{\theta}=\frac{p_y}{p_x
}tani=pxpy, that is, enter the numerator first, and then the denominator.

There are two sets of solutions here:
θ 1 = A tan 2 ( py , px ) \theta_1=\mathrm{Atan2}\left(p_y,p_x\right)i1=Atan2(py,px)
θ 1 ′ = A tan 2 ( − py , − px ) \theta_1^\prime=\mathrm{Atan2}\left(-p_y,-p_x\right)i1=Atan2(py,px)


  • Matlab code implementation
%% theta1求解
%theta1可能的解有两组
theta1_1=atan2(py,px);
theta1_2=atan2(-py,-px);

○ Solving for θ 3 \theta_3i3

Let the matrix elements (1,4) and (3,4) in the above equation be equal to:

c 1 p x + s 1 p y = a 1 + a 2 c 2 + a 3 c 23 + d 4 s 23 p z − d 1 = a 2 s 2 + a 3 s 23 − d 4 c 23 c_1p_x+s_1p_y=a_1+a_2c_2+a_3c_{23}+d_4s_{23}\\ p_z-d_1=a_2s_2+a_3s_{23}-d_4c_{23} c1px+s1py=a1+a2c2+a3c23+d4s23pzd1=a2s2+a3s23d4c23

The sum of the squares around the equal sign is
m 2 + n 2 = a 2 2 + a 3 2 + d 4 2 + 2 a 2 ( a 3 c 3 + d 4 s 3 ) m^2+n^2=a_2^2+ a_3^2+d_4^2+2a_2\left(a_3c_3+d_4s_3\right)m2+n2=a22+a32+d42+2a _2(a3c3+d4s3)
among them:
m = c 1 px + s 1 py − a 1 n = pz − d 1 m=c_1p_x+s_1p_y-a_1\\ n=p_z-d_1m=c1px+s1pya1n=pzd1


About the calculation process of this step:

I demonstrate with this code:

syms a1 a2 a3 d4 theta2 theta3

m=a2*cos(theta2)+a3*cos(theta2+theta3)+d4*sin(theta2+theta3);
n=a2*sin(theta2)+a3*sin(theta2+theta3)-d4*cos(theta2+theta3);

k=m^2 + n^2

% 展开表达式为多项式形式
K1 = expand(m^2 + n^2) 
%K = collect(K, [a1 a2 a3 d4]);  

% 化简多项式
K2=simplify(K1)

% 整理多项式的项
k3=collect(K2)

result:

k =
(a3*cos(theta2 + theta3) + d4*sin(theta2 + theta3) + a2*cos(theta2))^2 + (a3*sin(theta2 + theta3) - d4*cos(theta2 + theta3) + a2*sin(theta2))^2
 
K1 =
a2^2*cos(theta2)^2 + a2^2*sin(theta2)^2 + a3^2*cos(theta2)^2*cos(theta3)^2 + d4^2*cos(theta2)^2*cos(theta3)^2 + a3^2*cos(theta2)^2*sin(theta3)^2 + a3^2*cos(theta3)^2*sin(theta2)^2 + d4^2*cos(theta2)^2*sin(theta3)^2 + d4^2*cos(theta3)^2*sin(theta2)^2 + a3^2*sin(theta2)^2*sin(theta3)^2 + d4^2*sin(theta2)^2*sin(theta3)^2 + 2*a2*a3*cos(theta2)^2*cos(theta3) + 2*a2*a3*cos(theta3)*sin(theta2)^2 + 2*a2*d4*cos(theta2)^2*sin(theta3) + 2*a2*d4*sin(theta2)^2*sin(theta3)
 
K2 =
a2^2 + 2*cos(theta3)*a2*a3 + 2*sin(theta3)*a2*d4 + a3^2 + d4^2
 
k3 =
a2^2 + 2*cos(theta3)*a2*a3 + 2*sin(theta3)*a2*d4 + a3^2 + d4^2

H = ( m 2 + n 2 − a 2 2 − a 3 2 − d 4 2 ) / 2 a 2 H=\left(m^2+n^2-a_2^2-a_3^2-d_4^2\right)/2a_2 H=(m2+n2a22a32d42)/ 2a2
Then the equation can be expressed as:
a 3 c 3 + d 4 s 3 = H a_3c_3+d_4s_3=Ha3c3+d4s3=H

可得:
θ 3 = A t a n 2 ( H , ± a 3 2 + d 4 2 − H 2 ) − A t a n 2 ( a 3 , d 4 ) \theta_3=\mathrm{Atan2}\left(H,\pm\sqrt{a_3^2+d_4^2-H^2}\right)-\mathrm{Atan2}\left(a_3,d_4\right) i3=Atan2(H,±a32+d42H2 )Atan2(a3,d4)

Due to the existence of positive and negative signs, θ 3 \theta_3i3There are two sets of solutions.


  • ※ 【About how this step came about】

I didn't find the specific content of converting to arctangent, but this derivation process can refer to

→→→ [acosx+bsinx = c; how to calculate x]


  • Matlab code implementation
%% theta3求解
%theta1的取值已经确定,但是因为theta1有两组可能得解,所以这里实际上m有两组取值,这里只给出一组
m=cos(theta1)*px+sin(theta1)*py-a1; 
n=pz-d1;
H=(m^2+n^2-a2^2-a3^2-d4^2)/(2*a2);
theta3_1=atan2(H,sqrt(a3^2+d4^2-H^2))-atan2(a3,d4);
theta3_2=atan2(H,-sqrt(a3^2+d4^2-H^2))-atan2(a3,d4);

○ Solving for θ 2 \theta_2i2

Regarding the solution of \theta_2$, I tried several methods.

· Methods of Introduction to Robotics (failed attempts)

First, I tried the method documented in the textbook Introduction to Robotics (John J Craig).

As we all know, PUMA560 is used as a case in "Introduction to Robotics", and the structure of PUMA560 is different from the configuration of industrial robots commonly used today (mainly different from the robots I study), so it cannot be used directly. . Here is the calculation with reference to its steps.

The first step is to organize the calculation formula of the end pose description matrix of the robot as follows

[ 3 0 T ( θ 2 ) ] − 1   6 0 T = 4 3 T ( θ 4 )   5 4 T ( θ 5 )   6 5 T ( θ 6 )   [{_3^0}T\left(\theta_2\right)]^{-1}\ {_6^0}T={_4^3}T\left(\theta_4\right)\ {_5^4}T\left(\theta_5\right)\ {_6^5}T\left(\theta_6\right)\ [30T( i2)]1 60T=43T( i4) 54T( i5) 65T( i6) 

Given the range of the voltages (1.4) and (2.4), the quantity
( pz − d 1 ) sin ⁡ ( θ 23 ) − a 1 cos ⁡ ( θ 23 ) − a 2 cos ⁡ ( θ 3 ) + . . . . . . . . px cos ⁡ ( θ 1 ) cos ⁡ ( θ 23 ) + py sin ⁡ ( θ 1 ) cos ⁡ ( θ 23 ) = a 3 ( pz − d 1 ) cos ⁡ ( θ 23 ) + a 1 sin ⁡ ( θ ) + a 2 sin ⁡ ( θ 3 ) − . . . . . . . . py cos ⁡ ( θ 1 ) cos ⁡ ( θ 23 ) + px sin ⁡ ( θ 1 ) cos ⁡ ( θ 23 ) = − d 4 (p_z-d_1)\sin(\theta_{23})-a_1\cos( \theta_{23})-a_2\cos(\theta_3)+...\\p_x\cos(\theta_1)\cos(\theta_{23})+p_y\sin(\theta_1)\cos(\theta_{ 23})=a_3\\ (p_z-d_1)\cos(\theta_{23})+a_1\sin(\theta_{23})+a_2\sin(\theta_3)-...\\p_y\cos( \theta_1)\cos(\theta_{23})+p_x\sin(\theta_1)\cos(\theta_{23})=-d_4(pzd1)sin ( i23)a1cos ( i23)a2cos ( i3)+...pxcos ( i1)cos ( i23)+pysin ( i1)cos ( i23)=a3(pzd1)cos ( i23)+a1sin ( i23)+a2sin ( i3)...pycos ( i1)cos ( i23)+pxsin ( i1)cos ( i23)=d4


  • The calculation process is as follows

calculation process

syms Q1 Q2 Q3 Q4 Q5 Q6  d1 d4 dt a1 a2 a3  nx ny nz ox oy oz ax ay az px py pz

%ZK-500连杆间齐次变换矩阵
T_01 =[ cos(Q1),   -sin(Q1),    0,      0
        sin(Q1),    cos(Q1),    0,      0
        0,          0,          1,      d1
        0,          0,          0,      1];
T_12 =[ cos(Q2),   -sin(Q2),    0,      a1
        0,          0,         -1,      0
        sin(Q2),    cos(Q2),    0,      0
        0,          0,          0,      1];
T_23 =[ cos(Q3),   -sin(Q3),    0,      a2
        sin(Q3),    cos(Q3),    0,      0
        0,          0,          1,      0
        0,          0,          0,      1];
T_34 =[ cos(Q4),   -sin(Q4),    0,      a3
        0,          0,         -1,     -d4
        sin(Q4),    cos(Q4),    0,      0
        0,          0,          0,      1];
T_45 =[ cos(Q5),   -sin(Q5),    0,      0
        0,          0,          1,      0
       -sin(Q5),   -cos(Q5),    0,      0
        0,          0,          0,      1];
T_56 =[ cos(Q6),   -sin(Q6),    0,      0
        0,          0,         -1,      0
        sin(Q6),    cos(Q6),    0,      0
        0,          0,          0,      1];
T_6t=[  1           0           0       0
        0           1           0       0
        0           0           1       dt
        0           0           0       1];

% 计算T_06和T_16的逆矩阵
T_06=[nx ox ax px;ny oy ay py;nz oz az pz;0 0 0 1];
T_03=T_01*T_12*T_23;
T_36=T_34*T_45*T_56;


% 计算T_01的逆矩阵
T_03_inv = inv(T_03);  

%输出结果并化简
T_left=T_03_inv*T_06;
disp("等式左边矩阵:")
%T_left=simplify(T_left)
T_left
disp("等式右边矩阵:")
simplify(T_36)

The result is as follows

T_left =
 
[nz*cos(Q2)*sin(Q3) + nz*cos(Q3)*sin(Q2) - nx*cos(Q1)*sin(Q2)*sin(Q3) - ny*sin(Q1)*sin(Q2)*sin(Q3) + nx*cos(Q1)*cos(Q2)*cos(Q3) + ny*cos(Q2)*cos(Q3)*sin(Q1),

 oz*cos(Q2)*sin(Q3) + oz*cos(Q3)*sin(Q2) - ox*cos(Q1)*sin(Q2)*sin(Q3) - oy*sin(Q1)*sin(Q2)*sin(Q3) + ox*cos(Q1)*cos(Q2)*cos(Q3) + oy*cos(Q2)*cos(Q3)*sin(Q1), 

az*cos(Q2)*sin(Q3) + az*cos(Q3)*sin(Q2) - ay*sin(Q1)*sin(Q2)*sin(Q3) + ax*cos(Q1)*cos(Q2)*cos(Q3) + ay*cos(Q2)*cos(Q3)*sin(Q1) - ax*cos(Q1)*sin(Q2)*sin(Q3), 

pz*sin(Q2 + Q3) - d1*sin(Q2 + Q3) - a1*cos(Q2 + Q3) - a2*cos(Q3) + (px*cos(Q1 + Q2 + Q3))/2 + (py*sin(Q1 + Q2 + Q3))/2 + (px*cos(Q2 - Q1 + Q3))/2 - (py*sin(Q2 - Q1 + Q3))/2]

[nz*cos(Q2)*cos(Q3) - nz*sin(Q2)*sin(Q3) - ny*cos(Q2)*sin(Q1)*sin(Q3) - ny*cos(Q3)*sin(Q1)*sin(Q2) - nx*cos(Q1)*cos(Q2)*sin(Q3) - nx*cos(Q1)*cos(Q3)*sin(Q2),

 oz*cos(Q2)*cos(Q3) - oz*sin(Q2)*sin(Q3) - oy*cos(Q2)*sin(Q1)*sin(Q3) - oy*cos(Q3)*sin(Q1)*sin(Q2) - ox*cos(Q1)*cos(Q2)*sin(Q3) - ox*cos(Q1)*cos(Q3)*sin(Q2),

 az*cos(Q2)*cos(Q3) - az*sin(Q2)*sin(Q3) - ax*cos(Q1)*cos(Q2)*sin(Q3) - ax*cos(Q1)*cos(Q3)*sin(Q2) - ay*cos(Q2)*sin(Q1)*sin(Q3) - ay*cos(Q3)*sin(Q1)*sin(Q2), 

pz*cos(Q2 + Q3) - d1*cos(Q2 + Q3) + a1*sin(Q2 + Q3) + a2*sin(Q3) + (py*cos(Q1 + Q2 + Q3))/2 - (px*sin(Q1 + Q2 + Q3))/2 - (py*cos(Q2 - Q1 + Q3))/2 - (px*sin(Q2 - Q1 + Q3))/2]

[
nx*sin(Q1) - ny*cos(Q1),
ox*sin(Q1) - oy*cos(Q1),
ax*sin(Q1) - ay*cos(Q1),
px*sin(Q1) - py*cos(Q1)
]

[0,0,0, 1]
 
等式右边矩阵:
[
cos(Q4)*cos(Q5)*cos(Q6) - sin(Q4)*sin(Q6),
- cos(Q6)*sin(Q4) - cos(Q4)*cos(Q5)*sin(Q6), 
cos(Q4)*sin(Q5),  
a3
]


[                          
cos(Q6)*sin(Q5),                            
-sin(Q5)*sin(Q6),        
-cos(Q5), 
-d4]

[cos(Q4)*sin(Q6) + cos(Q5)*cos(Q6)*sin(Q4),   
cos(Q4)*cos(Q6) - cos(Q5)*sin(Q4)*sin(Q6), 
sin(Q4)*sin(Q5),   
0]
[0, 0, 0, 1]


Then let ChatGPT simplify it for me

insert image description here

The end result is this

(pz - d1)*sin(Q23) - a1*cos(Q23) - a2*cos(Q3) + px*cos(Q1)*cos(Q23) + py*sin(Q1)*cos(Q23)=a3;
(pz - d1)*cos(Q23) + a1*sin(Q23) + a2*sin(Q3) - py*cos(Q1)*cos(Q23) + px*sin(Q1)*cos(Q23)=-d4;

At this time, only s 23 s_{23} is unknown in the equations23and c 23 c_{23}c23, set it as unknown, (theoretically) you can solve θ 2 + θ 3 \theta_2+\theta_3i2+i3


m 1 = c 1 px + s 1 py − a 1 m 2 = pz − d 1 m 3 = a 3 + a 2 c 3 m_1=c_1p_x+s_1p_y-a_1\\ m_2=p_z-d_1\\ m_3=a_3 +a_2c_3m1=c1px+s1pya1m2=pzd1m3=a3+a2c3

n 1 = − c 1 py − s 1 px − d 1 n 2 = a 1 n 3 = − d 4 − a 2 s 3 n_1=-c_1p_y-s_1p_x-d_1\\ n_2=a_1\\ n_3=-d_4- a_2s_3n1=c1pys1pxd1n2=a1n3=d4a2s3

Organize the equation system as
m 1 c 23 + m 2 s 23 = m 3 n 1 c 23 + n 2 s 23 = n 3 m_1c_{23}+m_2s_{23}=m_3\\n_1c_{23}+n_2s_{23 }=n_3m1c23+m2s23=m3n1c23+n2s23=n3

Solutions have to

x = s 23 = ( m 1 n 3 − m 3 n 1 ) / ( m 1 n 2 − m 2 n 1 ) y = c 23 = − ( m 2 n 3 − m 3 n 2 ) / m 1 n 2 − m 2 n 1 ) x=s_{23}=(m_1n_3-m_3n_1)/(m_1n_2-m_2n_1)\\ y=c_{23}=-(m_2n_3-m_3n_2)/m_1n_2-m_2n_1) x=s23=(m1n3m3n1)/(m1n2m2n1)y=c23=(m2n3m3n2)/m1n2m2n1)

Level 23 = For 2 (y, x) \theta_{23}=\mathrm{For2}(y,x )
i23=Atan2 ( y ,x)

Then according to θ 3 \theta_3i3The value of θ 2 \theta_2i2

[! ! ? ? 】It looks fine, but the calculated result is different from the preset value. I don’t know where the problem is. If someone can see it, I hope to give some pointers.


  • Matlab code implementation
m1=cos(theta1)*px+sin(theta1)*py-a1;
m2=pz-d1;
m3=a3+a2*cos(theta3);

n1=-cos(theta1)*py-sin(theta1)*px+pz-d1;
n2=a1;
n3=-d4-a2*sin(theta1);

x = (m1*n3 - m3*n1)/(m1*n2 - m2*n1);
y = -(m2*n3 - m3*n2)/(m1*n2 - m2*n1);

theta23=atan2(y,x)-pi/2;%这里减pi/2因为在DH参数中theta2补偿了pi/2

· Methods in referenced articles (failed attempts)

That is the article mentioned earlier:

→→→ [MD-H model kinematics forward solution, inverse solution and verification of attitude angle calculation]

In this article, the author did not give the specific derivation process, but only gave the matlab code, the code is as follows

%theta2
c3=cosd(Theta3);s3=sind(Theta3);
g1=f2-d6*f1;
g2=f3-d6*az;
g3=a4*c3-d4*s3+a3;
Theta2=(atan2(g3,sqrt(g1^2+g2^2-g3^2))-atan2(g2,g1))*180/pi;
————————————————
版权声明:本文为CSDN博主「Vittore-Li」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/Vittore_Li/article/details/123185721

[! 】Note that the definition of the DH parameters of the author of this article is different from mine. My a1=his a2, my a2=his a3, my a3=his a4, and the connection of his DH model The Z axis of the rod is opposite to my direction, I don't know what effect it will have on the solution.

I looked at it for a long time and didn't understand how this came about, and the result of running it directly was also incorrect (running after making corresponding modifications to my DH model).

If anyone knows what method the author uses, I hope you can enlighten me! (clasping fists)


· The method of a master's thesis (the method that can get the correct result)

Yes, it is the thesis of the boss I mentioned earlier (previous article). In fact, my previous process is basically (or all) written according to the steps of the boss, but I added my understanding and verification process.

The boss is different, and the method I use is something I have never seen before. . .

The end position of the robot (the origin of the coordinate system 6) is as follows:

p x = a 1 c 1 + a 3 c 1 c 23 + d 4 c 1 s 23 + a 2 c 1 c 2 p y = a 1 s 1 + a 3 s 1 c 23 + d 4 s 1 s 23 + a 2 c 2 s 1 p z = d 1 + a 2 s 2 + a 3 s 23 − d 4 c 23 p_x=a_1c_1+a_3c_1c_{23}+d_4c_1s_{23}+a_2c_1c_2\\ p_y=a_1s_1+a_3s_1c_{23}+d_4s_1s_{23}+a_2c_2s_1\\ p_z=d_1+a_2s_2+a_3s_{23}-d_4c_{23} px=a1c1+a3c1c23+d4c1s23+a2c1c2py=a1s1+a3s1c23+d4s1s23+a2c2s1pz=d1+a2s2+a3s23d4c23

Organized to get:

p x c 1 − a 1 = a 3 c 23 + d 4 s 23 + a 2 c 2 p y s 1 − a 1 = a 3 c 23 + d 4 s 23 + a 2 c 2 p z − d 1 = a 2 s 2 + a 3 s 23 − d 4 c 23 \frac{p_x}{c_1}-a_1=a_3c_{23}+d_4s_{23}+a_2c_2\\ \frac{p_y}{s_1}-a_1=a_3c_{23}+d_4s_{23}+a_2c_2\\ p_z-d_1=a_2s_2+a_3s_{23}-d_4c_{23} c1pxa1=a3c23+d4s23+a2c2s1pya1=a3c23+d4s23+a2c2pzd1=a2s2+a3s23d4c23

remember

k 1 = p x c 1 − a 1 k 2 = p z − d 1 k_1=\frac{p_x}{c_1}-a_1 {k_2=p}_z-d_1 k1=c1pxa1k2=pzd1

get:

k 1 − a 2 c 2 = a 3 c 23 + d 4 s 23 k 2 − a 2 s 2 = a 3 s 23 − d 4 c 23 k_1-a_2c_2=a_3c_{23}+d_4s_{23}\\ k_2-a_2s_2=a_3s_{23}-d_4c_{23} k1a2c2=a3c23+d4s23k2a2s2=a3s23d4c23

Find the sum of squares:

a 3 2 + d 4 2 = k 1 2 + k 2 2 + a 2 2 − 2 k 1 a 2 c 2 − 2 k 2 a 2 s 2 a_3^2+d_4^2=k_1^2+k_2^2+a_2^2-2k_1a_2c_2-2k_2a_2s_2 a32+d42=k12+k22+a222 k1a2c22 k2a2s2

remember

k 3 = ( k 1 2 + k 2 2 + a 2 2 − a 3 2 − d 4 2 ) / 2 a 2 k_3=\left(k_1^2+k_2^2+a_2^2-a_3^2-d_4^2\right)/2a_2 k3=(k12+k22+a22a32d42)/ 2a2

but:

k 1 c 2 + k 2 s 2 = k 3 k_1c_2+k_2s_2=k_3 k1c2+k2s2=k3
Solution:
θ 2 = For A 2 ( k 3 , ± k 1 2 + k 2 2 − k 3 2 ) − For A 2 ( k 1 , k 2 ) \theta_2=\mathrm{For2}\left(k_3, \pm\sqrt{k_1^2+k_2^2-k_3^2}\right)-\mathrm{Atan2}\left(k_1,k_2\right)i2=Atan2(k3,±k12+k22k32 )Atan2(k1,k2)


  • Matlab code implementation
k1=px/cos(theta1)-a1;
k2=pz-d1;
k3=(k1^2+k2^2+a2^2-a3^2-d4^2)/(2*a2);

theta2_1=atan2(k3,sqrt(k1^2+k2^2-k3^2))-atan2(k1,k2);
theta2_2=atan2(k3,-sqrt(k1^2+k2^2-k3^2))-atan2(k1,k2);

Remember to subtract θ 2 \theta_2i2an offset of pi/2


❤ 2023.6.21 ❤

The above is to use the method of algebraic solution to find the angles of the first three axes. According to the general process, the last four axes should be found at this time, but as a summary method article, I am not satisfied with only recording one implementation method of.

After learning the method of the younger brother, I think it should be easier to use the set method to solve the first three axes, at least it is easier to understand than the algebraic method that is the same as the brain teaser.

△ Geometry solution for θ 1 \theta_1i1 θ 2 \theta_2 i2 θ 3 \theta_3 i3

○ Solving for θ 1 \theta_1i1

It can be seen from the schematic diagram of the robot that for this configuration of the robot, the mechanism composed of rod 1, rod 2 and rod 3 is in the same vertical plane, and the end of the robot is the common origin of the coordinate system of rod 4, rod 5 and rod 6. It can be seen from this that the end coordinates of the known robot ( px , py , pz ) \left(p_x,p_y,p_z\right)(px,py,pz) to obtain the rotation angle θ 1 \theta_1of axis 1i1

insert image description here
θ 1 = A tan 2 (py, px) \theta_1=\mathrm{Atan2}\left(p_y,p_x\right)i1=Atan2(py,px)

Don't even consider the case of multiple solutions


○ Solving for θ 3 \theta_3i3

The schematic diagram of the robot structure is as follows

insert image description here

As shown in the figure, point C' coordinates ( px , py , pz ) \left(p_x,p_y,p_z\right)(px,py,pz) ,A ratio( a 1 cos ⁡ θ 1 , a 1 sin ⁡ θ 1 , d 1 ) \left(a_1\cos{\theta_1},a_1\sin{\theta_1},d_1\right)(a1cosi1,a1sini1,d1)

L B ′ C ′ = L B C = B D 2 + C D 2 = a 3 2 + d 4 2 L A C = A D 2 − C D 2 = ( a 2 + a 3 ) 2 − d 4 2 L A B ′ = L A B = a 2 L_{B^\prime C^\prime}=L_{BC}=\sqrt{BD^2+CD^2}=\sqrt{a_3^2+d_4^2}\\ L_{AC}=\sqrt{AD^2-CD^2}=\sqrt{\left(a_2+a_3\right)^2-d_4^2}\\ L_{AB^\prime}=L_{AB}=a_2 LBC=LBC=BD2+CD2 =a32+d42 LAC=AD2CD2 =(a2+a3)2d42 LAB=LAB=a2

Because points O, A, C' are coplanar, so
LAC ′ = ( px 2 + py 2 − a 1 ) 2 + ( pz − d 1 ) 2 L_{AC^\prime}=\sqrt{\left(\sqrt {p_x^2+p_y^2}-a_1\right)^2+\left(p_z-d_1\right)^2}LAC=(px2+py2 a1)2+(pzd1)2

According to the law of cosines:
c 2 = a 2 + b 2 − 2 ab cos ⁡ γ c^2=a^2+b^2-2ab\cos{\gamma}c2=a2+b22 abcosγ
得,在 Δ A B ′ C ′ \Delta A\mathrm{B}^\mathrm{'}\mathrm{C}^\mathrm{'} ΔABC中:
cos ⁡ θ 3 ′ = LAB ′ 2 + LB ′ C ′ 2 − LAC ′ 2 2 LAB ′ LB ′ C ′ \cos{\theta_3^\prime}=\frac{L_{AB^\prime}^ 2+L_{B^\prime C^\prime}^2-L_{AC^\prime}^2}{2L_{AB^\prime}L_{B^\prime C^\prime}}cosi3=2 LABLBCLAB2+LBC2LAC2

Also obtained from the law of cosines, in Δ ABC \Delta ABCΔABC中:
cos ⁡ θ B = L A B 2 + L B C 2 − L A C 2 2 L A B L B C \cos{\theta_B}=\frac{L_{AB}^2+L_{BC}^2-L_{AC}^2}{2L_{AB}L_{BC}} cosiB=2 LABLBCLAB2+LBC2LAC2
According to the geometric relationship:
θ 3 = arccos ⁡ θ 3 ′ − arccos ⁡ θ B \theta_3=\arccos{\theta_3^\prime}-\arccos{\theta_B}i3=arccosi3arccosiB
Note that according to the properties of the law of cosines, the obtained θ 3 ′ \theta_3^\primei3The value of is always less than 180°, and θ 3 + θ B \theta_3+\theta_Bi3+iBThere are cases greater than 180°, so θ 3 \theta_3i3There are two groups of values.


○ Solving for θ 2 \theta_2i2

According to θ 2 \theta_2i2Given θ 3 \theta_3i3Different values, θ 2 \theta_2i2The solution has the following four situations:

insert image description here

θ 2 = ∠ BAC ′ − ∠ B ′ AC ′ θ 2 = ∠ BAC ′ + ∠ B ′ AC ′ θ 2 = − ∠ BAC ′ − ∠ B ′ AC ′ θ 2 = − ∠ BAC ′ + ∠ B ′ AC ′; \theta_2=\angle\math{BA}\math{C}^\math{'}-\angle\math{B}^\math{'}\math{AC}^\math{'}\\ \theta_2 =\angle\maths{BA}\maths{C}^\maths{'}+\angle\maths{B}^\maths{'}\maths{AC}^\maths{'}\\ \theta_2=- \angle\mathrm{BA}\mathrm{C}^\mathrm{'}-\angle\mathrm{B}^\mathrm{'}{\mathrm{AC}}^\mathrm{'}\\ \theta_2= -\angle\maths{BA}\maths{C}^\maths{'}+\angle\maths{B}^\maths{'}\maths{AC}^\maths{'}i2=BACBACi2=BAC+BACi2=BACBACi2=BAC+BAC

According to the figure, the coordinates of point B ( a 1 cos ⁡ θ 1 , a 1 sin ⁡ θ 1 , d 1 + a 2 ) \left(a_1\cos{\theta_1},a_1\sin{\theta_1},d_1 +a_2\right)(a1cosi1,a1sini1,d1+a2) .
Since the points O, A, B, and C' are coplanar, so

L B C ′ = ( p x 2 + p y 2 − a 1 ) 2 + ( p z − d 1 − a 2 ) 2 L_{BC'}=\sqrt{\left(\sqrt{p_x^2+p_y^2}-a_1\right)^2+\left(p_z-d_1-a_2\right)^2} LBC=(px2+py2 a1)2+(pzd1a2)2

∠ BAC ′ = β \angle\mathrm{BA}\mathrm{C}^\mathrm{'}=\betaBAC=β ∠ B ′ A C ′ = γ \angle\mathrm{B}^\mathrm{'}\mathrm{AC}^\mathrm{'}=γ BAC=c

According to the law of cosines, in Δ ABC ′ \Delta \mathrm{ABC}^\mathrm{'}ABC _' in:

cos ⁡ β = LAB 2 + LAC ′ 2 − LBC ′ 2 2 LABLAC ′ \cos{\beta}=\frac{L_{AB}^2+L_{AC^\prime}^2-L_{BC^\prime }^2}{2L_{AB}L_{AC^\prime}}cosb=2 LABLACLAB2+LAC2LBC2

Δ AB ′ C ′ \Delta \mathrm{AB}^\mathrm{'}\mathrm{C}^\mathrm{'}ΔABC中:
cos ⁡ γ = LAB ′ 2 + LAC ′ 2 − LB ′ C ′ 2 2 LAB ′ LAC ′ \cos{\gamma}=\frac{L_{AB^\prime}^2+L_{AC^\ prime}^2-L_{B^\prime C^\prime}^2}{2L_{AB^\prime}L_{AC^\prime}}cosc=2 LABLACLAB2+LAC2LBC2

Ratio:
θ 2 = ± arccos ⁡ β ± arccos ⁡ γ \theta_2=\pm\arccos{\beta}\pm\arccos{\gamma}i2=±arccosb±arccosγ
θ 2 \theta_2 i2Four sets of solutions can be obtained.


○ Summary of geometric methods

After sorting out the method of calculating the angles of the first three axes by the geometric method, I feel that the geometric method is not so simple, but the intuition is affirmative, but the geometric solution does not improve the situation of multiple algebraic solutions, and this multiple solution needs to be based on Judging by geometric relations is not necessarily simpler than algebraic solutions.

Because the calculation process is not complicated, the code of matlab is not given here (mainly I did not type).

If there is any problem in the process or there is a better method, please let me know! (clasping fists)


△ Algebraic solution to θ 4 \theta_4i4 θ 5 \theta_5 i5 θ 6 \theta_6 i6

CSDN also reminded me that there are too many words, and I can’t post one article, so I had to disassemble it and solve it with inverse kinematics θ 4 \theta_4i4 θ 5 \theta_5 i5 θ 6 \theta_6 i6, see Jacobi related content

→→→ [Industrial Robot Kinematics and Matlab Forward and Inverse Algorithm Study Notes (Summary of a Plenary Session) (3)]

Guess you like

Origin blog.csdn.net/ooorczgc/article/details/131328330