This article uses quaternion matrix to solve the problem of 6R robot inverse kinematics in the three-dimensional space. In fact, this problem has been solved in 1986  , through Closed Displacement Equation established by Homogeneous Transforms Matrix. It makes use of the product of the closed equation to conduct linear combination and then gets a new series of related equations. Finally, it performs linear elimination according to the linear combination among equations and does final elimination by the resultant, obtaining the 16-degree equation with single variable in the end. The kinematic model of 6R robot can also be built using Dual quaternion or Double quaternion, but there are some problems existed. When Qiao Shuguang  used Double quaternion to solve the problem, 8 extraneous roots appear. In order to eliminate the extraneous roots, four 1 + t2 common factors were extracted in Dixon Resultant. Thus, a 16-degree equation with single variable is obtained. Huang Xiguang  and Gan Dongming  transformed the sine and cosine of one rotation angle into plural form instead of extracting common factors, but numerical calculation is needed. Because only in that way, ±12 degree equation can be transformed to ±8 degree equation, and then a 16-degree equation with single variable can be obtained. Even though they have obtained the single-variable equation, the deduction process depends on numerical computation lacking rigorous proof. A new algorithm using quaternion and dual quaternion in matrix form is put forward in this article. It applies quaternion in special cases of rotated plane, transforming the sine and cosine of the rotation angle into matrix form, then exporting flat quaternion base in two matrixes form. It establishes serial 6R manipulator kinematic equations in the form of quaternion matrix. Then five variables are eliminated through linear elimination and application of lexicographic Groebner base. Thus, upper bound of the degree of the equation is determined, which is 16. In this way, a 16-degree equation with single variable is obtained without any extraneous root. This is the first time that quaternion matrix   modeling has been used in 6R robot inverse kinematics analysis.
2. Homogeneous Transformations in the Form of Quaternion Matrix
A dual quaternion can be expressed as:
which the last four part can be written as
which the part in the bracket can be transformed to matrix form using the method above, so the matrix form of dual quaternion can be expressed as:
Using D-H method to build robot coordinate system, the relationship of two adjacent joint coordinate systems i-1 and i, can be described by the parameters in Figure 1.
In Figure 1, a new coordinate system can be derived by the coordinate system i-1 rotating on its axis Z with angle θi and transforming si along the same axis. Similarly, by rotating this new coordinate system on its axis X with angle αi and transforming ai along the same X, the coordinate system i can be obtained. This kinematics can be described in matrix form like this
Figure 1. D-H coordinate transform.
among which the latter one is a conversion related to x-axis.
3. Closed-Form Kinematics Equations in Term of Double Quaternion Matrix
3.1. Mathematical Modeling
Inverse solution of position of 6R robot in three dimensions is that given the position and gesture and parameter si, ai, αi , find the input angles ( ) of every joints. 6R serial mechanism (Figure 2) has six joints and it needs 6 three-dimension movements described in Figure 1. According to basic theories of quaternion matrix, the mathematical model of inverse solution of kinematics position of 6R serial mechanism in three dimensions can be expressed in matrix form:
θi, si, αi and ai in the equations are structural parameters of 6R robot manipulate arm. and are quaternion matrix transformations that rotate and move along z-axis and x-axis respectively. M is the expression in quaternion matrix form of the position and gesture of the end of the robot. For general 6R robot, unknown variables are and other variable are determined by the structure of robot which are known. Our goal is to find out the six angles. We use Ti and Ai to represent and . As Qiao  said that two of the six variables on the left of Equation (2) can be moved to the right and then it can be solved by Dixon resultant. Here, we move three of six variables on the left to the right, then Equation (2) becomes:
Assume that the left and right part in equation is T7 and T8 respectively, which are quaternions in matrix form. Using Mathematic 6.0, we get:
Figure 2. A general 6R manipulator.
Since and ( ) and we assume that , we can obtain eight equations below:
where ai and bi are known parameters determined by the structure of mechanical arm.
3.2. Eliminate x4, x5 and x6
Assume the right end of the eight Equations in (5) to be:
Solve yi and we can get eight equations below:
where ci are known parameters determined by the structure of mechanical arm.
In (7), we use lexicographic method to order, so , then we compute the Groebner base. Use algebraic system to perform symbolic operation, then we get 21 bases. However, 11 bases among them are eliminated because of containing x4, x5 and x6. Other ten lower-degree bases are selected as quadric bases:
Substitute y1~y8 into Equation (8) and multiply to both sides, then we obtain 10 equations about whose degrees are no more than 4:
For (9), assume , , and simplify this equation by lexicographic Groebner base. Detailed steps are:
Use Mathematica on Intel Pentium IV, 2.93 GHz, RAM 1 G, PC and rank the Groebner bases in (9) according to . This process cost 5.657 seconds and we obtain 11 bases.
Seven of the 11 bases are shown below:
Other four bases are abandoned because they have high degree of X1 and X2. The coefficients eij in (10) are 4, 3, 1, 3, 2, 2, 1 algebraic expression of X3.
The seven Equations in (10) can be transformed into matrix form:
In order to have solutions, the value of determinant of coefficient must be 0, that is
According to the analysis to the degree of X3, matrix N7×7 has 16 degrees about X3. So the degree of expansion is no more than 16.
According to (12), there is no need to extract any common factor and 16-degree input and output equations with single variable X3 can be obtained:
where si are real coefficients determined by input parameters. Solve (13), 16 solutions will be obtained and through:
value of is available.
Substitute x3 to (8) and extract eight equations to build an equation set; consider as unknown variables and solve it. Then we can get X1 and X2. Through (14), we can get θ1 and θ2. Input θ1 and θ2 to (7), yi can be solved. Then, by (6) and (14), θ4, θ5 and θ6 are also available.
3.3. Sample Analysis
Use the parameters in example by Q. Shuguang, which the structural parameters are shown in Table 1. According to the parameter above, we obtain the position and gesture matrix of the end of the mechanical arm, which has 16 groups of joint angles.
The results of back solution are shown in Table 2, in which there are four real solutions and the 14th solution equals to the initial value. In addition, the result in Table 2 is exactly the same as the result gained by program in   and  . In this way, this algorithm is correct.
Based on research of quaternion in matrix form, we apply it on the modeling of 6R robot. By using lexicographic Groebner base twice, we eliminate 3 variables
Table 1. Structural parameters of 6R robot.
Table 2. 16 groups of solutions of 6R robot.
and obtain 10 bases in the first time and 11 bases in the second time. Thus, the degree of variables decreases. Using 7 bases among them and resultant elimination, the analytical solution of the 16-degree equation is obtained and the numerical example gets the same result as the literature above. It is a convenient method which can be applied to inverse kinematics analysis of 6R robot in three dimensions, laying a new foundation for real application.