## Appendix A Derivation of Dynamic Model  
First, consider the dynamics of the left wheel. All notations denoted by subscripts of \(L\) and \(R\) are associated with the the left and right wheels, respectively. Let \(A_{L}\) be the contact point with the ground; \(H_{L}\) be the friction; \(N_{L}\) be the normal force by the ground; \(F_{xL}\) and \(F_{y}L\) be the forces exerted by the cart; \(M_{L}\) be the mass of the wheel; \(W_{L}=M_{L}g\) be the weight; \(T_{L}\) be the controlling torque provided by the motor; and \(R\) be the radius of the two wheels.  
The dynamic equations of the wheels in the cart-body-fixed frame are shown as follows  
\[\left\{\begin{array}{rcl}-\ddot{\theta}_{L}I_{L}&=&-T_{L}+H_{L}R\\ \ddot{x}_{L}M_{L}&=&-F_{xL}+H_{L}\\ 0&=&F_{yL}+N_{L}-M_{L}g\end{array}\right., \tag{1}\]  
where \(J_{L}\) is the moment of inertia of the wheel and \(\theta_{L}\) is the rolling angle of the wheel. A similar process can be applied to the right wheel and yields  
\[\left\{\begin{array}{rcl}-\ddot{\theta}_{R}I_{R}&=&-T_{R}+H_{R}R\\ \ddot{x}_{R}M_{R}&=&-F_{xR}+H_{R}\\ 0&=&F_{yR}+N_{R}-M_{R}g\end{array}\right.. \tag{2}\]  
The assumption of no slipping leads to \(\ddot{x}_{L}=R\ddot{\theta}_{L}\) and \(\ddot{x}_{L}=R\ddot{\theta}_{R}\). Assume the two wheels are identical. Then \(M_{L}=M_{R}=M_{w}\), \(J_{L}=J_{R}=I_{w}\), \(\ddot{x}_{L}=\ddot{x}_{R}=\ddot{x}\), \(\theta_{L}=\theta_{R}=\theta_{w}\)\(T_{L}=T_{R}=\ddot{u}^{*}\). Notably, \(\theta_{w}\) is defined positive to have the TWVS move toward \(+\dot{\mathbf{i}}\)The dynamics of the cart is given as follows:  
\[\left\{\begin{array}{rcl}F_{xL}+F_{xR}-F_{p}&=&M\ddot{x}\\ -F_{yL}-F_{yR}-N_{p}&=&Mg\end{array}\right., \tag{10}\]  
where \(M\) is the mass of the cart. Since longitudinal forces are assumed to be exerted passing through the cm and lateral forces are balanced, there is no equation for torques. This also implies that the cart-body-fixed frame does not rotate and it is, hence, coincident with the inertial frame.  
The equations of the pendulum's translation are derived with respect to the cm of the pendulum, whereas the equation of the rotation is derived with respect to the lower tip of the pendulum for convenience, where the pendulum is linked to the cart. Therefore, the equations of motion are obtained by [29]  
\[\sum\mathbf{F} = m\mathbf{a}_{G}, \tag{11}\] \[\sum\mathbf{M} = \mathbf{r}_{G}\times m\mathbf{a}_{G}+J_{p}\ddot{\theta}\mathbf{k}, \tag{12}\]  
where \(m\) is the mass of the pendulum; \(J_{p}\) is the moment of inertia about the pendulum cm. Moreover, \(\mathbf{r}_{G}\) is the position vector pointing from the tip to the pendulum cm, and \(\mathbf{a}_{G}\) is the acceleration of the pendulum cm. The two terms can be found by  
\[\mathbf{r}_{G} = l(-\cos\theta\mathbf{i}+\sin\theta\mathbf{j}) \tag{13}\] \[\mathbf{a}_{G} = \mathbf{a}_{c}+\ddot{\theta}\mathbf{k}\times\mathbf{r}_{G}+\dot {\theta}\mathbf{k}\times(\dot{\theta}\mathbf{k}\times\mathbf{r}_{G}), \tag{14}\]  
where \(l\) is the half length of the pendulum and \(\mathbf{a}_{c}=\ddot{x}\mathbf{i}\) is the acceleration of the cart. Expanding (11) through (14) yields (49) and  
\[F_{p} = ml\sin\theta\dot{\theta}^{2}+m\ddot{x}-ml\cos\theta\ddot{\theta} \tag{15}\] \[N_{p}-mg = -ml\cos\theta\dot{\theta}^{2}-ml\sin\theta\ddot{\theta}. \tag{16}\]  
Substituting (10), (11), and (15) into (10) yields  
\[H_{L}-2M_{w}\ddot{x}+H_{R}-\left(ml\sin\theta\dot{\theta}^{2}+m \ddot{x}-ml\cos\theta\ddot{\theta}\right) = M\ddot{x} \tag{17}\]  
Moreover, \(H_{L}=\ddot{u}^{*}/R-J_{w}\ddot{x}/R^{2}\) and \(H_{R}=\ddot{u}^{*}/R-J_{w}\dot{x}/R^{2}\). Consequently, (17) can be re-written as (50), given as  
\[\left(M+m+2M_{w}+\frac{2J_{w}}{R^{2}}\right)\ddot{x}-ml\cos\theta \ddot{\theta} = 2\frac{\ddot{u}^{*}}{R}-ml\sin\theta\dot{\theta}^{2}.\]