# Experimental Evaluation of a Takagi-Sugeno Fuzzy Controller for an EV3 Ballbot System +
## 3 Takagi-Sugeno Fuzzy Modelling  
### EV3 BRS's Tsfm  
The TSFM [36; 37] is described by fuzzy if-then rules, each of which is associated with a local linear system from the linearization on an operation point for a nonlinear system [38; 39; 40]. The fuzzy blending of the linear system models raises the overall fuzzy model of the system. The structure of a TSFM in continuous time adopts the following form:  
_Plant rule i_:  
\[\text{IF}\quad\ z_{1}(t)\ \text{is}\ M_{i1}\ \text{and}\ \cdots\ \text{and}\ z_{p}(t)\ \text{is}\ M_{ip}, \tag{14}\] \[\text{THEN}\quad\ \left\{ \begin{array}{l}\dot{x}(t)=A_{i}x(t)+B_{i}u(t),\\ y(t)=C_{i}x(t),\ \ \ \ \ i=1,2,\ldots,r;\end{array} \right. \tag{15}\]  
where \(z_{1}(t)\cdots z_{p}(t)\) are measurable premise variables, \(M_{ij}\) are fuzzy sets, \(x(t)\in\mathbb{R}^{n}\) is the state vector, \(y(t)\in\mathbb{R}^{q}\) is the output vector, \(u(t)\in\mathbb{R}^{m}\) is the input vector, \(A_{i}\in\mathbb{R}^{n\times n}\), \(B_{i}\in\mathbb{R}^{n\times m}\), \(C_{i}\in\mathbb{R}^{q\times n}\), and \(r\) is for the number of fuzzy rules. So the overall output of the T-S fuzzy system (14) and (15) is inferred using a singleton fuzzifier, a center average defuzzifier, and a product inference engine, from the pair \((x(t),u(t))\), as follows [41]:  
\[\dot{x}(t) = \sum_{i=1}^{r}h_{i}(z(t))\{A_{i}x(t)+B_{i}u(t)\}, \tag{16}\] \[y(t) = \sum_{i=1}^{r}h_{i}(z(t))C_{i}x(t), \tag{17}\]  
where \(z(t)=(z_{1}(t)\ z_{2}(t)\ \cdots\ z_{p}(t))\) and \(w_{i}(z(t))=\prod_{j=1}^{p}M_{ij}(z_{j}(t))\), with \(M_{ij}(z_{j}(t))\) as the grade of membership of \(z_{j}(t)\) in \(M_{ij}\), and  
\[h_{i}(z(t))=\frac{w_{i}(z(t))}{\sum_{i=1}^{r}w_{i}(z(t))} \tag{18}\]  
is the normalized weight of each if-then rule. The TSFMs are universal approximators of any smooth nonlinear dynamic system [28]. The TSFM can be considered as an infinite dimensional system since it can be composed of a great number of linear subsystems as a result of linearization for infinitesimal quantities around an operation point. Although there are no general guidelines about how many linearization points should be chosen, a large number of points may be necessary for an accurate approximation, which implies a high computational cost [29]. Also, as the TSFC design methodology tries both LMIs and eigenvalue problems, i.e., convex feasibility and optimization problems [42], the design of a large-dimensional TSFM may be conducive for an LMI that is infeasible. It should be noticed that a TSFM must be redesigned for every modification in the parameters, or assumptions about the dynamical behavior, of the nonlinear system since the controller design is based on the TSFM. Then, the nonlinear model (13) is linearized around operation points \(x_{1}=0\) and \(x_{1}=\pm\frac{\pi}{12}=\left|\frac{\pi}{12}\right|\). Thus, taking \(x_{1}=0\), and recalling that from small-angle linearization \(\cos(\theta)\approx 1\) and \(\sin(\theta)\approx\theta\), the linear model has the form  
\[ \begin{bmatrix}\dot{x}_{1}\\ \dot{x}_{2}\\ \dot{x}_{3}\\ \dot{x}_{4}\end{bmatrix} = \begin{bmatrix}0&0&1&0\\ 0&0&0&1\\ -\Delta_{1}Wm_{22}&0&0&\Delta_{1}(m_{12}^{*}f_{B_{b}})-\frac{k_{b}k_{b}}{R_{m }}\\ \Delta_{1}Wm_{21}^{*}&0&0&-\Delta_{1}(m_{11}^{*}f_{B_{b}})-\frac{k_{b}k_{b}}{R_ {m}}\end{bmatrix} x+ \begin{bmatrix}0\\ 0\\ -\Delta_{1}\frac{k_{b}m_{12}^{*}}{R_{m}}\\ \Delta_{1}\frac{k_{b}m_{11}^{*}}{R_{m}}\end{bmatrix} u \tag{19}\]  
where \(\Delta_{1}=1/\left(m_{11}^{*}m_{22}-m_{21}^{*}m_{12}^{*}\right),m_{11}^{*}=l_ {B}+I_{M}+l_{b}+L^{2}m_{b}+m_{B}{R_{b}}^{2}+2 Lm_{B}{R_{b}},m_{12}^{*}=m_{21}^{* }=I_{M}+l_{b}\delta+m_{B}\delta{R_{b}}^{2}+m_{b}\delta{R_{b}}^{2}+Lm_{B} \delta{R_{b}}\), and \(W=-m_{B}\delta L\). From the parametric values in Table 1, (19) takes the form  
\[\dot{x}= \begin{bmatrix}0&0&1&0\\ 0&0&0&1\\ 155.5&0&0&-2.4\\ 1200.3&0&0&-23.7\end{bmatrix} x+ \begin{bmatrix}0\\ 0\\ 50.2203\\ 509.729\end{bmatrix} u, \tag{20}\]  
which corresponds to the local linear system \(\dot{x}=A_{1}x+B_{1}u\).