# Evaluation of PID-Based Algorithms for UGVs
## 3 Methodology
### PID Controller
#### 3.4.4 PID Vector Field  
The algorithm is shown in pseudocode below (Algorithm 5) and presented in Figure 12. It is somewhat different from the others, as it also uses PID control, but its error is derived from the vector sum of the virtual forces encountered during navigation. The pseudocode presents a dynamic strategy for the UGV's navigation, incorporating multiple checks and calculations to ensure a precise and safe trajectory. The process begins with a check for \"No_Goals\", which returns FALSE if no goals are defined, preventing the algorithm from proceeding without a clear purpose. Next, two flags are initialized: \"Flag_Goal_Reached\" and \"Flag_Rotation\". The first starts as FALSE, indicating that the goal has not yet been reached, while the second is initialized as TRUE, signaling the need for rotation. The core of the algorithm is a loop that continues until the goal is reached (\"Flag_Goal_Reached\" = FALSE). During each iteration, a priority check for person detection is performed. If a positive detection occurs, the UGV is immediately halted, prioritizing safety. In cases where rotation is required (\"Flag_Rotation\" = TRUE), the algorithm evaluates whether the UGV is not aligned and whether 10 s have passed without positional change. If both criteria are met, the UGV is directed to rotate. Otherwise, the original position is updated, and the \"Flag_Rotation\" is deactivated. When rotation is no longer needed (\"Flag_Rotation\" = FALSE), the algorithm checks whether the goal has been reached. If the goal is met, the machine stops, and \"Flag_Goal_Reached\" is activated. If the goal has not been reached, the algorithm enters a series of calculations involving the \"S_Star\" error (for linear trajectory control) and the \"Tau_Error\" (for angular orientation control). This algorithm is based on the concept of following a trajectory by creating a vector field around the path to be followed. The vectors in this field provide orientation commands to guide the robot towards the desired trajectory. The goal is not to follow a moving point, but rather to position the robot along the trajectory as it moves. The vectors in this field are directed toward the path that should be followed, following the desired direction of navigation [40]. These vectors act as orientation  
Figure 11: Trajectory with the CTE + H algorithm. commands for the robot. As shown in Figure 13, which represents a sample of a vector field between the start and the destination (black arrows), this approach directs the robot (red arrow) along the line between points from the start of its navigation. ```
IF No_Goals = TRUE  RETURN FALSE  Flag_Goal_Reached = FALSE  Flag_Rotation = TRUE  WHILE Flag_Goal_Reached = FALSE: IF detect_people = TRUE: \(V_{L}=0\) and \(V_{R}=0\) (STOP MACHINE) ELSE: IF Flag_Rotation = TRUE  IF Not_Aligned AND 10_Seconds_Passed_Without_Changing_Position: \(v=0\) and \(\omega\
eq~{}0\) (ROTATE MACHINE) ELSE:  Original_Position = Actual_Position  Flag_Rotation = FALSE  else: \(\chi^{f}=atan2(w2_{y}-w1_{y}~{},~{}w2_{x}-w1_{x})\)  S\({}^{*}=\frac{(z-w1)^{T}(w2-w1)}{||w2-w1||}\) \(\epsilon=||z-(\text{S}^{*}*(w2-w1)+w1)||\) \(\rho=sign((w2-w1)*(z-w1))\) IF S\({}^{*}\geq 1\): \(V_{L}=0\) and \(V_{R}=0\) (STOP MACHINE)  Flag_Goal_Reached = TRUE  Flag_Rotation = TRUE  IF S\({}^{*}<1\): \(\epsilon=\rho*\epsilon\) IF \(|\epsilon|>\tau\): \(\chi^{d}=\chi^{f}-\rho*\chi^{e}\) IF \(|\epsilon|\leq\tau\): \(\chi^{d}=\chi^{f}-\chi^{e}\big{(}\frac{\kappa}{\tau}\big{)}^{k}\)  Angular PID \(\omega=K^{\rho}_{p}\chi^{d}+K^{\theta}_{i}\int\chi^{d}~{}dt+K^{\theta}_{d} \frac{\chi^{d}}{dt}\) Linear PID \(v=K^{linear}_{p}\text{S}^{*}+K^{linear}_{i}\int\text{S}^{*}~{}dt+K^{linear}_{d} \frac{\text{dS}^{*}}{dt}\) \(V_{L}=v-\frac{t}{2}\omega\) AND \(V_{R}=v+\frac{t}{2}\omega\)
```  
**Algorithm 5** PID Vector Field controller. The concept of vector fields, as shown in Figure 14, is comparable to that of potential fields, which have been widely used as a tool for trajectory planning.