# Evaluation of PID-Based Algorithms for UGVs
## 3 Methodology
### On-Orf Controller  
The ON-OFF controller is represented in Figure 3 and operates by switching between two values, meaning that it involves an instantaneous change between two states [30].  
In the context of this study and analysis, several variables play crucial roles in understanding and controlling the system shown in Figure 3. The Target (T) variable defines the desired location on the map, while the Actual Position (AP) variable is the precise position relative to a reference point. The On-Off Error (\(\epsilon_{\text{ON-OFF}}\)) variable represents the position error, where if it exceeds a certain threshold, a new trajectory is calculated. This error is the difference between the desired position (T) and the actual position (AP) of the system. The Angular Value (\(\omega\)r) variable expresses the angular value associated with rotational or curvilinear movement. The Microcontroller (\(\mu\)C) is the \"brain\" of the system, responsible for processing the values obtained from the \"cmd_vel\" topic to control the UGV. The Voltage Right Wheel (VR) and Voltage Left Wheel (VL) variables indicate the voltages applied to the right and left wheels, respectively, of the locomotion system, influencing the movement and direction.  
Based on the desired trajectory, two parallel trajectories were created with a tolerance distance of \(\pm\)0.25 m. Initially, the robot aligns with the desired trajectory. If the robot's position coincides with any point of these parallel trajectories during navigation, the algorithm performs a recalculation between the current position and the destination. This action is repeated until the robot's position is within a 0.25 m radius (R) of the destination.  
The algorithm is as follows (Algorithm 1):  
Figure 3: ON-OFF controller block diagram.  
Algorithm 1 defines a navigation process and decision-making for the UGV's movement. The system is designed to respond dynamically to environmental conditions and the proximity to the destination point. Algorithm 1 begins by setting two main flags: \"Flag_Goal_Reached\" and \"Flag_Rotation\", initially configured as true or false, respectively. The algorithm processes the coordinates until \"Flag_Goal_Reached\" becomes true.  
The first check in the algorithm is the detection of people; if detected, the UGV will stop moving to ensure safety. If no one is detected, the algorithm evaluates whether the destination has been reached. If the goal is reached, the machine stops, and \"Flag_Goal_Reached\" is set to true. If there is a rotation required (i.e., \"Flag_Rotation\" is true), the algorithm checks whether the rotation is complete. If the rotation is finished, the machine stops, and \"Flag_Rotation\" is set to false. If the rotation is not completed, the machine continues rotating, and after 10 s with no position change, the rotation speed is increased.  
If rotation is not needed (i.e., \"Flag_Rotation\" is false), the algorithm checks whether the UGV is within the desired path. If it is not, \"Flag_Rotation\" is reactivated, the machine stops, and the UGV realigns its orientation. If the UGV is within the accepted limits, it continues moving towards the goal, as shown in Figure 4.