# Gain-Scheduled Model Predictive Control for
## 3 Controller Design
### Linearization of Dynamic Equation  
As shown in (14), the dynamic equation of the CIPS has strong nonlinearity. In addition, the control variable is the force, \(u\), and the measurable output variables include the position, \(x\), of the cart and the pendulum angle \(\theta\) of the SIP. Since the MPC requiresa linear time-invariant equation for executing the model prediction procedure, we first linearize the dynamic Equation (14) of the CIPS at a series of different pendulum angles to obtain various linearized models, respectively. For any operating point, \((X_{o},U_{o})\), on the trajectory of the dynamic Equation (14) of the CIPS, the following equations are satisfied:  
The dynamic Equation (14) of the CIPS can be rewritten as  
\[ \begin{cases}\dot{X}=f(X,U)\\ Z=h(X,U)\end{cases}  \tag{17}\]  
where  
\[ \begin{cases}f=\left[\begin{array}{cccc}f_{1}&f_{2}&f_{3}&f_{4}\end{array} \right]^{T}\\ h=\left[\begin{array}{cccc}h_{1}&h_{2}\end{array}\right]^{T}\\ U=\left[\begin{array}{cccc}u&f_{m}&f_{M}\end{array}\right]^{T}\end{cases}  \tag{18}\]  
For the ease of presentation, a variable, \(V_{1}\), is defined as  
\[V_{1}=-f_{m}-f_{M}-\eta X_{2}-mlX_{4}^{2}\sin X_{3}+(f_{m}\cos X_{3}+mg\sin X _{3})\cos X_{3} \tag{19}\]  
According to (14), (17), and (19), the following equations can be obtained  
\[ \begin{cases}f_{1}=X_{2}\\ f_{2}=\dfrac{u+V_{1}}{M+m\sin^{2}X_{3}}\\ f_{3}=X_{4}\\ f_{4}=\dfrac{1}{ml}f_{m}\cos X_{3}+\dfrac{g\sin X_{3}}{l}+\dfrac{\cos X_{3}}{l }\dfrac{u+V_{1}}{M+m\sin^{2}X_{3}}\\ h_{1}=X_{1}\\ h_{2}=X_{3}\end{cases}  \tag{20}\]  
For any operating point, \((X_{o},U_{o})\), on the trajectory of the dynamic Equation (17) of the CIPS, the following equations are satisfied:  
\[ \begin{cases}\dot{X}_{o}=f(X_{o},U_{o})\\ Z_{o}=h(X_{o},U_{o})\end{cases}  \tag{21}\]  
Around the operating point, \((X_{o},U_{o})\), the dynamic equation (Equation (17)) of the CIPS can be linearized as  
\[ \begin{cases}\delta\dot{X}=A\delta X+B\delta U\\ \delta Z=C\delta X+D\delta U\end{cases}  \tag{22}\]  
where \(A=\left.f_{f}(X)\right|_{(X_{o},U_{o})}\), \(B=\left.f_{f}(u)\right|_{(X_{o},U_{o})}\), \(C=\left.J_{h}(X)\right|_{(X_{o},U_{o})}\) and \(D=\left.J_{h}(u)\right|_{(X_{o},U_{o})}\) are Jacobian matrices, where  
\[ \begin{cases}A=\left[\begin{array}{cccc}0&1&0&0\\ 0&\frac{\partial f_{2}}{\partial X_{2}}&\frac{\partial f_{2}}{\partial X_{3}}& \frac{\partial f_{2}}{\partial X_{4}}\\ 0&0&0&1\\ 0&\frac{\partial f_{4}}{\partial X_{2}}&\frac{\partial f_{4}}{\partial X_{3}}& \frac{\partial f_{4}}{\partial X_{4}}\end{array}\right],B=\left[\begin{array} []{cccc}0&0&0\\ \frac{\partial f_{2}}{\partial u}&\frac{\partial f_{2}}{\partial f_{2}}& \frac{\partial f_{3}}{\partial f_{M}}\\ 0&0&0\\ \frac{\partial f_{4}}{\partial u}&\frac{\partial f_{4}}{\partial f_{m}}& \frac{\partial f_{4}}{\partial f_{M}}\end{array}\right]\\ C=\left[\begin{array}{cccc}1&0&0&0\\ 0&0&1&0\end{array}\right],D=O_{3\times 3}\end{cases}  \tag{23}\]where  
\[\left\{ \begin{aligned} \frac{\partial f_{2}}{\partial X_{2}}& =\frac{-\eta}{M+m\text{sin}^{2}X_{3}}\\ \frac{\partial f_{2}}{\partial X_{3}}&=\frac{mg\cos 2X_{3}-mlX_{4 }^{2}\cos X_{3}-f_{m}\sin 2X_{3}}{M+m\text{sin}^{2}X_{3}}\\ &\qquad-\frac{(u-V_{1})m\sin 2X_{3}}{\big{(}M+m\text{sin}^{2}X_{3} \big{)}^{2}}\\ \frac{\partial f_{2}}{\partial X_{4}}&=\frac{-2 mlX_{4 }\sin X_{3}}{M+m\text{sin}^{2}X_{3}}\\ \end{aligned} \right. \tag{24}\] \[\left\{ \begin{aligned} \frac{\partial f_{2}}{\partial u}& =\frac{1}{M+m\text{sin}^{2}X_{3}}\\ \frac{\partial f_{2}}{\partial f_{m}}&=\frac{- \sin^{2}X_{3}}{M+m\text{sin}^{2}X_{3}}\\ \frac{\partial f_{2}}{\partial f_{M}}&=\frac{- 1}{M+m\text{sin}^{2}X_{3}}\\ \frac{\partial f_{4}}{\partial u}&=\frac{\cos X_{3} }{l\big{(}M+m\text{sin}^{2}X_{3}\big{)}}\\ \end{aligned} \right.\] (25) \[\left\{ \begin{aligned} \frac{\partial f_{4}}{\partial f_{m}}& =\frac{1}{ml}\cos X_{3}-\frac{\sin^{2}X_{3}}{l\big{(}M+m\text{sin}^{2}X_{3} \big{)}}\\ \frac{\partial f_{4}}{\partial f_{M}}&=-\frac{ \cos X_{3}}{l\big{(}M+m\text{sin}^{2}X_{3}\big{)}}\end{aligned}