Optimal Fuzzy Controller Design for Autonomous Robot Path Tracking Using Population-Based Metaheuristics

In this work, we propose, through the use of population-based metaheuristics, an optimization method that solves the problem of autonomous path tracking using a rear-wheel fuzzy logic controller. This approach enables the design of controllers using rules that are linguistically familiar to human users. Moreover, a new technique that uses three different paths to validate the performance of each candidate configuration is presented. We extend on our previous work by adding two more membership functions to the previous fuzzy model, intending to have a finer-grained adjustment. We tuned the controller using several well-known metaheuristic methods, Genetic Algorithms (GA), Particle Swarm Optimization (PSO), Grey Wolf Optimizer (GWO), Harmony Search (HS), and the recent Aquila Optimizer (AO) and Arithmetic Optimization Algorithms. Experiments validate that, compared to published results, the proposed fuzzy controllers have better RMSE-measured performance. Nevertheless, experiments also highlight problems with the common practice of evaluating the performance of fuzzy controllers with a single problem case and performance metric, resulting in controllers that tend to be overtrained.


Introduction
Proposed by Lofti Zadeh [1], fuzzy logic introduces the concepts of fuzzy sets and fuzzy logic operators [2]. Contrary to Boolean logic, in which an element is a member of a set or is not, elements have a degree of membership to many sets in fuzzy logic. Fuzzy logic uses so-called membership functions (MFs) to assign a numerical value to each set member, indicating their degree of membership. We must define MFs for each linguistic variable. These variables can be used in a rule-based system to express knowledge similarly to natural language. For instance, the rule "if distance is near" uses the linguistic variable distance, with a fuzzy MF assigning a degree of membership to the set near to each element of the distance domain; for instance, for 2 mm and 50 mm, the function will assign the following degrees of membership: near (2) = 0.92 and near (50) = 0.40. These rule-based systems can express complex relationships well suited for control applications.
That is why, since the earlier years of fuzzy logic theory, fuzzy inference systems [3] have been applied to control problems [3][4][5][6], in many research projects [7,8] and commercial systems.
Many papers address the problem of path tracking control with fuzzy logic, the earlier works used simple fuzzy rules to make adjustments to linear controllers [9], or integrated fuzzy logic to a complex adaptive controller [10]. Meng [11] proposes a Fuzzy PID (proportional integral derivative) Controller algorithm to a two-degree-of-freedom arm robot. Antonelli et al. [12] propose a set of rules to emulate the way humans drive, using as inputs of curve and distance to the system. We have also reviewed works where authors use controllers for the follow-up and planning of routes. For example, using a simplified kinematic model of the bicycle type using the control law for the navigation and follow-up of a path [13], in work presented by Beleño et al. [14] they propose the planning and tracking of the trajectories of a land vehicle based on the steering control in a natural environment. Guerrero-Castellanos et al. [15] addresses the path following problem for the robot (3, 0) based on its kinematic model and proposes a solution by designing a control strategy that mainly considers the maximum permitted levels of the control signal.
An essential caveat of applying fuzzy control strategies to real-world problems is that we require optimization or adaptive techniques to tune some aspects of the fuzzy inference system. From the membership functions (MFs) that define the linguistic variables to the definition of a rule-based system, including a defuzzification method [16,17].
Tuning is needed because the fuzzy controllers' performance is highly dependent on the parameters of the fuzzy system used. Moreover, the option of making a manual selection of these parameters is difficult because the search space is of considerable size and requires the validation of establishing the controller's performance by running time-consuming simulations. Evolutionary Algorithms (EAs) and other population-based metaheuristics are often employed in tuning Fuzzy Inference Systems (FISs) [18,19].
Population-based metaheuristics are stochastic techniques that search for optimal solutions using two strategies: exploration and exploitation. Exploration searches the space globally, avoiding to be trapped in a local optimum, while exploitation searches locally for nearby promising solutions. Genetic Algorithms (GAs) are the canonical representatives of population-based metaheuristics [20]. GAs work on a set of potential solutions called a population that is evolved for a certain number of generations until a suitable or optimal solution is found [21]. In each generation, potential solutions (individuals) are evaluated, and then surviving individuals reproduce through genetic crossover (exploration) and mutation operators (exploitation) to generate new offspring. Finally, there is a replacement mechanism to select the most adapted offspring and generate a new generation of the population. Most population-based metaheuristics, create an initial set of random candidate solutions. These candidates are evaluated against a quality function, then taking the quality and the position or structure of each solution in consideration, a nature-inspired metaheuristic is applied to generate a new set of candidates.
We have found in the literature various studies that optimize the parameters of a fuzzy controller applied to mobile autonomous robots using different bio-inspired metaheuristics [36,37]. Wagner and Hagras [38] propose a GA to evolve the architecture of a type-2 fuzzy controller in robot navigation for real environments; they optimize the standard deviation of Gaussian type-2 MFs. Again a GA is presented by Wu and Wan Tan [39] for evolving the parameters of all the MFs of a coupled-tank liquid-level control system. Astudillo et al. [40] propose a new metaheuristic based on chemical reactions to tune the parameters of a fuzzy controller for a uni-cycle robot. There is also work focused on the metaheuristic optimization of fuzzy type-2 controllers, the main works are reviewed by Castillo [41], and the main reason for using this type of controller is to model the uncertainty of the sensor data or the fuzzy model itself. We have observed that most of these studies optimize the parameters of MFs directly. For instance, if we have a triangular function for a fuzzy set A, defined by a lower limit a, and upper limit of b and a value m where a < m < b as each value is optimized independently, sometimes validating only the restriction a < m < b. This approach has the advantage of not limiting the search because candidate solutions can represent all possible MFs.
In this work, we propose a novel method that adds further restrictions, including a symmetric definition and limiting the range of values of each parameter. To achieve that, we first designed the structure of a parameterizable fuzzy controller, using five membership functions for each fuzzy input variable. In our previous work [42,43], we compared symmetrical and asymmetrical definitions and found that symmetrical restrictions give better results for rear-wheel-based controllers. We propose a new parameterization technique that enables symmetric MFs' definition by using an aperture factor instead of the previous method that used a delta from a fixed point. Moreover, in this work, we also propose a change on how candidate controllers are typically evaluated by other works in the literature by using a single simulation and path as the fitness function. As experiments show, in the case of rear-wheel path tracking, evaluating candidate solutions with three simulations, gives better results. As experiments show, these additions greatly improve the controller's optimal design by significantly decreasing the tracking error (RMSE) compared to our previous work. Experimental results also show that this method reduces the risk of generating an over-trained controller with low error for a specific path but cannot function in other paths.
To demonstrate the application of the method, we report an experimental case study using a bicycle-like mobile robot with nonholonomic constraints. In this work, we choose the problem of trajectory tracking since it has the particularity of being naturally symmetric since the error is measured by moving away either to the left or right of the desired path. Furthermore, in the literature, we have not found applications of fuzzy systems to follow the trajectory of a path so that this research could solve similar problems.
The main contribution of this work is to propose an optimization method to solve the problem of autonomous path tracking using a rear-wheel controller. The method ties population-based metaheuristics with parameterizable fuzzy controllers. This approach enables the design of controllers using rules that are linguistically familiar to human users.
We structure this document as follows: in Section 2, we present the proposed method, configurations, and we describe the experimental setup. In Section 3 we present the results achieved, and finally, in Section 4 we discuss the results and highlight future research directions.

Rear-Wheel Feedback and Kinematic Model
In this work, we use a simplified model of a bicycle-type kinematic robot consisting of two wheels connected by a rigid link of size l with nonholonomic restrictions [44,45]. The front-wheel can steer in the axis normal to the plane of motion, the steering angle is δ (see Figure 1), The position of the midpoint of the rear-wheel is given by the coordinates x r and y r . The heading θ is the angle of the link between the two wheels and the x axis. We follow the model described in [46], with the differential constraint: x r = v r cos(θ), y r = v r sin(θ), θ = v r l tan(δ).
(2) � � t^l Figure 1. Feedback and actuator variables for the rear-wheel-based control. The magnitude of e illustrated in red is the error measured from the rear wheel to the nearest point on the path. When e > 0, the wheel is at the right of the path, and when e < 0 is at the left. θ e is the difference between the tangent at the nearest point in the path and the heading θ. The output of the controller is the heading rate ω, a value we use to calculate the front wheel's steering angle δ.
The controller selects the steering angle δ with a value between the limits of the vehicle δ ∈ [δ min , δ max ] and a desired velocity v r again limited by v ∈ [v min , v max ]. The heading rate ω is related to the steering angle by and we can simplify the heading dynamics tȯ Now we explain the path tracking method described by Paden et al. [46]. This controller takes the feedback from the rear-wheel position as Figure 1 illustrates. The path (shown in red in the figure) is a continuous function with properties described in [47], and the feedback is a function of the nearest point on the reference path given by and the tracking error vector is , y re f (s(t))) The heading error is based on a unit vectort (shown in green on Figure 1) tangent to the path at s(t) given byt , The error e is the cross product of the two vectors The heading error uses the angle θ e between the robot's heading vector and (ṫ)

Fuzzy Controller
To design a fuzzy controller for the model we just described, we must decide which variables we are going to treat as fuzzy variables. First, we must consider the error (e), defined as the distance from the rear wheel to the path's closest point. This error is positive if it is on the right and negative if on the left side of the path. Another input variable is the angle θ e defined between the heading vector and the tangent vector of the path. This angle can also be negative or positive depending on the vehicle's position concerning the path; the controller output is the heading rate ω, a value we use to calculate the front wheel's steering angle δ. The target velocity of the robot will be constant, so we will not control the velocity v using the fuzzy controller. We will use the following simple proportional controller instead Parameterizable Fuzzy Controller We proposed a parameterizable fuzzy controller suitable for optimization using a bioinspired metaheuristic. We must define the structure of the fuzzy controller consisting of fuzzy rules and parameterizable membership functions. Extending our previous work [43], in which we used three MFs for each variable, we now add two more membership functions to the previous fuzzy model, intending to have a finer grain of control. Adding more MFs also adds more complexity to the rules, and now we have even more parameters to tune. Instead of having just two values for each type of error hi and low we add a middle value, represented by the medium membership function. The knowledge in the fuzzy rule base is now more complex than before, with 25 rules. In this case, defining the rules was not done by simply specifying a driver's knowledge. We needed to adjust the rules by running several simulations. The rules are presented in Table 1. Table 1. Proposed fuzzy rules for the basic controller with three membership functions.

Rule 1:
If θ e is hi_neg and e is hi_neg then ω is hi_pos Rule 2: If θ e is hi_neg and e is med_neg then ω is hi_pos Rule 3: If θ e is hi_neg and e is low then ω is hi_pos Rule 4: If θ e is hi_neg and e is med_pos then ω is med_pos Rule 5: If θ e is hi_neg and e is hi_pos then ω is low Rule 6: If θ e is med_neg and e is hi_neg then ω is med_pos Rule 7: If θ e is med_neg and e is med_neg then ω is med_pos Rule 8: If θ e is med_neg and e is low then ω is med_pos Rule 9: If θ e is med_neg and e is med_pos then ω is med_pos Rule 10: If θ e is med_neg and e is hi_pos then ω is low Rule 11: If θ e is low and e is hi_neg then ω is hi_pos Rule 12: If θ e is low and e is med_neg then ω is low Rule 13: If θ e is low and e is low then ω is low Rule 14: If θ e is low and e is med_pos then ω is low Rule 15: If θ e is low and e is hi_pos then ω is hi_neg Rule 16: If θ e is med_pos and e is hi_neg then ω is low Rule 17: If θ e is med_pos and e is med_neg then ω is med_neg Rule 18: If θ e is med_pos and e is low then ω is med_neg Rule 19: If θ e is med_pos and e is med_pos then ω is med_neg Rule 20: If θ e is med_pos and e is hi_pos then ω is med_neg Rule 21: If θ e is hi_pos and e is hi_neg then ω is low Rule 22: If θ e is hi_pos and e is med_neg then ω is med_neg Rule 23: If θ e is hi_pos and e is low then ω is hi_neg Rule 24: If θ e is hi_pos and e is med_pos then ω is hi_neg Rule 25: If θ e is hi_pos and e is hi_pos then ω is hi_neg The other component of a fuzzy controller are MFs; these must be defined as parameterizable structures, suitable to be optimized using a metaheuristic. We describe these structures in the following section.

Parameterizable Membership Functions
In this section, we describe our proposed method for MFs parameter optimization. First, we need to establish which parameters of the MFs we will keep fixed and which parameters we are going to optimize. As a general rule, we keep the MFs symmetrical around zero; this means that the middle point of the triangular MF for low will be zero in all cases. We also kept the extreme values of high trapezoidal MFs, fixed at 50 and 5, positive or negative depending on the side. We kept the parameters of ω fixed to limit the search space. The parameters are illustrated in Table 2. In this case, we just needed 10 variables to parameterize the controller.

Variable
Linguistic Value MF Parameters Another essential aspect to consider when tuning the above parameters is the range of values each parameter can have. Usually, we keep all the parameters in the same range when using a population-based metaheuristic. In our previous work [43], we compared two ranges, [0, 1] and [0, 2]. Our experiments showed better results with the narrower range, so we selected the same configuration for the three MFs controllers for this work. In this work, we propose a simple technique to change the tuning ranges for the MFs while keeping the adjustable parameters in the same range of values [0, 1]. We define different ranges for the input variables and normalize the values before they are passed to the membership functions. We can treat this as an aperture factor. Now each parameter of an MF can have a distinct range while keeping the parameters or be optimized fixed on [0, 1]. We defined from our experience the range for each parameter; these are shown in Table 3.

Optimization Problem Formulation
An optimization procedure is needed to tune the membership functions' parameters to generate a fuzzy controller that maintains a low positional error over the desired path. We can define the optimization problem as searching for the parameter vector x m f that defines the membership functions, which minimizes the error. We can define this as: arg min where the fitness function FC e rror is the average RMSE of three simulations: in which k is the number of paths s k . A simulation consists of running a control problem as defined in Section 2.1 in which the control is performed by the fuzzy controller FC(x m f ) with membership functions defined by x m f . The constant t max is the number of cycles executed in one simulation. As described before, the controller objective is to minimize the tracking error. To obtain the RMSE, we can use the tracking error vector defined in Equation (13): The vector x m f defines the parameters of the membership functions defined in Table 2 and the knowledge base in Table 1: The range of all parameters is between 1 and 0:

Metaheuristic Optimization Procedure
In general, a population-based metaheuristic needs to evaluate the fitness of each candidate solution (also called individuals) in its population. This process is illustrated in Figure 2. Each candidate solution is represented by a vector x m f , here implemented as a list of objects of type float. To evaluate each solution, we need to generate an instance of the fuzzy controller. Once created, the fuzzy controller is passed as a parameter, together with the mobile robot's paths. The output of the simulations is the RMSE of the accumulated errors e obtained during the simulations. We consider this measure as the fitness of the candidate solution.
In our previous work [43] we used a GA to evolve the controllers using a single path; we noticed that this could lead to over-training. Similar to what happens in supervised learning algorithms, the controller found by the GA could be specialized only to the path used for its evolution. It is well known that in rule-based learning, adding more rules can harm the capacity to generalize to unseen problems [48]. Noticing this, we added a list of three paths to evaluate the fitness for the experiments, which is the average RMSE of the three simulations. We ran experiments with one and three paths. We defined each path using cubic splines over a list of coordinates; this is a common approach in the literature [49]. The paths and the parameters to define them are shown in Table 4. The first path was used in previous work and was taken from the library of [50]. This path starts with a very narrow curve to the left that is difficult for controllers to follow, but it remains differentiable throughout the path, we call this path "M". The other paths are called "A" and "S" and have smoother curves, with long straight segments and different curvatures. All paths have seven anchor points for the cubic spline.  Figure 2. For each candidate solution in the population, a controller is created with the parameter vector. This controller is then tested by running one or more simulations. The RMSE of the tracking is considered as the fitness for that particular candidate solution. This process is repeated for each member of the population.

Complexity of the Optimization Procedure
The computational complexity of the optimization procedure described earlier depends mostly on the evaluation of the fitness function. It is difficult to estimate the cost of each simulation step because it depends on an ordinary differential equation solver (ODEInt). In particular, this is a multi-step solver (lsode), and the number of iterations changes depending on the initial conditions. Moreover, in order to calculate the current nearest point to the path as described in Equation (5), there is a local optimization procedure to find γ to establish this nearest point (x r e f (γ), y r e f (γ)). Nevertheless, we can consider the cost of the function evaluation as domain-dependent and with a high order complexity of at least \ . Because of this, normally, the number of function evaluations needed to find a solution is considered when establishing the performance of a metaheuristic algorithm.
All the algorithms that we tested on this paper follow the same procedure: randomly initialize the population, this has a O(n) complexity, with n the population size (the number of candidate solutions). After the evaluation, there is a step for updating the solution. The complexity for this is O(m * n) + O(m * n * l), m is the number of iterations and l the number of parameters in the fitness function. Some algorithms add a step for keeping only the generated solutions if the new fitness is better than the previous solution; this has an additional cost of O(n). Finally, some algorithms order the population by fitness after every iteration; this adds a complexity of O(nlogn).

Experimental Setup
In this section, we compare the parameter optimization procedure proposed in the previous section, using the following algorithms:
All algorithms have the same population size of 50, and the number of iterations was set at 30, from theses values, the total number of function evaluations is 1000. The parameters of the comparative algorithms is shown in Table 5. Table 5. Parameter values for the algorithms compared.

Algorithm
Parameter Value The fitness function returns the RMSE of the simulation as mentioned earlier, but to economize the computational resources, while the simulations were running, we interrupted those simulations where the robot was clearly out of the path or did not finish near the final point of the path. In these cases, we assigned a very low fitness (we wanted to minimize the error) of 5000 to the first case and 2000 to the second.
As the basis for comparison, we compare our results against the controller in [46], with the following control law defined as the parameters of the simulations and the canonical controller we are comparing against are summarized in Table 6. Table 6. Simulation and controller parameters.
We compared the algorithms using the mean, median, and standard deviation of the RMSE of 30 algorithm executions. Moreover, we performed a Wilcoxon rank-sum test between algorithms for performance comparison.

Results
This section shows the optimization results for the controller described in the previous sections. The descriptive statistics of these results are shown in Table 7. As expected, and because the optimization is non-deterministic, there are a few outliers at both extremes of the performance. In particular, outliers are presented on the GA algorithm with RMSE = 0.18205, and the AOA algorithm with RMSE = 0.7978. The PSO algorithm obtained the lower RMSE average (0.00546) and the best controller (0.00158) and AOA obtained the lower median (0.00523). In Figure 3, we can see that the GA algorithm has the worst median and overall results, while the remaining algorithms obtained competitive results. Table 8 gives the results of the Wilcoxon rank-sum test with an alternative hypothesis H 1 comparing if the algorithm in each row has a lower median than the algorithm on each column with a significance level at α = 0.05. Results with a p-value lower than 0.05 are shown in bold. The PSO outperformed the GA, AO, GWO, and HS among the six algorithms, while all outperformed the GA algorithm. The AOA algorithm is a particular case; there was not enough statistical significance to outperform other algorithms while having the lowest median. The GWO algorithm beat the HS algorithm, making it the second best considering the number of wins. Nevertheless, most algorithms (PSO, AO, AOA, and GWO) achieved good results.  To present a qualitative comparision, we selected 2 of the best controllers found in the 30 experiments, one from the best algorithm (PSO) and the other from the worst (GA), and then compared them against the baseline, a controller using the control law in Equation (16). These results are presented in Table 9. We can see that even the fuzzy controller optimized with the GA outperformed the control law in two paths. The results of the PSO are highly competitive against the baseline. When we observe the optimized MFs for both controllers, GA in Figure 4a and PSO in Figure 4b, we can see that they are similar on the low and high MFS, for both the θ r and e. however, there is a noticeable difference in the high negative and low negative MFs in each of them; both variables are very similar. We can also see that both MFs of ω remain fixed because we kept those parameters fixed. The best parameters found from all algorithms are shown in Table 10. We now show a plot of the paths and the robot's movement following the path. First, we have the path "M" (see Figure 5), in which all controllers have problems at the beginning with a curve that is very sharp to the left and then a sharp U-turn to go back to the start. We can see that the Control law follows the path with less zig-zag than the GA and PSO controllers, which keep the tracking closer to the path but with noticeable zig-zagging.
The plots in Figure 6 show the "A" path. This time all controllers closely follow the path. Again controller GA has a noticeable zig-zagging but manages to have a lower RMSE than the Control law.
The results of Figure 7 highlight the overall behavior of the three controllers on path "S". The control law takes more time to reach the path when it deviates from the reference because it has smoother steering, but once it is over the path, e does not increase. That is by design because one of the conditions is that a small initial tracking error will remain small. On the other hand, controller PSO does not deviate much from the reference, and has a smoother control than the GA.       We added more MFs when compared with our previous work [42] and consequently added more complexity to the knowledge base; we have shown that this change improved the control in terms of RMSE, although needing more computational resources on the evolutionary phase. The best previous results using a GA and a Fuzzy Controller with 3 MFs, are: RMSE = 0.6831, Standard Deviation = 0.1096, Median = 0.4133.

Discussion and Conclusions
In this paper, we proposed a new optimal parameterization method for a fuzzy controller, aimed at autonomous path tracking, using rear-wheel feedback. First, we presented a novel technique for handling the membership function's parameters and designed the controller's fuzzy rules. The controller parameters can be optimized using a populationbased metaheuristic. In addition, we proposed a new fitness function consisting of running a certain number of simulations to validate the candidate controller's performance.
To validate the method, we conducted a series of experiments comparing the results of six population-based metaheuristics. The statistical results show that the PSO, GWO, and AO metaheuristics provided good results. On the other hand, the GA metaheuristic gave the worst results among the selected algorithms. Nevertheless, all algorithms gave better average results than the control rule baseline. The proposed method offers a practical tool to help design and optimize fuzzy controllers for other applications.
When qualitatively comparing the controllers, we found that some solutions had undesired yaw oscillation while keeping a low RMSE; this is a crucial aspect to be considered in future work. We can consider including a damping module or an evaluation metric that negatively weights this kind of oscillation. We can even include a fuzzy variable to the controller; in comparison, the control law also uses the curvature of the path K(s) as a variable for determining ω. Perhaps we need to treat the evolutionary optimization of fuzzy controllers as a supervised learning task. The assessment of the quality of solutions needs to consider other metrics as part of the desired control properties, such as oscillation, overshoot, and generalization capabilities.
Furthermore, because of the high computational cost, as future work, we will propose a technique to execute these experiments in a distributed way, adding multiple populations such as the island-model, or a pool-based evolutionary approach, that could enhance the search, giving supralinear execution times. Later we could try other bio-inspired methods and compare the results. We could also add more membership functions and test other functions to improve the inference system. Funding: This research was funded by projects TecNM-5654.19-P and DemocratAI PID2020-115570GB-C22.