Performance of a Wall-Following Robot Controlled by a PID-BA using Bat Algorithm Approach

: A wall-following robot needs a controller that applies the closed-loop concept to move actively without hindrance. Some controllers with good capabilities can act as controllers for wall follower robots, such as PID controllers. Conceptually, this controller's good performance depends on tuning the three gains before use. Instead of giving the expected and appropriate output, wrong settings will provide inaccuracies for the controller, so applying the manual method at the tuning stage is not recommended. For this reason, PID controllers are often implemented in a system supported by appropriate optimization methods, such as Genetic Algorithm or Particle Swarm Optimization. Furthermore, different from this, in this study, the Bath Algorithm is used as an alternative optimization algorithm. Its application begins with a realistic simulation of a wall-following robot. This is done to provide the possibility to implement online PID controllers and BAs. In the end, several methods are compared to find out the performance of this type of approach. Moreover, based on the observed comparative results, the proposed method gives a better value in accumulative error and convergence speed in the PID optimization process.


Research Method
PID is an essential approach for controller application and has been widely used because it is convenient and has high reliability to regulate process variables (Sekarsari & Tata, 2021). PID is the abbreviation of its three constituent components, P as proportional, I as integral, and D as derivative. In this research, the design of the system WFR-PID controller is simulated through MATLAB due to the possession of the actual hardware. The simulation system consists of a modelling sensor and PID control; thus, the robot sim will be capable of doing the wall-following task.

Sensor Modelling
Sensor modelling is applied to create an accurate sensor simulation. In this case, the wallfollowing robot requires a measuring instrument that can be used to calculate the distance between itself and the arena wall. The sensor has a duty as a unit of distance measurement. To realize this task function, sensor modelling is designed based on arithmetic modelling for the intersection of two lines.

Figure 2 Lines Segment
In order to comprehend the measurement model, we use an analogy if the sensor location point is the initial measured distance/range sensor observed. Therefore, logically when the sensor's beam emits towards its bearing and does not detect anything, then the vector formed is just a line vector with a magnitude of max range in the direction according to the bearings.
On the other hand, if the sensor detects an obstacle in a specific bearing, the sensor vector line will be cut off and end at the point of intersection. Hence, a function is created in MATLAB to realize this model, which helps the sensor detect obstacles. According to vector cross products applied to build this function. First, we define the 2-dimensional vector cross product, Equation 1: Suppose the two-line segments run from to + and to + . Then any point on the first line is representable as + (for a scalar parameter ) and any point on the second line as + (for a scalar parameter ).

Figure 3 Vector Cross Product
The intersection of those two lines can be determined by the equation 2 below: Cross both sides with , getting Equation 2: And since × = 0, this means Equation 3: Furthermore, therefore, solving for Equation 4: In the same way, can be solved through Equation 5: To reduce the number of computation steps, it is convenient to rewrite this as follows (remembering that × = − × ), Equation 6: Based on the created function, there will be three reference cases that occur in the sensor measurement model such as: 1. If × = 0 and ( − ) × ≠ 0, the two lines are parallel and non-intersecting.
3. Otherwise, the two-line segments are not parallel but do not intersect.

Figure 4 Measurement Modelling
By knowing the point of intersection when the laser scanner detects an obstacle, we can implement the measurements model (Goldman, 1990). Thus, sensor modelling as the measurement approach can be achieved through these sequential steps. The robot is assigned for exploration by following the arena wall, and the robot can measure its distance from the obstacles yielded by sensor modelling. The next phase, which has yet to be described, is how to make the wall follow the robot is maintained distance from the wall. Process controls are necessary for designing a safe automation environment. A variety of process controls are used to manipulate processes; however, the most simple and often most effective is the PID controller. The controller attempts to correct the error between a measured process variable and desired set point by calculating the difference and then performing a corrective action to adjust the process accordingly. A PID controller controls a process through three parameters: Proportional (P), Integral (I), and Derivative (D). These parameters can be weighted, or tuned, to adjust their effect on the process. PID controllers allow for much better adjustments to be made in the system. Most robotic applications use a PID controller scheme to allow for much better control and fine-tuning adjustments, Eq 8, Eq 9, Eq 10, Eq 11 see below:

Figure 5 PID Control
In an ideal form, a PID controller's output u(t) is the sum of the three terms, as illustrated in Equation 8, where ( ) is the feedback error signal between the reference and the output.
Proportional control is the first component of PID. From Equation 9, P-control linearly correlates the controller output to the error or provides a linear relationship between a system's error and the system's controller output. As provided in Equation 10, Integral control is a second constructor of the system. It is often used because it can remove any offset that may exist. Thus, the system returns will be able to return to its original setting. A negative error will cause the signal to the system to decrease, while a positive error will cause the signal to increase. The rest constructor is the derivative control. Unlike P-only and I-only controls, D-control is a form of feed-forward control. It predicts the outcome of the process conditions by analyzing the change in error. It has the task of keeping the system in a consistent setting.
The primary benefit of adding D controllers is to resist change in the system, the most important being oscillations. The control output is calculated based on the rate of change of the error with time. The larger the error change rate, the more pronounced the controller response will be (Willis, 1999).

Figure 6 PID-WFR Concept
As illustrated in Figure 6, the PID controller is induced in the velocity adjustment process of the wall following the robot. The mobile robot has the assignment to follow the desired path by maintaining the rotational velocity of each wheel, as shown. Therefore, this concept's objective can only be defined if the designed system can produce several outputs or conditions. Three conditions should be fulfilled according to this analogy.
1. If the robot is too close to the wall, the controller adjusts the rotational velocity; thus, the robot moves away from the wall 2. If the robot is in the ideal position, the controller proceeds the robot to move forward 3. If the robot is too far from the wall, the controller adjusts the rotational velocity; thus, the robot moves towards the wall : We refer set point (SP) as the desired robot distance when moving alongside the wall. As well as process value (PV) as the distance obtained through measurement in each iteration. For instance, when the wall is located on the robot's right side, the measured distance of the robot is 15 cm, where the SP is 10 cm. Thus the current error is −5 , which means the robot has to move closer to the wall by 5 cm. This can be achieved by reducing the right motor speed by = −5 .

Figure 8 PID Tuning
related to how to find the optimum values for each parameter , , and . As represented in the Introduction, these values take work to find. Nevertheless, this issue will be solved by using an optimization technique. As shown above, in Figure 8, the parameters are initially set by trial and error. In order to ease this trial and error stage, it is recommended to adjust the Kp first, followed by Ki and Kd, respectively. The robot's behaviour can be observed by the values adjustment, then defining the upper and lower bound for each parameter. Then proceed to the optimization process after both upper and lower bounds are obtained. New parameters value acquired through the optimization process is applied and evaluated.

Propose Method
Metaheuristic algorithm in recent times is one of the critical research and development areas since it has significant findings. Their capacities to address and provide near-optimal solutions to problems without providing extensive details of the problem concepts have given them an advantage over many traditional techniques. Metaheuristic algorithms are motivated mainly by some real-world phenomena. They are usually a natural optimization technique (Oladipo et al., 2020). The optimization of PID parameters will be approached by heuristic methods such as Bat Algorithm (BA).

1:
Define the objective function f(x) 2: Initialize the bat population xi and vi (i=1,2,…,n) 3: Initialize frequencies fi, pulse rates ri, and loudness Ai 4: Set the iteration counter t = 0 5: while (t<tmax) 6: vary ri and Ai 7: Generate new solutions by adjusting frequencies 8: Update velocities and solutions 9: if rand > ri 10: Select a solution among the best solutions 11: Generate a local solution around the best-selected solution 12: end if 13: Generate a new solution by flying randomly 14: if rand > Ai and f(xi) < f(xj) 15: Accept new solution 16: end if 17: Rank the bats and find the current best solution x * 18: end while The bat Algorithm (BA) was created by Xin-She Yang in 2010, and this algorithm attempts to mimic the main characteristics of microbats' echolocation behaviour. Bats, especially microbats, use echolocation for navigation, emitting short, ultrasonic pulses that typically last a few milliseconds with frequencies ranging from 25 kHz to about 150 kHz. The loudness of such bursts can be up to 110 dB. When homing for prey, microbats typically increase their pulse emission rates and frequencies, which is also accompanied by a variation in their loudness. The primary purpose of such frequency tuning and echolocation is for navigation and hunting to increase the detection accuracy and success rate of capturing the prey. Such characteristics are simulated in the bat algorithm (Slowik & Kwasnicka, 2020).

Figure 9 Bat Algorithm Optimization
The main steps of the BA consist of a single loop with some probabilistic switching during the iteration. As an overview of the proposed method, the optimization problem is finding PID parameters: , , minimizing Root Mean Square Error (RMSE) as an objective function (fitness function). Based on Table 1 and Figure 9, we see the flow process. The bat algorithm executes the computation based on the upper-lower bound initial parameter set. Refers to the function objective; a solution is initialized. While the loop is started, the bats will update frequency and loudness, and later the selection criteria are raised. When the stopping criteria are reached, the final optimum values are generated according to its function objective. The new PID gain value is obtained and later evaluated through mobile robot behaviour.

Robot Arena
Considering that this research is carried out using MATLAB simulations, no real arenas were used. The robot arena was built using MATLAB modelling. There were two types of arenas which were built, spirals and squares. The size of the robot modelling will be adjusted proportionally to the modelled maps; thus, the robot steps will be manageable.

Determine Constraints
Under the methodology illustrated in figure 8, the pre-optimization step is to set the PID parameter on a trial basis. The first step is to give a Kp value and then observe the robot's performance in the arena. If the value of Kp given is sufficient to provide good performance, then these parameters' upper and lower limits are determined. Whether or not the given Kp value can be observed based on the robot's behaviour in the arena. Then proceed with Ki and Kd using the same method. From the trials that were carried out, the data for the upper and lower ranges for each parameter was obtained as follows:

Optimization
Getting the upper and lower bounds for each parameter is the first step for optimization.
Following the proposed method, the optimization approach used is Bat Algorithm. This method is built by determining the parameters of the algorithm itself. The parameters in question are the number of bat populations, the maximum number of iterations, dimensions, objective functions, acoustic vibration ratio, frequency, and amplitude (Robandi, 2021).
Dimensions are reflections of the axes of the lines used. In this program, the dimensions are three because the PID position is determined from 3 parameters, namely Kp, Ki, and Kd. The BA parameter values used are listed in the table below: The optimization produced optimal PID parameter value, and the performance was observed through the RMSE value. The objective function used is the minimum RMSE. The optimization process from iteration to iteration produced a fitness value plotted using a convergence curve graph to determine the level of convergence of the optimization algorithm used. By comparing the level of convergence between the Bat algorithm and PSO. Particle Swarm Optimization was given equal parameter values for iterations and population while the user randomly set the rest. The next convergence curves for each method applied were obtained as follows.

Performance Analysis
The optimum values of the parameters Kp, Ki, and Kd obtained from the optimization process were applied to the wall-following robot. Performance evaluation can be done based on the movement behaviour of the robot in the arena and the RMSE value or dynamic error generated in the entire iteration of the movement. However, when referring to the robot's movement alone, the evaluation cannot be accurate and is subjective. Therefore, the movement behaviour of the robot will be a minor factor that is not considered. Instead, the evaluation is based on the resulting dynamic error value. The dynamic error generated by the experimental set is recorded based on the table below. Following the data presented in the table above, PID parameterization will improve performance when assisted by optimization. PSO is an optimization method used to compare with the proposed method, namely BA. Without needing to discuss parameterization on a trial basis, it can be seen that PID control with PSO produces a dynamic error of 0.1939 in arena-1 and 0.01072 in arena-2. Furthermore, the resulting dynamic error in PID-BA is 0.16278 in arena 2 and 0.01046 in arena 2. Performance improvements can be seen in the "improvement" column. Implementing PID parameter optimization using BA resulted in improvisation, although the difference was insignificant. When adjusted to the convergence curve in figure   13, it can be seen that the optimization for arena-1 does not change much. However, in arena-2, BA appears to be faster in producing fmin values, while PSO requires longer iterations to achieve convergence.

Conclusions
This paper has shown the performance of a wall-following robot controlled by a PID-BA. The role of the BA was to produce proper values of three unknown parameters of the PID controller in the wall-following robot application. The PID controller performance was evaluated through the dynamic error generated by the PID controller. Different approaches were simulated and compared. Based on the comparative results, we can conclude that Bat Algorithm, inspired by bat echolocation behaviour, produces better performance in both terms of dynamic error produced and convergence rate.