# Balance Control of a Configurable Inverted Pendulum on an Omni-Directional Wheeled Mobile Robot
## 2 Mathematical Modeling
### Model of a Rotary Inverted Pendulum  
The mathematical modeling of a rotating inverted pendulum as shown in Figure 3 will be described in this subsection. Here the pendulum rod is mounted to a pivot point off the robot's center. The pendulum rod can rotate freely in the vertical plane perpendicular to the axis connecting the center of the robot and the pivot point. The world frame is denoted by the coordinate system \(\hat{O}_{W}\hat{X}_{W}\hat{Y}_{W}\hat{Z}_{W}\), the origin \(\hat{O}_{W}\) coincides with the center of mass of the robot, the \(\hat{X}_{W}\)-axis aligns with the \(\hat{X}_{M}\)-axis of the robot, and the \(\hat{Y}_{W}\)-axis aligns with \(\hat{Y}_{M}\)-axis of the robot. The pendulum's body frame is \(o^{\prime}x^{\prime}y^{\prime}z^{\prime}\), the origin \(o^{\prime}\) coincides with the pivot point of the inverted pendulum, the \(z^{\prime}\)-axis aligns with the pendulum, and the \(x^{\prime}\)-axis aligns with the vector \(\overline{\hat{O}_{W}o^{\prime}}\).  
Figure 3: Rotary inverted pendulum.  
The system variables and parameters are defined as below:  
\[m :\] the pendulum mass. \[l :\] length of the pendulum from its center of mass to the pivot point. \[\beta :\] the pendulum's angular displacement from the vertical upright. \[\phi :\] the robot's rotational angular displacement. \[I_{pxx},I_{pyy},I_{pzz} :\] the pendulum's moment of the inertia about the \[x^{\prime}\] -axis, \[y^{\prime}\] -axis, \[z^{\prime}\] -axis, \[\quad\quad\quad\quad\quad\  
The system variables and parameters are defined as below:  
\[\begin{array}{rcl}M,m&:&\mbox{mass of the mobile robot and the pendulum, respectively.}\\ l&:&\mbox{length of the pendulum from its center of mass to the pivot point.}\\ x,y&:&\mbox{the position of the robot's center of mass relative to the $\hat{X}_{W}$-axis and}\\ &\hat{Y}_{W}\mbox{-axis, respectively.}\\ \alpha,\beta&:&\mbox{the pendulum's angular displacement around the $\hat{X}_{M}$-axis and $\hat{Y}_{M}$-axis,}\\ &&\mbox{respectively.}\\ I_{pxx},I_{pyy},I_{pzz}&:&\mbox{the pendulum's moment of inertia about the $x_{p}$-axis, $y_{p}$-axis, and $z_{p}$-axis, respectively.}\\ g&:&\mbox{gravitational acceleration.}\\ F_{x}&:&\mbox{control force applied to the $\hat{X}_{M}$-axis.}\\ F_{y}&:&\mbox{control force applied to the $\hat{Y}_{M}$-axis.}\\ \end{array}\]  
Again, by the Euler-Lagrange Formula (7) the dynamic equations for the system are derived. For this system, \(q\) and \(Q\) are chosen as  
\[q=\big{[}\begin{array}{cccccc}x&\alpha&y&\beta\end{array}\big{]}^{\mbox{T}}, \tag{13}\]  
\[Q=\big{[}\begin{array}{cccccc}F_{x}&0&F_{y}&0\end{array}\big{]}^{\mbox{T}}. \tag{14}\]  
The dynamic equations of the spherical inverted pendulum are obtained as below:  
\[\begin{array}{l}(m+M)\dot{x}+(ml\cos\alpha\cos\beta)\dot{\alpha}+(-ml\sin \alpha\sin\beta)\dot{\beta}\\ +(-ml\dot{\alpha}\sin\alpha\cos\beta-ml\dot{\beta}\cos\alpha\sin\beta)\dot{ \alpha}\\ +(-ml\dot{\beta}\sin\alpha\cos\beta-ml\dot{\alpha}\cos\alpha\sin\beta)\dot{ \beta}=F_{x},\\ (ml\cos\alpha\cos\beta)\dot{x}+(ml^{2}\cos^{2}\beta+I_{pyy}\cos^{2}\beta+I_{ pzz}\sin^{2}\beta)\dot{\alpha}\\ +(-ml^{2}\dot{\beta}\sin\beta\cos\beta-I_{pyy}\dot{\beta}\sin\beta\cos\beta+I_{ pzz}\dot{\beta}\sin\beta\cos\beta)\dot{\alpha}\\ +(-ml^{2}\dot{\alpha}\sin\beta\cos\beta-I_{pyy}\dot{\alpha}\sin\beta\cos\beta+I_{ pzz}\dot{\alpha}\sin\beta\cos\beta)\dot{\beta}\\ -mgl\sin\alpha\cos\beta=0\\ \\ (m+M)\dot{y}+(ml\cos\beta)\dot{\beta}-ml\dot{\beta}^{2}\sin\beta=F_{y},\\ \\ (-ml\sin\alpha\sin\beta)\ddot{x}+(ml\cos\beta)\ddot{y}+(ml^{2}+I_{pxx})\ddot{ \beta}\\ +(ml^{2}\dot{\alpha}\sin\beta\cos\beta+I_{pyy}\dot{\alpha}\sin\beta\cos\beta-I_{ pzz}\dot{\alpha}\sin\beta\cos\beta)\dot{\alpha}\\ -mgl\cos\alpha\sin\beta=0.\\ \end{array} \tag{15}\]  
Figure 4: Spherical inverted pendulum.