## 2 Materials and Methods
### Navigation and Path Planning  
In this section, the motion control principles of the developed UGV are explained. In this study, global path planning was restricted to the tennis court boundaries determined by LiDAR and Hector SLAM. The robot executes the local path planning algorithm in accordance with the identified boundaries. The design of a path-planning algorithm based on a single camera and local path-planning is one of the most important contributions of this study. It is a common technique to install a camera on top of a tennis court that is responsible for identifying the position of the robot and tennis balls in the global coordinate system. This method of path planning is not applicable to all courts and players because it is challenging and expensive to install cameras on the courts' roofs. A cable-driven robot system is a common and expensive system that can be utilized for this purpose. Another challenge is to develop a wireless communication system between the camera and the robot for implementing the outcomes of the global path planning algorithm. This research tried to eliminate common global path planning by using a camera mounted on top of the tennis court. Using a single camera and the developed algorithm, the local coordinate system was utilized to control the robot. This strategy made the system flexible and able to be used standalone in every tennis court across the world without any necessary modifications or special equipment. The study's goals were as follows:  
* Searching for the working environment of the tennis balls. * Path planning for the robot to the nearest balls using a single webcam. * Collision detection and obstacle avoidance. * Calculating the desired heading angle for the navigation of the robot. At the starting point, if the robot did not detect any tennis ball, the search function was called. While implementing the function, the robot began to rotate around itself in a clockwise direction where the right wheels rotated backward and the left wheels rotated forward. Using feedback from wheels' encoders, the robot counted the number of balls and the related number of pixels every 10 degrees and recorded them in a matrix. A greater number of pixels identified the desired direction of motion. In this study, the main hypothesis in the path planning of the robot using a single camera, and in absence of the ball's depth information, was \"a higher number of pixels shows the nearest tennis ball and has a higher priority\". Based on this hypothesis, the camera frame was divided into 15 regions as shown in Figure 6.  
Figure 6: The camera frame was divided into 15 regions. \(\alpha\): camera field of view; L: camera horizontal field of view; D: Distance to object. During the ball collection mission, the robot moved toward the region that includes a higher number of tennis ball pixels, which is the direction of the nearest tennis ball. It is necessary to map a camera frame with the robot reference frame for this purpose. I.e., the desired heading angle should be identified for every 15 regions. There are three possible scenarios to control the heading angle of the robot. If the greater number of pixels related to the tennis balls belong to regions 3, 8 or 13, the robot should go forward to collect the closest ball set (Scenario 1--Figure 7). In this scenario the desired heading angle or reference input of the controller is \(\theta_{d}=0\). If the greater number of pixels related to the tennis balls belong to regions 2, 7 or 12, the robot should turn left slightly for \(\theta_{d}=-16.7^{\circ}\) to collect the closest ball set (Scenario 2A--Figure 8). If the greater number of pixels related to the tennis balls belong to regions 4.9 or 14, the robot should turn right slightly for \(\theta_{d}=+16.7^{\circ}\) to collect the closest ball set (Scenario 2B--Figure 8). Figure 8: Scenario 2: the closest set of tennis balls was accumulated slightly left (**A**) or slightly right (**B**) of the robot heading.