# Evaluation of PID-Based Algorithms for UGVs
## 3 Methodology
### PID Controller
#### 3.4.3 PID CTE + H  
The PID CTE + H controller autonomously manages the UGV's linear and angular trajectories using a set of two PID controllers, as depicted in Figure 10. This nonlinear controller consists of two distinct parts. Initially, the reference angle, \(\theta\), is obtained from the trajectory planning system, the \"Path Planner\". In the block diagram, the external loop provides feedback by comparing the robot's current trajectory with the planned trajectory provided by the \"Path Planner\". The obtained value is then converted into a correction angle through a proportional controller with a gain, Kct, resulting in a correction term, \(\varphi\). This correction is subtracted from the \(\theta\) value to obtain the new desired \(\theta\), which will be the new reference input for the internal loop of the block diagram. This internal loop, in turn, uses the current orientation with feedback to calculate the necessary actuation effect. In this context, several variables play crucial roles in understanding and controlling the system depicted in Figure 10. The variable \"Bearing of the path\" (\(\phi\)) represents the orientation the system should follow relative to a reference point. The \"Distance from point to line\" (DDFPL) measures the perpendicular distance between a specific point and the reference line. This measure helps evaluate how close the system is to the desired route and correct any deviations. The \"Cross track error\" (e_CTE) measures the lateral deviation of the system from the desired trajectory. It indicates how far the system is from the planned route and is used to calculate corrections. The \"Gain\" (KCT) is a multiplicative factor applied to certain variables or controller actions. It regulates the intensity of corrections or system responses as needed. The \"Corrective turn angle\" (\(\varphi\)) determines the angle by which the system must adjust to correct deviations from the planned trajectory, guiding the system back onto the correct route. The \"Desired Heading\" (\(\theta\)DCs) represents the desired orientation or the angle the system should achieve or maintain. The \"Target\" (T) defines the desired location on the map. The \"Actual Position\" (AP) is the precise position relative to a reference point. The \"Heading Error\" (\(e_{Head}\)) is the error between the desired angle (\(\theta\)Des) and the actual angle (\(\theta\)) of the system. The \"Position Error\" (ePos) is the error between the desired position (T) and the actual position (AP) of the system. The \"Angular Value\" (\(\omega\)r) expresses the angular value associated with rotational or curvilinear motion. The \"Linear Value\" (Vr) represents the system's linear motion, and the \"Actual Heading\" (\(\theta\)) indicates the current orientation or real angle of the system. Figure 10: CTE + H controller. The \"Microcontroller\" (uC) is the system's \"brain\", responsible for processing the values obtained from the \"cmd_vel\" topic for UGV control. The \"Voltage Right Wheel\" (VR) and \"Voltage Left Wheel\" (VL) represent the voltages applied to the right and left wheels, respectively, of the locomotion system to influence movement and direction. The CTE + H algorithm is shown in the pseudocode below (Algorithm 4) and is presented as depicted in Figure 11. It is a more complex algorithm than the previous ones because it includes both error variables from the earlier algorithms. This algorithm can be characterized as the integration of the PIDH and PIDCTE algorithms.