## 2 Materials and Methods
### Robot Control  
The control algorithm of the robot is explained in this section. Generally, two control schemes can be considered for this robot. The global control strategy is responsible for keeping the robot inside the desired region and navigating the robot toward the closest tennis balls. Meanwhile, the local control strategy is responsible for the robot's collision prevention and collision passing maneuvers. A flowchart of these robot control strategies is shown in Figure 10. After starting the operation, first, the robot position was checked manually or autonomously based on the LiDAR data and the 2D map generated by the Hector SLAM. If the robot's position was not inside the desired region, then the position revise function was called, and the position revising maneuver was implemented. If the robot's position was not inside the desired region, then the camera frame was captured and analyzed using the YOLO algorithm. At this stage, if the robot did not find a tennis ball, the search function was called as mentioned in the navigation and path planning section. If the YOLO algorithm found the tennis balls, the number of pixels related to the detected balls in each of the 15 camera frame regions was calculated. Considering the pixel numbers, the path planning algorithm identified the desired heading angle of the robot, and this value was used as a reference input for the fuzzy controller. The fuzzy controller was responsible for navigating the robot toward the planned route by regulating its heading angle. However, during this navigation process, the priority was always the collision prevention algorithm. If the ultrasonic sensors sent feedback that detected an object in the robot's way, the motion control of the robot was broken up, and a predefined object pass maneuver was implemented. Then, the path planning and fuzzy control stages were implemented again. Figure 9: Scenario 3: the closest set of tennis balls was accumulated left (**A**) or right (**B**) of the robot heading. Fuzzy Controller Design  
In this study, a fuzzy controller was developed and implemented to control the heading angle and speed of the motors. The general architecture of the controller is shown in Figure 10. First, the user specified a PWM value for the robot's forward movement. This value was responsible for the speed of the robot when it moved in a forward direction, and the reference heading angle \(\theta_{d}\) was equal to zero. By running the controller, the reference heading angle \(\theta_{d}\) was identified using the algorithm explained in the Section 2.5. Afterward, the controller calculated the \(PWM\) values of the right and left wheels (see Figure 11). The construction of a fuzzy inference system (FIS) refers to the act of constructing a map between a given input and an output using fuzzy logic. After the mapping has been established, decisions and patterns can be identified. The FIS applied in this paper was the Mamdani technique, which is a well-recognized method for capturing expert knowledge. This allowed us to describe the knowledge in ways that were more approachable and straightforward. However, fuzzy inference of the Mamdani kind is computationally intensive [24; 25]. Based on the sign of the reference heading angle \(\theta_{d}\), \(PWM\) signals were calculated by the fuzzy controller, and the updated PWM signals were sent to the left (\(PWM_{L}\)) and right (\(PWM_{R}\)) motors. Figure 11: General architecture of the controller. Figure 10: A flowchart of the robot control strategies. The difference between the speed of the left and right motors resulted in the rotation of the robot in the desired direction. The new heading angle was calculated considering the difference between the rotation angles of the left and right wheels (Figure 12).