# Experimental Validation of a Guaranteed Nonlinear Model Predictive Control
## 2 Background of Dynamic Modeling of the Inverted Pendulum
### Dynamic Modeling of the Inverted Pendulum  
The Euler-Lagrange equation is a systematic method used here to express the system's equations of motion, describing various nonlinear derivatives to get the ODEs (for more details, see [22]). After going through this process, the nonlinear equations of a direct dynamic model for rotary nonlinear inverted pendulum are given by  
\[\left\{\begin{array}{l}\dot{y}_{1}=y_{2},\\ \dot{y}_{2}=\frac{1}{\Delta}\bigg{\{}-\mu_{3}\cos(y_{3})\big{[}\mu_{1}\sin(y_ {3})\cos(y_{3})y_{2}^{2}+\Gamma_{2}-\mu_{g}\sin(y_{3})\big{]}+\\ \\ \mu_{4}\big{[}\mu_{3}\sin(y_{3})y_{4}^{2}-\mu_{1}\sin(2y_{3})y_{2}y_{4}+\Gamma _{1}\big{]}\bigg{\}},\\ \\ \dot{y}_{3}=y_{4},\\ \\ \dot{y}_{4}=\frac{1}{\Delta}\bigg{\{}\big{[}\mu_{1}\sin(y_{3})^{2}+\mu_{2} \big{]}\big{[}\mu_{1}\cos(y_{3})\sin(y_{3})y_{2}^{2}+\Gamma_{2}-\mu_{g}\sin(y _{3})\big{]}-\\ \\ \mu_{3}\cos(y_{3})\big{[}\mu_{3}\sin(y_{3})y_{4}^{2}-2\mu_{1}\cos(y_{3})\sin(y _{3})y_{2}y_{4}+\Gamma_{1}\big{]}\bigg{\}},\end{array}\right. \tag{1}\]  
where \(y_{1}\) and \(y_{2}\) indicate, respectively, the angular position and velocity of the rotative arm. Likewise, \(y_{3}\) and \(y_{4}\) are the angular and speed variables of the pendulum arm. We draw all these agreements as \(y=[y_{1},y_{2},y_{3},y_{4}]\in\mathbb{R}^{4}\) referring to the state vector. \(\Gamma_{i}\) is the torque applied at the joint \(i\), which depends on the viscous friction variables, and  
\[\Delta=-\mu_{3}^{2}\cos(y_{3})^{2}+\mu_{1}\mu_{4}\sin(y_{3})^{2}+\mu_{2}\mu_{4},\]  
\[\mu_{1}=l_{p}^{2}\Big{[}\frac{m_{p}}{4}+M\Big{]},\quad\mu_{2}=l_{a}^{2}[m_{p} +M]+\frac{J_{m}}{N_{g}^{2}}+J_{a},\]  
\[\mu_{3}=l_{p}l_{a}\Big{[}\frac{m_{p}}{2}+M_{,}\Big{]},\quad\mu_{4}=l_{p}^{2} \Big{[}\frac{m_{p}}{4}+M\Big{]}+J_{p},\quad\mu_{g}=\Big{[}\frac{m_{p}}{2}+M \Big{]}l_{p}g,\]  
where \(m_{a}\) and \(J_{a}\) denote the horizontal arm's mass and its inertia, respectively--similarly for the pendulum arm with the mass \(m_{p}\) and inertia \(J_{p}\). \(M\) is the mass of the load attached to the pendulum arm, \(J_{m}\) is the DC motor inertia, and \(N_{g}\) its gear ratio. \(l_{a}\), \(l_{p}\), and \(r_{0}\) are the device's dimensional parameters (as defined in Figure 1), and \(g\) is the gravitational acceleration.  
Since the second joint is passive, \(\Gamma_{2}\) can only be written as a function of friction conditions. The relationship between friction and velocity is well modeled in the literature [20]. In this paper, we use a simple friction model, in which it is related to the viscous terms, which are proportional to the joint speed:  
\[\left[\begin{array}{c}\Gamma_{1}\\ \Gamma_{2}\end{array}\right]=\left[\begin{array}{c}\tau-f_{v1}y_{2}\\ \\ -f_{v2}y_{4}\end{array}\right], \tag{2}\]  
where \(\tau\) is the motor's torque and \(f_{v_{i}}\) is the viscous Coulomb friction coefficient of the joint \(i\). These coefficients are often considered as constant values in the majority of literature works. Here, the main goal is to identify them in a guaranteed way by reducing the error between the theoretical model output and measured data output, i.e., they must belong to specific subsets consistent with the model and sensors' outputs. The guaranteed estimated parameters are reported in [20] and outlined in Table 1.