# Construction of Robotics and Application of the Optical-Flow Algorithm in Determining Robot Motions
## 2 Methodology
### Experimental Setup and Process to Determine System Parameters
#### 3.3.1 Standard Model for Initial System Parameters  
In the first experiment, the parameters of the system for determining velocity and angle should be calculated. Here, we use a symbol cubic model located in model 2 for the determination. The experimental area is also set up as follows. In the experimental area, we arrange multiple points and determine the positions of these points within the camera's observation coordinate system (Figure 7a). In the camera's observation space, the objects to be recognized move freely. When the objects move through the predetermined points, the camera system will collect recognition images and extract a set of parameters about the object. Specifically, at each point when the object passes by, we will capture the height and position of the object in the image. Figure 6: WLAN data transfer library structure. For each object introduced into the experimental area for training, we will collect two sets of data. First, the data set correlating the object's height in the image (_h_) with the actual distance from the object to the observation camera (distance _d_--through the known positions of the predetermined points). Second, the data set correlating the offset between the recognized object's center and the image center (\(\Delta x\)) with the actual angular offset between the object and the observation camera in the coordinate system relative to the camera (angle _a_--determined through the predefined points in the training area) (Figure 7c). Next, a model of the object is built for the experiment. To establish the correlation function between the distance of the object and the camera and the size of the recognition frame, we set up an experimental environment, as described in Figure 7. The camera is configured with a resolution of 1920 \(\times\) 1080 pixels, a frame rate of 30 frames per second (fps), and observes an area of 720 cm \(\times\) 480 cm. Note that the maximum speed of the camera was 60 fps. In this study, the frame rate is less than the maximum value. The reason for that is to increase the speed of the computer system in determining the object's position and speed. By using a more powerful computer system, the frame rate of the camera can be increased. However, since this study focuses on an inexpensive computer vision technique, the speed of the camera was reduced. The camera is positioned straight at a height of 28.5 cm (without an angle relative to the horizontal plane). The standard sample used by the authors is a 10 cm high wooden pole, placed on a robot that moves randomly within the training area. Using the method for establishing the object's correlation function as presented in Section 2, we will obtain a set of parameters for 77 points within the training area (as described in Figure 7a). With the obtained parameter set, we developed a program to find the correlation function between \(d\) (cm) and \(h\) (pixels) (Figure 7); and the correlation function between \(a\) (degrees) and _\(\Delta x\)_ (pixels) (Figure 7a); specifically, as follows:  
Figure 7: (**a**) The layout of the training area; (**b**) The actual training area; (**c**) Image height and the offset between the object’s center and the image center. \[*d(h)=16249\times h^{-0.989} \tag{8}\] \[*\alpha(\Delta x)=0.00335\times\Delta x-0.027\]  
Note that due to the axis misalignment, Equation (8) shows a minus value of 0.027, which is different from Equation (5) for the ideal case. To evaluate the reliability in determining the position and direction of the object using the correlation function (8), we continued to move the sample object through 77 points in the training area (with known actual positions and angles), thereby identifying the error between the actual distance d and the measured distance d obtained using the recognition program and the estimation function (8) (as described in Figure 8b). Similarly, the error in determining the object's movement direction is described in Figure 9b.