# A Data-Driven Approach of Takagi-Sugeno Fuzzy Control of Unknown Nonlinear Systems
## 5 Application Example  
In this section, the data-driven T-S fuzzy model identification and control are implemented on a flexible two-link joint robot to demonstrate the effectiveness of the proposed approach. Flexible robot manipulators possess various advantages over the rigid ones: they require less material, allow higher manipulation speed while consume less power, and are safer to operate due to reduced inertia. However, controlling flexible robot manipulators for precise positioning could a challenging task because of the high precision required for positioning, oscillation due to flexibility, highly nonlinear and distributed dynamics of the system, as well as the difficulty in establishing an accurate model [29]. The picture and the schematic of the two-link flexible-joint robot manipulator to be dealt with in this paper are shown in Figure 3.  
The robot is described by 8 state variables: \(\theta_{1}\), angle of the 1 st link; \(\theta_{2}\), angle of the 2 nd link; \(\theta_{3}\), angle of the 1 st motor; \(\theta_{4}\), angle of the 2 nd motor; and the four angular velocities. There are two input variables: \(T_{1}\), the torque of the 1 st motor and \(T_{2}\), the torque of the 2 nd motor. The state vector and input vector of this system are defined as:  
\[\theta=\left[ \begin{array}{cccc}\theta_{1}&\theta_{2}&\theta_{3}&\theta_{4} \end{array} \right]^{T}\quad\mathbf{x}=\left[ \begin{array}{cc}\theta^{T}& \dot{\theta}^{T}\end{array} \right]^{T}\quad\mathbf{u}=\left[ \begin{array}{ cc}T_{1}&T_{2}\end{array} \right]^{T}\.\]The nonlinear equation of motion of this robot can be expressed as [30]:  
\[\mathbf{M}(\theta)\ddot{\theta}+\mathbf{V}\Big{(}\theta,\dot{\theta}\Big{)}+ \mathbf{C}\dot{\theta}+\mathbf{D}\Big{(}\dot{\theta}\Big{)}+\mathbf{K}\theta= \mathbf{T}, \tag{18}\]  
where \(\mathbf{M}(\theta)\) is the inertia matrix, \(\mathbf{V}\Big{(}\theta,\dot{\theta}\Big{)}\) is the vector of Coriolis and centrifugal functions, \(\mathbf{C}\) is the viscous damping coefficient matrix, \(\mathbf{D}\Big{(}\dot{\theta}\Big{)}\) is the Coulombic friction vector, \(\mathbf{K}\) is the stiffness coefficient matrix, and \(\mathbf{T}\) is the input torque vector. The inertia matrix is given by:  
\[\mathbf{M}(\theta) =\left[ \begin{array}{cc}\mathbf{M}_{1}(\theta)&\mathbf{M}_{12}\\ \mathbf{M}_{21}&\mathbf{M}_{2}\end{array} \right]\quad\quad\mathbf{M}_{12}= \mathbf{M}_{21}^{T}=\left[ \begin{array}{cc}0&J_{4}+\frac{I_{6}}{r}\\ 0&0\end{array} \right]\quad\mathbf{M}_{2}=\left[ \begin{array}{cc}J_{3}+\frac{I _{5}}{r^{2}}&0\\ 0&J_{4}+\frac{I_{6}}{r^{2}}\end{array} \right]\] (19) \[\mathbf{M}_{1}(\theta) =\left[ \begin{array}{cc}p_{1}+\left(m_{2}a_{2}^{2}+J_{2}\right) +2(1_{1}m_{2}a_{2})\cos(\theta_{2})&\left(m_{2}a_{2}^{2}+J_{2}\right)+\left(1_ {1}m_{2}a_{2}\right)\cos(\theta_{2})\\ \left(m_{2}a_{2}^{2}+J_{2}\right)+\left(1_{1}m_{2}a_{2}\right)\cos(\theta_{2}) &\left(m_{2}a_{2}^{2}+J_{2}\right)\end{array} \right]\] \[\text{where }m_{i}\text{ is the lumped mass of components, }J_{i}\text{ is the moment of inertia of components, }l_{i}\text{ is the length of links, and }a_{1}\text{ and }a_{2}\text{ denote the offset from the center of gravity of the first and second link to the first and second joint, respectively. In addition, \(b_{1}\) is the distance between the second motor and the first joint, and \(r\) is the gear ratio of the chain drives. The vector of the Coriolis and centrifugal functions is  
\[\mathbf{V}\Big{(}\theta,\dot{\theta}\Big{)}=\left[ \begin{array}{cc}-\left( l_{1}m_{2}a_{2}\right)\Big{(}2\dot{\theta}_{1}\dot{\theta}_{2}+\dot{\theta}_{2} ^{2}\Big{)}\sin(\theta_{2})\\ \left(l_{1}m_{2}a_{2}\right)\dot{\theta}_{1}^{2}\sin(\theta_{2})\\ 0\end{array} \right], \tag{20}\]  
and the viscous damping matrix can be written as  
\[\mathbf{C}=\left[ \begin{array}{ccc}c_{1}+c_{5}&&-\frac{c_{5}}{r}\\ &c_{2}+c_{6}&&-\frac{c_{6}}{r}\\ -\frac{c_{5}}{r}&&c_{3}+\frac{c_{5}}{r^{2}}\end{array}