# SambotII: A New Self-Assembly Modular Robot Platform Based on Sambot
## 5 Self-Assembly of SambottII
### Laser-Camera Unit  
As is known, the idea of laser triangulation means the formation of a triangle by using a laser beam, a camera and a targeted point. The laser-camera unit consists of a laser tube and a camera, both of which are installed parallel on the vertical middle line of the active docking surface (see Figures 3a and 8a). Due to the actual machining and installation errors, the optical axes of the camera and laser may be inclined to some extent (see \(\alpha\) and \(\beta\) showed in Figure 9). Here, \(\alpha\) indicates the angle between the central axis of the laser beam and the horizontal line, while \(\beta\) represents the angle between the camera and the horizontal line. Theoretically speaking, the position of the laser spot that is projected in the camera image (x) changes with the distance between the object and the active docking surface. In Figure 9, the 'Surface' denotes the active docking surface and the right panel refers to a target object. The parameter x stands for the distance between the laser projection spot and the central point of the captured image. The x is calculated by the number of pixels, y denotes the actual distance between the active docking surface and the measured object, and z is the distance between the camera lens and the active docking surface. The parameter \(d\) is the vertical distance between the center of camera lens and the emitting point of the laser beam. \(f\) represents the focal distance of camera and \(l\) is the distance between the laser tube and surface. According to the principle of similar triangles and the perspective projection theory, one can get:  
\[b=\tan\alpha(l+y) \tag{1}\]  
Figure 8: The positions of camera, laser tube and LED lights. (**a**) The relative position of camera and laser tube; and, (**b**) The relative distances of four LED lights on a passive docking surface. X = 60 mm and \(Y_{1}=Y_{2}=35\) mm. Figure 9: Principle of distance measurement. \[a+c=d-b \tag{2}\]  
\[\tan(\gamma+\beta)=\frac{a+c}{z+y}=\frac{(x+f\tan\beta)\sin(90^{\circ}-\beta)}{f \frac{1}{\cos\beta}-(x+f\tan\beta)\cos(90^{\circ}-\beta)} \tag{3}\]  
From Formulas (1)-(3), one can obtain:  
\[Axy+Bx+Cy+D=0 \tag{4}\]  
where  
\[A=\cos\beta-\tan\alpha\sin\beta \tag{5}\]  
\[B=z\cos\beta+d\sin\beta-\tan\alpha\sin\beta\cdot l \tag{6}\]  
\[C=f\left[\sin\beta+\tan\alpha\left(\frac{1}{\cos\beta}-\tan\beta\sin\beta \right)\right] \tag{7}\]  
\[D=f\left[\sin\beta(z+d\tan\alpha)-d\frac{1}{\cos\beta}+l\tan\alpha\left(\frac {1}{\cos\beta}-\tan\beta\sin\beta\right)\right] \tag{8}\]  
Based on Formulas (4)-(8), one can determine the relationship between x and y. The values of coefficients A, B, C, and D can be obtained by using the methods of experimental calibration and the least square estimation algorithm. Figure 10 shows the calibration process of the laser-camera unite. The distance between the camera and target is marked as \(y_{i}\) (e.g., In Figure 10\(y_{i}\) = 0.2 m), and the vertical distance between the laser point and the center of image shown in camera was marked as \(x_{i}\). In the calibration process, n pairs of \(x_{i}\) and \(y_{i}\)(\(1\leq i\leq n\)) can be obtained by putting the camera at different distances from 50 mm to 300 mm for several turns. The sum of the squared-residual is defined as:  
Figure 8:0  
In order to estimate the optimal values of A, B, C and D, S must be minimized. So, the following equations should be simultaneously satisfied:  
Figure 8:1  
Figure 8:2 The calibration process of the laser-camera unit. Figure 8:3 Figure 8:4  
Then, a system of linear equations can be derived, as below:  
\[\left[