# A Data-Driven Approach of Takagi-Sugeno Fuzzy Control of Unknown Nonlinear Systems
## 5 Application Example
\begin{array}{l}10,000\Big{[}\left(\theta_{1}-r_{\theta _{1}}\right)^{2}+\left(\theta_{2}-r_{\theta_{2}}\right)^{2}\Big{]}+\left[ \left(\theta_{3}-r_{\theta_{3}}\right)^{2}+\left(\theta_{4}-r_{\theta_{4}} \right)^{2}\right]\\ +1000\Big{[}\left(\theta_{1}-r_{\dot{\theta}_{1}}\right)^{2}+\left(\dot{ \theta}_{2}-r_{\dot{\theta}_{2}}\right)^{2}\Big{]}+\left[\left(\dot{\theta}_{ 3}-r_{\dot{\theta}_{3}}\right)^{2}+\left(\dot{\theta}_{4}-r_{\dot{\theta}_{4 }}\right)^{2}\right]+0.17_{1}^{2}+0.17_{2}^{2}\end{array} \right\}dt \tag{29}\]  
Figure 5: Experimental data and predicted outputs from the T-S fuzzy models. \begin{table}
\begin{tabular}{c c c} \hline
**Neuro-Fuzzy Model** & **T-S Fuzzy Model with** **Uniformly Distributed** **27 Points** & **T-S Fuzzy Model with** **Optimized 12 Points** \\ \hline NDEI & 0.0267 & 0.0697 & 0.0477 \\ \hline \end{tabular}
\end{table} 
Table 3: NDEIs of the neuro-fuzzy model and T-S fuzzy models. The fuzzy optimal control systems derived from the T-S fuzzy models with 27 and 12 points were simulated using the mathematical model in MATLAB with initial condition \(\mathbf{x=0}\). To obtain an assessment of the proposed control algorithm, it is necessary to compare this paradigm to alternative control techniques. Therefore, a PID controller was also designed:  
\[\left[ \begin{array}{c}T_{1}\\ T_{2}\end{array} \right]=\left[ \begin{array}{c}0.4e_{1}+0.1\dot{e}_{1}+0.1 \int e_{1}dt\\ 0.4e_{2}+0.1\dot{e}_{2}+\int e_{2}dt\end{array} \right]\!, \tag{30}\]  
where \(e_{1}\) and \(e_{2}\) are tracking error of \(\theta_{1}\) and \(\theta_{2}\). The PID gains were based on [32], in which a PID controller was designed for this robot manipulator. Figure 6 shows the simulated responses of the flexible robot system with the fuzzy controllers and PID controller, while the mean square errors (MSEs) of command tracking are compared in Table 4. The performances of the fuzzy controllers are evidently better than that of the PID controller. The PID responses exhibit larger overshoot and longer settling time, which leads to larger MSE. The results of the 12 points T-S fuzzy model are almost the same as the results of the 27 points one, as the non-significant difference of modeling errors may only yield trivial effect on the control system. Since the number of linearization is reduced, the 12 points T-S fuzzy model is more computationally efficient. The fuzzy optimal controllers were then implemented on the robot. The experimental results are shown in Figure 7. The achieved tracking performances are good and close to the simulation results, except for some lags and oscillations along the trajectories. \begin{table}
\begin{tabular}{c c c c} \hline \hline  & \begin{tabular}{c} **T-S Fuzzy Model** \\ **with 27 Points** \\ \end{tabular} & \
\begin{tabular}{c} **T-S Fuzzy Model** \\ **with 12 Points** \\ \end{tabular} &
\begin{tabular}{c} **PID** \\ \end{tabular} \\ \hline \(\theta_{1}\) & \(2.95\times 10^{-4}\) & \(2.98\times 10^{-4}\) & \(1.20\times 10^{-3}\) \\ \(\theta_{2}\) & \(7.31\times 10^{-4}\) & \(8.06\times 10^{-4}\) & \(1.22\times 10^{-3}\) \\ \(\theta_{3}\) & \(0.0169\) & \(0.0170\) & \(0.0744\) \\ \(\theta_{4}\) & \(0.0084\) & \(0.0097\) & \(0.0268\) \\ \hline \hline \end{tabular}
\end{table} 
Table 4: MSEs of command tracking with the designed controllers. Figure 6: Simulation results of the fuzzy optimal controllers for the flexible robot. These oscillations are caused by the flexible joints of the robot, which are very difficult to completely eliminate.