KUKA XYZ-ABC format¶
KUKA robots use the so called XYZ-ABC format. \(XYZ\) is the position in millimeters. \(ABC\) are angles in degrees, with \(A\) rotating around \(z\) axis, \(B\) rotating around \(y\) axis and \(C\) rotating around \(x\) axis. The rotation convention is \(z\)-\(y'\)-\(x''\) (i.e. \(x\)-\(y\)-\(z\)) and computed by \(r_z(A) r_y(B) r_x(C)\).
Conversion from KUKA-ABC to quaternion¶
The conversion from the \(ABC\) angles in degrees to a quaternion \(q=(\begin{array}{cccc}x & y & z & w\end{array})\) can be done by first converting all angles to radians
\[\begin{split}A_r = A \frac{\pi}{180} \text{,} \\
B_r = B \frac{\pi}{180} \text{,} \\
C_r = C \frac{\pi}{180} \text{,} \\\end{split}\]
and then calculating the quaternion with
\[\begin{split}x = \cos{(A_r/2)}\cos{(B_r/2)}\sin{(C_r/2)} - \sin{(A_r/2)}\sin{(B_r/2)}\cos{(C_r/2)} \text{,} \\
y = \cos{(A_r/2)}\sin{(B_r/2)}\cos{(C_r/2)} + \sin{(A_r/2)}\cos{(B_r/2)}\sin{(C_r/2)} \text{,} \\
z = \sin{(A_r/2)}\cos{(B_r/2)}\cos{(C_r/2)} - \cos{(A_r/2)}\sin{(B_r/2)}\sin{(C_r/2)} \text{,} \\
w = \cos{(A_r/2)}\cos{(B_r/2)}\cos{(C_r/2)} + \sin{(A_r/2)}\sin{(B_r/2)}\sin{(C_r/2)} \text{.}\end{split}\]
Conversion from quaternion to KUKA-ABC¶
The conversion from a quaternion \(q=(\begin{array}{cccc}x & y & z & w\end{array})\) with \(||q||=1\) to the \(ABC\) angles in degrees can be done as follows.
\[\begin{split}A &= \text{atan}_2{(2(wz + xy), 1 - 2(y^2 + z^2))} \frac{180}{\pi} \\
B &= \text{asin}{(2(wy - zx))} \frac{180}{\pi} \\
C &= \text{atan}_2{(2(wx + yz), 1 - 2(x^2 + y^2))} \frac{180}{\pi}\end{split}\]