# Performance Improvement of an NMP Mini Segway Using Sample and Hold Inputs
## 3 Mini-Segway System Model
### Mini-Segway Robot Dynamic Equation  
The MS equations of motion are shown in (8) below.  
\[\begin{split}(m_{p}+\frac{2I_{w}}{r^{2}}+2m_{w})\dot{x}_{cart}=& -\frac{2K_{\tau}K_{emf}}{R_{m}r^{2}}\dot{x}_{cart}+\frac{K_{\tau}}{R_{m}r}(u_{ L}+u_{R})\\ &-\frac{2K_{f}\dot{x}_{cart}}{r^{2}}+m_{p}l\theta_{p}^{2}\sin \theta_{p}-m_{p}l\dot{\theta}_{p}\cos\theta_{p}\\ (I_{p}+m_{p}l^{2})\ddot{\theta}_{p}=&-m_{p}l\dot{x}_ {cart}\cos\theta_{p}+m_{p}l\beta\sin\theta_{p}+\frac{2K_{\tau}K_{emf}}{R_{m}r }\dot{x}_{cart}\\ &-\frac{K_{\tau}}{R_{m}}(u_{L}+u_{R})+\frac{2K_{f}}{r}\dot{x}_{ cart}\\ (I_{p_{z}}+\frac{2I_{w}h^{2}}{r^{2}}+2m_{w}h^{2})\ddot{\phi}=& \frac{-2K_{\tau}K_{emf}h^{2}}{R_{m}r^{2}}\dot{\phi}+\frac{K_{\tau}h}{R_{m}r}(u_ {L}-u_{R})-\frac{2K_{f}h}{r^{2}}\dot{\phi}\end{split} \tag{8}\]  
Figure 2: Free body diagram of the mini-Segway robot.  
where \(u_{L}\) and \(u_{R}\) are the left and right motor applied voltages, and they are considered as system control inputs. The MS system is balanced at its equilibrium point, the upright position (\(\theta_{p}=0\)). Small angle approximations of nonlinear functions are used as below:  
\[\begin{split}\cos\theta_{p}&=0\\ \sin\theta_{p}&=1\end{split} \tag{9}\]  
The linearized MS state-space model is described in (10), and the state vector is \(x=[x_{cart}\;\hat{x}_{cart}\;\theta_{p}\;\hat{\theta}_{p}\;\phi\;\phi]^{\top}\).  
\[\begin{split} A&=\begin{bmatrix}0&1&0&0&0&0\\ 0&\alpha&\frac{-m_{p}^{2}l^{2}}{ab-m_{p}^{2}l^{2}}&0&0&0\\ 0&0&0&1&0&0\\ 0&\beta&\frac{m_{p}gla}{ab-m_{p}^{2}l^{2}}&0&0&0\\ 0&0&0&0&0&1\\ 0&0&0&0&0&\frac{-2K_{\tau}K_{\text{\tiny{eff}}}l^{2}-2K_{\text{\tiny{ff}}}lR _{\text{\tiny{int}}}}{R_{m}r^{2}c}\end{bmatrix}\\ \\ B&=\begin{bmatrix}0&0\\ \frac{K_{\tau}(b+m_{p}l\tau)}{R_{m}r(ab-m_{p}^{2}l^{2})}&\frac{K_{\tau}(b+m_{ p}l\tau)}{R_{m}r(ab-m_{p}^{2}l^{2})}\\ 0&\\ -K_{\tau}(m_{p}l+4\tau)&-K_{\tau}(m_{p}l+4\tau)\\ \frac{K_{\tau}(b-m_{p}^{2}l^{2})}{R_{m}r(ab-m_{p}^{2}l^{2})}&\frac{K_{\tau}h}{ R_{m}r(ab-m_{p}^{2}l^{2})}\\ 0&0\\ \frac{K_{\tau}h}{R_{m}rc}&\frac{-K_{\tau}h}{R_{m}rc}\end{bmatrix}\end{split} \tag{10}\]  
where  
\[\begin{split} a&=m_{p}+2m_{w}+\frac{2l_{w}}{r^{2}}\\ b&=I_{p}+m_{p}l^{2}\\ c&=I_{p_{z}}+\frac{2l_{w}}{r^{2}}h^{2}+2m_{w}h^{2}\\ \alpha&=\frac{-2K_{\tau}K_{\text{\tiny{eff}}}(m_{p}lr+b)-2K_{ \text{\tiny{f}}}R_{m}(b+m_{p}lr)}{R_{m}r^{2}(ab-m_{p}^{2}l^{2})}\\ \beta&=\frac{2K_{\tau}K_{\text{\tiny{eff}}}(ra+m_{p}l)+2K_{ \text{\tiny{f}}}R_{m}(ra+m_{p}l)}{R_{m}r^{2}(ab-m_{p}^{2}l^{2})}\end{split} \tag{11}\]  
The MS system parameters are shown in Table 1.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Symbol** & **Description** & **Value/Unit** \\ \hline \(K_{emf}\) & Motor EMF constant & 0.027 V\textasciitilde{}s/rad \\ \(K_{\tau}\) & Motor torque constant & 0.23 N\textasciitilde{}m/A \\ \(R_{m}\) & Motor internal resistance & 4.8 \(\Omega\) \\ \(K_{f}\) & Motor shaft friction coefficient & 0.001 N\textasciitilde{}s/rad \\ \(l_{w}\) & Wheel moment of inertia & 0.0000409 kgm\({}^{2}\) \\ \(l_{p}\) & Cart body moment of inertia & 0.0012 kgm\({}^{2}\) \\ \(l\) & Distance between cart body & 0.02 m \\  & center of mass and y-axis & \\ \(m_{w}\) & Wheel mass & 0.0492 kg \\ \(m_{p}\) & Cart body mass & 0.7197 kg \\ \(r\) & Wheel radius & 0.034 m \\ \(h\) & Half cart width & 0.086 m \\ \hline \hline \end{tabular}
\end{table}
Table 1: Mini-Segway parameters.  
With these parameter values defined in Table 1, the MS state-space model becomes  
\[A=\begin{bmatrix}0&1&0&0&0&0\\ 0&-6.8776&-1.6517&0&0&0\\ 0&0&0&1&0&0\\ 0&156.8512&107.3635&0&0&0\\ 0&0&0&0&0&1\\ 0&0&0&0&-26.4502\end{bmatrix} \tag{12}\]  
\[B=\begin{bmatrix}0&0\\ 2.4425&2.4425\\ 0&0\\ -55.7028&-55.7028\\ 0&0\\ 19.3887&-19.3887\end{bmatrix}\]  
The MS system is open-loop unstable due to a positive pole located at \(s=9.5715\). In order to further improve the system performance experimentally, the plant dynamics shall be stabilized before the SHI scheme can be applied since the proposed SHI requires a stable plant.