# SambotII: A New Self-Assembly Modular Robot Platform Based on Sambot
## 5 Self-Assembly of SambottII
### LED-Camera Unit  
In order to determine the angle between two docking surfaces, a LED-camera unit is designed and a three-step measurement method is proposed. The first step is to determine the relationship between the horizontal distance x of the adjacent LED lights showed in captured image and the actual distance L between the two docking surfaces. The LED identification algorithms can be used to find out the LEDs in complex backgrounds and determine their positions in the image, as shown in Figure 11, where each LED is marked by a red rectangle. Then, one can work out the value of x. In this step, it is assumed that the two docking surfaces are parallel to each other. The measurement principle is shown in Figure 12a. In Figure 12, L represents the distance between the passive and active docking surfaces, \(f\) denotes the focal distance of the camera, and z is the distance between the camera lens and the active docking surface. In Figure 12a, X is the horizontal distance between the two upper adjacent LED lights on the passive docking surface (also see Figure 8b), and x is the distance calculated from the pixel length that X showed in camera image  
According to the principles of similar triangles and perspective projection, one can get:  
\[\frac{x}{f}=\frac{X}{L+z} \tag{18}\]  
It can be rewritten as:  
\[(L+B_{1})x+D_{1}=0 \tag{19}\]  
Where:  
\[B_{1}=z,\ D_{1}=-fX \tag{20}\]  
Similar to the case of laser-camera unit, the two unknown coefficients B and D can be determined by experimental calibration. From Formula (19), \(x\) can be expressed as:  
\[x=\frac{-D_{1}}{L+B_{1}} \tag{21}\]  
Figure 11: Results of the LED-identification algorithms. Figure 12: Principles of the LED measurement method. (**a**) Top view that shows the measurement principle in the horizontal direction; and, (**b**) A side view that shows the measurement principle in the vertical direction. The second step is to determine the average vertical distance of the two adjacent LED lights shown in the image at distance L. Here, L is obtained by the LED-camera unit rather than the laser-camera unit. The laser-camera unit can obtain the distance between the camera and the laser spot, however, the distance between the camera and the horizontal center of LEDs (middle of \(Y_{1}\) and \(Y_{2}\)) is required. It is hard to assure that the laser spot just locates at the center of LEDs. Thus, if the distance that is obtained by laser is used, it may cause unpredictable error in the result of angle measurement. As shown in Figure 12b, \(Y_{1}\) and \(Y_{2}\) are the vertical distances of the adjacent LED lights and \(\overline{Y}\) is their average value, i.e., \(\overline{Y}=(Y_{1}+Y_{2})/2\). While, \(y_{1}\) and \(y_{2}\) are the images of \(Y_{1}\) and \(Y_{2}\) projected in the camera. The average value of \(y_{1}\) and \(y_{2}\) is \(\overline{y}\), i.e., \(\overline{y}=(y_{1}+y_{2})/2\). Similarly, one can get:  
\[\frac{\overline{y}}{\tilde{f}}=\frac{\overline{Y}}{L+z} \tag{22}\]  
It can be rewritten as:  
\[(L+B_{2})\overline{y}+D_{2}=0 \tag{23}\]  
where  
\[B_{2}=z,\ D_{2}=-f\overline{Y} \tag{24}\]  
Using the same calibration method, one can obtain the relationship between \(\overline{y}\) and L as:  
\[L=\frac{-D_{2}-B_{2}\overline{y}}{\overline{y}} \tag{25}\]  
The last step is to determine the angle \(\theta\) between the two docking surfaces. As shown in Figure 13, the two docking surfaces are not parallel to each other in a practical situation. Therefore, the horizontal distance X shown in the image is actually its projection (\(\widetilde{X}\)) in the direction of the active docking surface. From Figure 13, it can be obtained that:  
\[(L+B_{1})x+D_{1}=0 \tag{19}\]0  
When considering the distance showed in the captured image, one has:  
\[(L+B_{1})x+D_{1}=0 \tag{19}\]1  
Contrarily, the average vertical distance y only depends on the distance L between the two docking surfaces and it is not affected by \(\theta\). \[(L+B_{1})x+D_{1}=0 \tag{19}\]2 Top view of the actual position of the two docking robots.