Short Question:
As demonstrated in the image below, how can I calculate the rotation matrix that relates the base coordinate and the rectangle coordinate, given 3 known points P1, P2, P3 on the surface of the rectangle with respect to the base coordinate?
Long Question:
I am currently working on OMRON pick-and-place robots. Basically, the overall layout of the system is similar to what is shown in the following picture:
The system has a rotary encoder that reflects the conveyor belt motion.
What I am trying to do is to come out with a transformation matrix T that represents the belt with respect to the robot coordinates. This transformation matrix is automatically calculated using a calibration wizard, however I am trying to understand how such matrix is calculated based on the 3-point belt calibration carried out as below:
Simple Calibration Steps:
The calibration can simply be completed after teaching 3 points on the belt as shown in the following image:
The steps are as follows:
- A product is placed on the belt at the upstream limit that a robot can start tracking the product from.
- The robot tip is then placed on the product. Its location and the encoder value are recorded. Let the point be P1 and encoder value be E1.
- The belt is then allowed to move in the product feeding direction until the it reaches to another location which the robot tip can reach.
- Robot tip is placed on top of the product. This is the second calibration point P2. The encoder value is also recorded. Let it be E2.
- Lastly the robot tip is moved and placed on the calibration product on a side location of the belt called
downstream pick limit
. This would be the the third point P3 and it is recorded.
After I followed these steps for a test robot in hand, I got the following quantities:
$$P_1 = \begin{bmatrix}-286.8 & -338.0 & 244.6\end{bmatrix} ; E_{1}=-71873$$
$$P_2 = \begin{bmatrix}140.3 & -422.2 & 246.7\end{bmatrix} ; E_{2}=-158710$$ $$P_3 = \begin{bmatrix}-18.004 & -590.452 & 248.746\end{bmatrix} $$
Let b = [bx by bz] be a belt point. Since the belt motion is having a magnitude along the x direction, then the scale factor in units of mm/pulses can be calculated by:
$$s = \frac {|P2-P1|}{E2-E1} = \frac {\sqrt{(140.3-(-286.8))^2 + (-422.2 -(-338.0))^2 + (246.7-244.6)^2}}{−158710 -(-71873)} =-0.005013$$
This is one important scale factor that we need to calculate during the calibration process (the minus sign means the encoder counts opposite to belt rotation)
Along with this scale that we get during calibration, we need to calculate all members of the transformation matrix T which relates belt coordinates with robot coordinates. This has the rotation matrix R and translation matrix D. $$ p=Tb = \begin{bmatrix}& R & & D\\ 0 & 0 & 0 & 1 \end{bmatrix}b $$
$$p=\begin{bmatrix} p_x \\ p_y\\ p_z\\ 1 \end{bmatrix} = \begin{bmatrix} r_{11} & r_{12} & r_{13} & d_{x}\\ r_{21} & r_{22} & r_{23} & d_{y}\\ r_{31} & r_{32} & r_{33} & d_{z}\\ 0 & 0 & 0 & 1\\ \end{bmatrix} \begin{bmatrix} b_x \\ b_y\\ b_z\\ 1 \end{bmatrix} $$
Since b always has one component along the x axis of the belt, then the coordinate of the first calibration point with respect to belt coordinate is (Belt did not move yet): $$ b_1 = \begin{bmatrix} 0 \\ 0\\ 0\\ 1 \end{bmatrix} $$
and the coordinate of the second calibration point with respect to belt coordinate is (Belt moved from P1 to P2):
$$ b_2 = \begin{bmatrix} s\times(E2-E1) \\ 0\\ 0\\ 1 \end{bmatrix} = \begin{bmatrix} 435.3 \\ 0\\ 0\\ 1 \end{bmatrix} $$
Therefore, from P1 calibration, we have:
$$p_1=\begin{bmatrix} −286.8 \\ −338.0\\ 244.6\\ 1 \end{bmatrix} = \begin{bmatrix} r_{11} & r_{12} & r_{13} & d_{x}\\ r_{21} & r_{22} & r_{23} & d_{y}\\ r_{31} & r_{32} & r_{33} & d_{z}\\ 0 & 0 & 0 & 1\\ \end{bmatrix} \begin{bmatrix} 0 \\ 0\\ 0\\ 1 \end{bmatrix} $$
Solving for T matrix members, we get dx = −286.8, dy = −338.0 and dz = 244.6
From P2 calibration, we have: $$p_2=\begin{bmatrix} 140.3 \\ −422.2\\ 246.7\\ 1 \end{bmatrix} = \begin{bmatrix} r_{11} & r_{12} & r_{13} & −286.8\\ r_{21} & r_{22} & r_{23} & −338.0\\ r_{31} & r_{32} & r_{33} & 244.6\\ 0 & 0 & 0 & 1\\ \end{bmatrix} \begin{bmatrix} 435.3 \\ 0\\ 0\\ 1 \end{bmatrix} $$
Solving for the Rotation matrix, we get: $$ R = \begin{bmatrix} 0.981112257 & r_{12} & r_{13}\\ -0.193378015 & r_{22} & r_{23}\\ 0.004866365 & r_{32} & r_{33} \end{bmatrix} $$
Based on OMRON calibration wizard, the following matrix is obtained after finishing teaching the 3 points: $$ T = \begin{bmatrix} 0.981112257 & -0.193427089 & 0.00216786 & −286.8\\ -0.193378015 & -0.981022085 & -0.01416372 & −338.0\\ 0.004866365 & 0.013476983 & -0.999897339 & 244.6\\ 0 & 0 & 0 & 1\\ \end{bmatrix} $$
As seen, the first column and 4th conform with the results that we got. However, I am not really sure what the mathematical way to follow using the third calibration point to calculate the rest of the transformation matrix that I have. How would I be able to calculate r12, r22, r32, r13, r23 and r33?
-EDIT: (Response to the answer provided by @50k4)
I have tried your equations to find P4
for a sample coordinate that I got from the Google Sketchup 3D Designer, however I am getting big illogical values a
and b
and consequently for its x
, y
and z
. I created a Google sheet which contains the design with assigned values of each point and I also implemented your equations in it to calculate a, b, and P4 as well as $\vec v_1 = P_3 - P_4$ and $\vec v_2 = P_1 - P_4$. Here is the link for this sheet that I shared and can be publicly edited:
https://docs.google.com/spreadsheets/d/1XGTqjk7kfwNi0hfktoVEtkkTNgrD1LUz8ui2Tyu455Y/edit?usp=sharing
Why I Need to Know This in The First Place!
I am an experienced software engineer with robotics and control engineering qualification. I am planning to program 3D models and create a simulation platform and solve a problem in hand for the robotics world. Clear understanding of this field in mathematics is required.