# Balance Control of a Configurable Inverted Pendulum on an Omni-Directional Wheeled Mobile Robot
## 3 Using Second-Order Sliding Mode Control to Design the Stabilizing Controllers
### Controller Design for a Rotary Inverted Pendulum
\begin{split} z_{\phi}(t)&=z_{\phi}(t_{0})e^{-a(t- t_{0})}-k^{-1}\int_{t_{0}}^{t}[\dot{\beta}(\tau)+b\beta(\tau)]e^{-a(t-\tau)}d \tau,\\ &=z_{\phi}(t_{0})e^{-a(t-t_{0})}-k^{-1}[\beta(\tau)e^{-a(t-\tau) }]_{t_{0}}^{t}+k^{-1}\int_{t_{0}}^{t}\beta(\tau)\frac{d}{d\tau}e^{-a(t-\tau)} d\tau-k^{-1}b\int_{t_{0}}^{t}\beta(\tau)e^{-a(t-\tau)}d\tau,\\ &=[z_{\phi}(t_{0})+k^{-1}\beta(t_{0})]e^{-a(t-t_{0})}-k^{-1}\beta (t)+k^{-1}(a-b)\int_{t_{0}}^{t}\beta(\tau)e^{-a(t-\tau)}d\tau.\end{split}  \tag{46}\]  
From (45) and (46), it gives that  
\[ \begin{split}\dot{z}_{\phi}&=-az_{\phi}-k^{-1}( \dot{\beta}+b\beta),\\ &=-a\bigg{\{}[z_{\phi}(t_{0})+k^{-1}\beta(t_{0})]e^{-a(t-t_{0})} -k^{-1}\beta+k^{-1}(a-b)\int_{t_{0}}^{t}\beta(\tau)e^{-a(t-\tau)}d\tau\bigg{\}} -k^{-1}(\dot{\beta}+b\beta).\end{split}  \tag{47}\]  
Substituting (47) into (44), it follows that  
\[ \begin{split}\ddot{\beta}=&-b\dot{\beta}-ka\bigg{\{} -a\Big{\{}[z_{\phi}(t_{0})+k^{-1}\beta(t_{0})]e^{-a(t-t_{0})}-k^{-1}\beta\\ &+k^{-1}(a-b)\int_{t_{0}}^{t}\beta(\tau)e^{-a(t-\tau)}d\tau \Big{\}}-k^{-1}(\dot{\beta}+b\beta)\bigg{\}}-k[H(\beta,\dot{\phi})\tan\beta], \\ =&(a-b)\dot{\beta}+(ab-a^{2})\beta+a^{2}(a-b)\int_{t_ {0}}^{t}\beta(\tau)e^{-a(t-\tau)}d\tau\\ &-kH(\beta,\dot{\phi})\tan\beta+ka^{2}[z_{\phi}(t_{0})+k^{-1} \beta(t_{0})]e^{-a(t-t_{0})}.\end{split}  \tag{48}\]  
Denote  
\[w(t)=\int_{t_{0}}^{t}\beta(\tau)e^{-a(t-\tau)}d\tau. \tag{49}\]  
By taking time derivative of \(w(t)\) and let \(w(t_{0})=0\), we have  
\[ \begin{split}\dot{w}(t)&=\frac{d}{dt}\int_{t_{0}}^{ t}\beta(\tau)e^{-a(t-\tau)}d\tau,\\ &=\beta(\tau)e^{-a(t-\tau)}|_{\tau=t}+\int_{t_{0}}^{t}\frac{ \partial}{\partial t}[e^{-a(t-\tau)}]\beta(\tau)d\tau,\\ &=\beta(t)+\int_{t_{0}}^{t}-ae^{-a(t-\tau)}\beta(\tau)d\tau,\\ &=\beta(t)-aw(t).\end{split}  \tag{50}\]Thus form (48)-(50), it follows that the zero dynamics of the system constrained to the manifold of \(s_{\phi}=0\) and \(\dot{s}_{\phi}=0\) are given by  
\[\left\{ \begin{array}{ll}\ddot{\beta}=(a-b)\dot{\beta}+(ab-a^{2})\beta+a^{2}(a-b )w-kH(\beta,\dot{\phi})\tan\beta+ka^{2}[z_{\phi}(t_{0})+k^{-1}\beta(t_{0})]e^{-a (t-t_{0})},\\ \dot{w}=\beta-aw.\end{array} \right. \tag{51}\]  
During the sliding mode, the system dynamics become insensitive to the matched disturbances, and the effects of the disturbance are completely eliminated, as seen in (51). To show that the zero dynamics (51) over the upper-half plane is semi-globally asymptotically stable, the stability of the following system is first investigated:  
\[\left\{ \begin{array}{ll}\ddot{\beta}=(a-b)\dot{\beta}+(ab-a^{2})\beta+a^{2}(a -b)w-kH(\beta,\dot{\phi})\tan\beta,\\ \dot{w}=\beta-aw.\end{array} \right. \tag{52}\]  
Note that the unforced system (52) is the zero dynamics (51) in the absence of external excitation. Also note that in (52), the nonlinear term is  
\[H(\beta,\dot{\phi})\tan\beta = \left\{\frac{g}{R_{c}}+\frac{\dot{\phi}^{2}}{mlR_{c}\cos\beta} \Big{[}\Big{(}ml^{2}+I_{Pyy}-I_{Pzz}\Big{)}{\cos}^{2}\beta+ml^{2}+I_{Pxx} \Big{]}\right\}\tan\beta \tag{53}\]  
Define the state vector as  
\[x_{z}=\left[ \begin{array}{c}x_{1}\\ x_{2}\\ x_{3}\end{array} \right]=\left[ \begin{array}{c}\beta\\ \dot{\beta}\\ w\end{array} \right]. \tag{54}\]  
The configuration of the Lur'e system [28] can be used to formulate the system (52) as follows:  
\[\dot{x}_{z} =\left[ \begin{array}{ccc}0&1&0\\ (ab-a^{2})&(a-b)&a^{2}(a-b)\\ 1&0&-a\end{array} \right]x_{z}+\left[ \begin{array}{c}0\\ k\\ 0\end{array} \right]u_{z}, \tag{55}\] \[y_{z} =\left[ \begin{array}{ccc}1&0&0\end{array} \right]x_{z},\] (56) \[u_{z} =-\psi(t,y_{z})=-H(\beta,\dot{\phi})\tan\beta. \tag{57}\]  
Note that in (57) \(\psi\) is a time varying nonlinearity, whose time variation depends on \(\dot{\phi}\). From (41), the system has a singularity at \(\beta=\pm\frac{\mathcal{T}}{2}\). Therefore, the domain of the open upper-half plane \(|\beta|\leq\frac{\mathcal{T}}{2}-\varepsilon\) is considered, where \(\varepsilon\) is sufficiently small and \(0<\varepsilon\ll\frac{\mathcal{T}}{2}\).