# Design, Fabrication, and Control Algorithm of Self-Reconfigurable Modular Intelligent Vehicles
## 4 Visual Positioning Algorithm  
With regard to identifying graphic codes, we make a comparison between various graphic codes, including the HoloBar code, which is robust to image occlusion [15], and AprilTag is finally selected mainly because of its simplicity, allowing a fast calculation in the main control vehicle. In the self-reconfiguration motion control of modular vehicles, AprilTag [16; 17] is first identified via a monocular camera so as to evaluate the spatial location and attitude of the vehicle [18]. Afterwards, the position and attitude are adjusted accordingly to ensure its movement in a preset route. According to the requirement of positioning accuracy, the size of AprilTag is designed as 4 \(\times\) 4 cm, and AprilTag is attached to the vehicle. The center of AprilTag is identical to the center of the modular vehicle (Figure 10). Figure 10: Modular vehicle with AprilTag. The image captured by the monocular camera goes through processes, such as image enhancement, image binarization, image filtering [19], AprilTag extraction and decoding, and position calculation, and is finally utilized to evaluate the position and attitude (Figure 11). After the identification and decoding of AprilTag in the image, the spatial position and attitude of the modular vehicle can be estimated. The geometric center of the AprilTag of each vehicle coincides with the geometric center of the modular vehicle with the same positive direction. An OpenMv camera is installed on the main control vehicle, and the AprilTag on three submodule vehicles is photographed from a certain angle. The spatial position of each modular unit relative to the main unit can be obtained by detecting each AprilTag (Figure 12). The pitch angle of OpenMv is adjusted to ensure that each modular unit has a sufficient range of movement, and AprilTag can be accurately identified. Equation (10) gives a method for estimating the field of view range. \(\theta\) is the angle of view, \(w\) and \(h\) are the width and height of the view, and/\(f\) is the camera focal length. \[\theta=2\times\arctan(\frac{\sqrt{w^{2}+h^{2}}}{2f}) \tag{10}\]  
After calculation and debugging, the intersection angle between the OpenMv camera and the horizontal line is 43\({}^{\circ}\), and the motion range is a 45 \(\times\) 65 cm rectangle plane in front of the main modular vehicle (Figure 13). Figure 11: Image processing procedure. Figure 12: Position and attitude identification of a modular vehicle. A coordination system is established for the picture taken by OpenMv, with O\({}_{\text{C}}\) as the center point of the picture, the forward direction of the modular vehicle as the Y-axis, and the right translation direction of the main control car as the X-axis, as shown in Figure 14. Through the identification and positioning of AprilTag, the coordination and attitude of the modular vehicle in the OpenMv coordinate system can be obtained. The position and attitude information of the modular vehicle is packaged and output through the serial port, as shown in Figure 14, where T\({}_{\text{X}}\), T\({}_{\text{Y}}\), and T\({}_{\text{Z}}\) represent the coordinate of the modular car in the OpenMv coordinate system, R\({}_{\text{X}}\) represents the rotation angle of the modular car around its own X-axis, R\({}_{\text{Y}}\) represents the rotation angle of the modular car around its own Y-axis, and R\({}_{\text{Z}}\) represents the current yaw angle of the modular vehicle. When the number of submodule vehicles that can be detected in the main module car's view is inconsistent with the preset number, for example, the submodule vehicle goes beyond the field of the camera view or AprilTag cannot be recognized, the main module vehicle will track and rotate within a certain range until a sufficient number of submodule vehicles are captured. The captured vehicles will be gathered in the same visible field according to the instructions of the central control vehicle.