# Optimization of Fuzzy Logic Controller Used for a Differential Drive Wheeled Mobile Robot
## 2 Problem Description
### Optimization of the Fuzzy Logic Controller Based on the Genetic Algorithm
#### 4.1.2 Simulation Open-Course Code  
The simulation program of this experiment is published as an open-source code for all readers. This simulation has been developed by employing of the Google Colab(r) and the Python language. The open-source code has been published on Code Ocean ([[https://doi.org/10.24433/CO.1867832.v1](https://doi.org/10.24433/CO.1867832.v1)]([https://doi.org/10.24433/CO.1867832.v1](https://doi.org/10.24433/CO.1867832.v1))) (accessed on 2 March 2021) [43], it also has been stored in Colorado ([[https://colab.research.google.com/drive/17](https://colab.research.google.com/drive/17) FUnDR7 XNjMsDOFrXfnBNWffqXYntEjF7 usp=sharing]([https://colab.research.google.com/drive/17](https://colab.research.google.com/drive/17) FUnDR7 XNjMsDOFrXfnBNWffqXYntEjF7 usp=sharing)) (accessed on 3 May 2021), and in GitHub([[https://github.com/vanthuanhvbq/GA_FLC](https://github.com/vanthuanhvbq/GA_FLC)]([https://github.com/vanthuanhvbq/GA_FLC](https://github.com/vanthuanhvbq/GA_FLC))) (accessed on 4 May 2021) so that readers can browse, view, run and experiment with the codes. However, to run this simulation program faster, users should setup their own cluster then replace the URL address with theirs. Otherwise they will experience a long run. This program consists of several sections, which have been explained in the simulation program. Figure 12: The output membership functions used for the Mohammad-based FLC_GA. \begin{table}
\begin{tabular}{c c c} \hline \hline \multicolumn{3}{c}{**The \(\omega_{r}\) (rad/s)/The \(\omega_{l}\) (rad/s)**} \\ \hline
**Name** & **Notation** & **Parameters** \\ \hline Very Small Right/Left & VSR/VSL & [0 0 5]/[0 0 5] \\ Small Right/Left & SR/SL & [0 5 10]/[0 5 10] \\ Near Medium Big Right/Left & NMBR/NMBL & [5 10 15]/[5 10 15] \\ Medium Big Right/Left & MBR/MBL & [10 15 20]/[10 15 20] \\ Near Big Right/Left & NBR/NBL & [15 20 25]/[15 20 25] \\ Big Right/Left & BR/BL & [20 25 30]/[20 25 30] \\ Very Big Right/Left & VBR/VBL & [25 30 30]/[25 30 30] \\ \hline \hline \end{tabular}
\end{table} 
Table 9: Parameters for outputs of the expert-based FLC. Figure 14: The membership function used for the zigzag path. (**a**) The distance membership functions before tuning; (**b**) The distance membership functions after tuning; (**c**) The angle membership functions before tuning; (**d**) The angle membership functions before tuning; (**e**) The output_1 (Omega_R) membership functions before tuning; (**f**) The output_1 (Omega_R) membership functions after tuning; (**g**) The output_2 (Omega_L) membership functions before tuning; (**h**) The output_2 (Omega_L) membership functions after tuning. \begin{table}
\begin{tabular}{c c c c c} \hline \hline \multirow{2}{*}{**Controllers**} & \multicolumn{2}{c}{**Energy Consumption**} & \multicolumn{2}{c}{**Travel Distance**} \\ \cline{2-5}  & **E (J)** & **E (\%)** & **s (m)** & **s (\%)** \\ \hline Circle-based controller & 17.80 & 210.15 & 45.80 & 106.66 \\ Mathew-based controller & 70.11 & 827.75 & **42.94** & **100.00** \\ Chaudhari-based controller & 17.90 & 211.33 & 46.19 & 107.57 \\ Thoa-based controller & 69.11 & 815.94 & 44.09 & 102.68 \\ Expert-based controller & 69.51 & 820.66 & 43.12 & 100.42 \\ Mohammad-FLC & 61.83 & 730.00 & 43.00 & 100.14 \\ Proposed GA\_FLC & **8.47** & **100.00** & 43.23 & 100.68 \\ \hline \hline \end{tabular}
\end{table} 
Table 13: Energy consumption and travel distance of the robot when the robot tracks the sharp turn path by the different controllers. Bold values are the best in the appropriate column.