**2. System model**

### **2.1 Kinematic model**

The general kinematics of the Ballbot is a relationship between **ϕ**\_ *<sup>k</sup>* ¼ *φ*\_ *<sup>x</sup> φ*\_ *<sup>y</sup> φ*\_ *<sup>z</sup>* h i*<sup>T</sup>* , the angular velocity of the ball relative to the body frame, and *ψ*\_ *<sup>i</sup>* (*i* ¼ 1, 2, 3), the angular velocities of the three OWs relative to the reference frame of the body. The kinematics relationship of dual-row OWs was discussed in [22]. For the Ballbot, the

*Hierarchical Sliding Mode Control for a 2D Ballbot That Is a Class of Second-Order… DOI: http://dx.doi.org/10.5772/intechopen.101855*

three OWs, a kind of single-row OW, are mounted on the body of the robot. The driving axes are separated by 120° in the *x*-*y* plane and each driving axis is sloped downward by *α*.

The main assumptions for simplification of the system are:


The non-slip condition of the surface of the ball-OWs is met by requiring that the projection of velocities of the ball at all contact points in the actuation direction of the OW be the same and expressed mathematically as

$$
\dot{\boldsymbol{\nu}}\_i \boldsymbol{r}\_w = \left(\dot{\boldsymbol{\Phi}}\_k \times \mathbf{P}\_i\right) \mathbf{u}\_{wi}, i = \mathbf{1}, 2, 3,\tag{1}
$$

where **P***<sup>i</sup>* is the position vector from the center of the ball to the contact point *i* between the ball and the *i*th OW in the body frame as indicated in **Figure 1**, **u***wi* is the vector of direction cosines of the *i*th OW contact point velocities in the actuation directions, and *rw* is the radius of the OW.

Therefore, the angular velocities of the OWs are expressed as

$$
\dot{\boldsymbol{\nu}}\_i = \frac{1}{r\_w} (\dot{\boldsymbol{\Phi}}\_k \times \mathbf{P}\_i) \mathbf{u}\_{wi},\\ \dot{\boldsymbol{\imath}} = \mathbf{1}, \mathbf{2}, \mathbf{3}. \tag{2}
$$

As shown in **Figure 1**, the position vector of the contact point **P***<sup>i</sup>* can be defined by

$$\mathbf{P}\_1 = \begin{bmatrix} r\_k \sin a & \mathbf{0} & r\_k \cos a \end{bmatrix}^T,\tag{3a}$$

**Figure 1.** *Sketch of decomposed angular velocities of three OWs and a ball.*

$$\mathbf{P}\_{2,3} = \begin{bmatrix} \mathbf{1} \\ -\frac{1}{2}r\_k \sin a & \pm \frac{\sqrt{3}}{2}r\_k \sin a & r\_k \cos a \end{bmatrix}^T. \tag{3b}$$

Furthermore, the direction cosine vectors that provide the corresponding direction of the speed at the contact point between the OWs and the ball are defined by

$$\mathbf{u}\_{w1} = \begin{bmatrix} \mathbf{0} & \mathbf{1} & \mathbf{0} \end{bmatrix}^T,\tag{4a}$$

$$\mathbf{u}\_{w2,3} = \left[ \mp \frac{\sqrt{3}}{2} \quad -\frac{1}{2} \quad \mathbf{0} \right]^T \cdot \tag{4b}$$

Substituting (3a), (3b), (4a) and (4b) into (2) yields

$$\begin{bmatrix} \dot{\rho}\_x & \dot{\rho}\_y & \dot{\rho}\_x \end{bmatrix}^T = \mathbf{J}(a) \begin{bmatrix} \dot{\psi}\_1 & \dot{\psi}\_2 & \dot{\psi}\_3 \end{bmatrix}^T,\tag{5}$$

where **J**ð Þ α is the Jacobian matrix of the system

$$\mathbf{J}(a) = \begin{bmatrix} -\frac{2r\_w}{3r\_k \cos \alpha} & \frac{r\_w}{3r\_k \cos \alpha} & \frac{r\_w}{3r\_k \cos \alpha} \\ 0 & -\frac{\sqrt{3}r\_w}{3r\_k \cos \alpha} & \frac{\sqrt{3}r\_w}{3r\_k \cos \alpha} \\ \frac{r\_w}{3r\_k \sin \alpha} & \frac{r\_w}{3r\_k \sin \alpha} & \frac{r\_w}{3r\_k \sin \alpha} \end{bmatrix}. \tag{6}$$

The Jacobian matrix (6) represents the effect of the zenith angle on the motion relationship between the ball and three single-row OWs.

### **2.2 Dynamic model**

**Figure 2** presents the planar model of the Ballbot. The system of the Ballbot is modeled as a rigid cuboid on top of a ball to get a simple calculation of the system parameters. The ball mass *mk* and OW mass *mw* are considered as point masses concentrated at their centers. *ma* represents the equivalent mass of all components including the body, drive mechanism, and other parts. Chosen generalized coordinates of the Ballbot system include *xk*ð Þ*t* , *yk*ð Þ*t* , *θx*ð Þ*t* , and *θy*ð Þ*t* , here, *xk*ð Þ*t* , *yk*ð Þ*t* denote

**Figure 2.** *Planar model of the main driving system of the Ballbot.*

*Hierarchical Sliding Mode Control for a 2D Ballbot That Is a Class of Second-Order… DOI: http://dx.doi.org/10.5772/intechopen.101855*

the position of the, *θx*ð Þ*t* , and *θy*ð Þ*t* are the orientation of the body around the *x*- and *y*axes. The control input is the resultant moment of the three actuators, whose *x* and *y* terms are τ*<sup>x</sup>* and τ*y*.

The Ballbot system dynamics are described by obtaining the kinetic and potential of the ball, body, and OWs. For the ball,

$$T\_{k\mathbf{x}} = \frac{1}{2} \left( m\_k + \frac{I\_k}{r\_k^2} \right) \dot{\mathbf{y}}\_k^2, V\_{k\mathbf{x}} = \mathbf{0},\tag{7}$$

where *rk* is the ball radius and *Ik* is the ball momentum inertia.

The OWs are attached to the body of the Ballbot. Thus, only the rotational motion of the OWs has to be calculated, that is,

$$T\_{w\infty} = \frac{3I\_w \cos^2 \alpha}{4r\_w^2} \left(\dot{y}\_k + r\_k \dot{\theta}\_\mathbf{x}\right)^2, V\_{w\mathbf{x}} = \mathbf{0},\tag{8}$$

where *rw* is the radius of each OW, α represents the zenith angle, and *Iw* indicates the momentum inertia of each OW.

For the body,

$$T\_{ax} = \frac{1}{2}I\_x \dot{\theta}\_x^2 + \frac{1}{2}m\_a \left(\dot{y}\_k - l\dot{\theta}\_x \cos\theta\_x\right)^2 + \frac{1}{2}m\_al^2 \dot{\theta}\_x^2 \sin^2\theta\_x,\\ V\_{ax} = m\_al \dot{q} \cos\theta\_x,\tag{9}$$

where *Ix* is the body momentum inertia around the *x*-axis, *l* represents the distance from the ball center to the body mass center, and *g* denotes the gravitational acceleration.

In the *y*-*z* plane, the generalized coordinates of the Ballbot system are defined as **q***<sup>x</sup>* ¼ *yk θ<sup>x</sup>* � �*<sup>T</sup>* and the friction vector

$$\mathbf{D}(\dot{\mathbf{q}}\_{\mathbf{x}}) = \begin{bmatrix} b\_{\mathbf{y}} \dot{\mathbf{y}}\_{\mathbf{k}} & b\_{\mathbf{r}\mathbf{x}} \dot{\boldsymbol{\theta}}\_{\mathbf{x}} \end{bmatrix}^{T},\tag{10}$$

where *by* and *brx* are the viscous damping coefficients that model the ball-floor friction and ball-body friction in the *y*-*z* plane, respectively.

The Lagrangian function *Lx* is expressed as

$$\begin{aligned} L\_x &= T\_x - V\_x = T\_{kx} + T\_{wx} + T\_{ax} - \left(V\_{kx} + V\_{wx} + V\_{ax}\right) \\ &= \begin{pmatrix} \frac{1}{2} \left(m\_k + \frac{I\_k}{r\_k^2}\right) \dot{\mathbf{j}}\_k^2 + \frac{3I\_w \cos^2 \alpha}{4r\_w^2} \left(\dot{\mathbf{y}}\_k + r\_k \dot{\theta}\_x\right)^2 \\\\ + \frac{1}{2} I\_x \dot{\theta}\_x^2 + \frac{1}{2} m\_d \left(\dot{\mathbf{y}}\_k - l \dot{\theta}\_x \cos \theta\_x\right)^2 + \frac{1}{2} m\_d l^2 \dot{\theta}\_x^2 \sin^2 \theta\_x - m\_d gl \cos \theta\_x \end{pmatrix}, \end{aligned} \tag{11}$$

The Euler-Lagrange equation that describes the motion of the Ballbot is

$$\frac{d}{dt}\left(\frac{\partial L\_{\mathbf{x}}}{\partial \dot{\mathbf{q}}\_{\mathbf{x}}}\right) - \frac{\partial L\_{\mathbf{x}}}{\partial \mathbf{q}\_{\mathbf{x}}} = \frac{1}{r\_{w}} \begin{bmatrix} 1 \\ r\_{k} \end{bmatrix} \boldsymbol{\varepsilon}\_{\mathbf{x}} - \mathbf{D}\left(\dot{\mathbf{q}}\_{\mathbf{x}}\right). \tag{12}$$

From (12), the dynamic equations on the *y*-*z* plane are expressed as follows:

$$(\ddot{y}\_k a\_1 + (a\_4 - a\_3 \cos \theta\_\mathbf{x})\ddot{\theta}\_\mathbf{x} + a\_3 \dot{\theta}\_\mathbf{x}^2 \sin \theta\_\mathbf{x} + b\_j \dot{y}\_k = r\_w^{-1} \tau\_\mathbf{x},\tag{13}$$

$$(a\_4 - a\_3 \cos \theta\_\mathbf{x})\ddot{\mathbf{y}}\_k + \ddot{\theta}\_\mathbf{x} a\_2 + b\_{\mathbf{r}\mathbf{x}} \dot{\theta}\_\mathbf{x} - a\_5 \sin \theta\_\mathbf{x} = r\_k r\_w^{-1} \tau\_\mathbf{x},\tag{14}$$

where *<sup>a</sup>*<sup>1</sup> <sup>¼</sup> *mk* <sup>þ</sup> *Ikx r*2 *k* <sup>þ</sup> *ma* <sup>þ</sup> <sup>3</sup>*Iw*cos2*<sup>α</sup>* 2*r*<sup>2</sup> *w* , *a*<sup>2</sup> ¼ *mal* <sup>2</sup> <sup>þ</sup> <sup>3</sup>*Iwr*<sup>2</sup> *<sup>k</sup>*cos2*<sup>α</sup>* 2*r*<sup>2</sup> *w* þ *Ix*, *a*<sup>3</sup> ¼ *mal*, *a*<sup>4</sup> ¼ 3*Iw*cos2*α* 2*r*<sup>2</sup> *w rk*, *a*<sup>5</sup> ¼ *magl*, *Ik* refers to the ball momentum inertia, *Iw* is the OW momentum inertia, *Ix* denotes the body momentum inertia about the *x*-axis, *by* and *brx* are the viscous damping coefficients.

Then, (13) and (14) can be rewritten as follows:

$$
\ddot{y}\_k = F\_{\text{x1}}(\mathbf{q}\_{\text{x}}, \dot{\mathbf{q}}\_{\text{x}}) + G\_{\text{x1}}(\mathbf{q}\_{\text{x}})\tau\_{\text{x}},\tag{15}
$$

$$
\ddot{\boldsymbol{\theta}}\_{\mathbf{x}} = \boldsymbol{F}\_{\mathbf{x}2} \left( \mathbf{q}\_{\mathbf{x}}, \dot{\mathbf{q}}\_{\mathbf{x}} \right) + \mathbf{G}\_{\mathbf{x}2} \left( \mathbf{q}\_{\mathbf{x}} \right) \boldsymbol{\tau}\_{\mathbf{x}}, \tag{16}
$$

$$\begin{aligned} \text{where } &F\_{x1}(\mathbf{q}\_{\mathbf{x}}, \dot{\mathbf{q}}\_{\mathbf{x}}) = A\_{\mathbf{x}}^{-1} \Big[ (a\_3 \cos \theta\_{\mathbf{x}} - a\_4)(a\_5 \sin \theta\_{\mathbf{x}} - b\_{\mathbf{x}} \dot{\theta}\_{\mathbf{x}}) - a\_2 \Big( a\_3 \dot{\theta}\_{\mathbf{x}}^2 \sin \theta\_{\mathbf{x}} + b\_3 \dot{\eta}\_{\mathbf{x}} \Big) \Big], \\\\ &G\_{x1}(\mathbf{q}\_{\mathbf{x}}) = A\_{\mathbf{x}}^{-1} r\_{\mathbf{w}}^{-1} (a\_2 + a\_3 r\_{\mathbf{k}} \cos \theta\_{\mathbf{x}} - a\_4 r\_{\mathbf{k}}), \end{aligned}$$

$$\begin{aligned} F\_{x2}(\mathbf{q}\_{\mathbf{x}}, \dot{\mathbf{q}}\_{\mathbf{x}}) = A\_{\mathbf{x}}^{-1} \Big[ (a\_4 - a\_3 \cos \theta\_{\mathbf{x}}) \Big( a\_3 \dot{\theta}\_{\mathbf{x}}^2 \sin \theta\_{\mathbf{x}} + b\_3 \dot{\eta}\_{\mathbf{x}} \Big) + a\_1 (a\_5 \sin \theta\_{\mathbf{x}} - b\_{\mathbf{x}} \dot{\theta}\_{\mathbf{x}}) \Big], \\\\ &G\_{x2}(\mathbf{q}\_{\mathbf{x}}) = A\_{\mathbf{x}}^{-1} r\_{\mathbf{w}}^{-1} (a\_3 \cos \theta\_{\mathbf{x}} - a\_4 + a\_1 r\_{\mathbf{k}}), \end{aligned}$$

$$A\_{\mathbf{x}} = a\_1 a\_2 - (a\_4 - a\_3 \cos \theta\_{\mathbf{x}})^2.$$

In the *x*-*z* plane, the mathematical equations describe the Ballbot system dynamics as follows:

$$\ddot{\mathbf{x}}\_x \mathbf{b}\_1 + (b\_4 \cos \theta\_\mathbf{y} - b\_3) \ddot{\theta}\_\mathbf{y} - b\_4 \dot{\theta}\_\mathbf{y}^2 \sin \theta\_\mathbf{y} + b\_x \dot{\mathbf{x}}\_k = -r\_w^{-1} \tau\_\mathbf{y},\tag{17}$$

$$(b\_4 \cos \theta\_\circ - b\_3) \ddot{\mathbf{x}}\_k + \ddot{\theta}\_\circ b\_2 - b\_5 \sin \theta\_\circ + b\_\eta \dot{\theta}\_\circ = r\_k r\_w^{-1} \tau\_\circ,\tag{18}$$

where *<sup>b</sup>*<sup>1</sup> <sup>¼</sup> *mk* <sup>þ</sup> *Ik r*2 *k* <sup>þ</sup> <sup>3</sup>*Iw*cos2*<sup>α</sup>* 2*r*<sup>2</sup> *w* <sup>þ</sup> *ma*, *<sup>b</sup>*<sup>2</sup> <sup>¼</sup> <sup>3</sup>*Iwr*<sup>2</sup> *<sup>k</sup>*cos2*<sup>α</sup>* 2*r*<sup>2</sup> *w* þ *mal* <sup>2</sup> <sup>þ</sup> *Iy*, *<sup>b</sup>*<sup>3</sup> <sup>¼</sup> <sup>3</sup>*Iw*cos2*<sup>α</sup>* 2*r*<sup>2</sup> *w rk*, *b*<sup>4</sup> ¼ *mal*, *b*<sup>5</sup> ¼ *magl*, *Iy* represents the body momentum inertia about the *y*-axis, *bx* and *bry* are the viscous damping coefficients.

In the *x*-*z* plane, minimal coordinates of the Ballbot system denotes **q***<sup>y</sup>* ¼ *xk θ<sup>y</sup>* � �*<sup>T</sup>* , then (17) and (18), are rewritten as follows:

$$
\ddot{\boldsymbol{x}}\_k = \boldsymbol{F}\_{\mathcal{Y}1}\left(\mathbf{q}\_{\mathcal{Y}}, \dot{\mathbf{q}}\_{\mathcal{Y}}\right) + \boldsymbol{G}\_{\mathcal{Y}1}\left(\mathbf{q}\_{\mathcal{Y}}\right)\boldsymbol{\varepsilon}\_{\mathcal{Y}},\tag{19}
$$

$$
\ddot{\boldsymbol{\theta}}\_{\mathcal{Y}} = \boldsymbol{F}\_{\mathcal{Y}^2} \left( \mathbf{q}\_{\mathcal{Y}}, \dot{\mathbf{q}}\_{\mathcal{Y}} \right) + \boldsymbol{G}\_{\mathcal{Y}^2} \left( \mathbf{q}\_{\mathcal{Y}} \right) \boldsymbol{\varepsilon}\_{\mathcal{Y}}, \tag{20}
$$

$$\begin{aligned} \text{where } &F\_{\mathcal{I}1}\left(\mathbf{q}\_{\mathcal{Y}},\dot{\mathbf{q}}\_{\mathcal{Y}}\right) = A\_{\mathcal{Y}}^{-1}\Big[b\_{2}\Big(b\_{4}\sin\theta\_{\mathcal{Y}}\dot{\theta}\_{\mathcal{Y}}^{2} - b\_{x}\dot{\mathbf{x}}\_{k}\Big) + \left(b\_{3} - b\_{4}\cos\theta\_{\mathcal{Y}}\right)\big(b\_{5}\sin\theta\_{\mathcal{Y}} - b\_{\mathcal{Y}}\dot{\theta}\_{\mathcal{Y}}\Big)\Big], \\\\ &G\_{\mathcal{Y}1}\Big(\mathbf{q}\_{\mathcal{Y}}\Big) = -A\_{\mathcal{Y}}^{-1}r\_{w}^{-1}\big(b\_{2} - b\_{3}r\_{k} + b\_{4}r\_{k}\cos\theta\_{\mathcal{Y}}\Big), \\ &F\_{\mathcal{Y}2}\Big(\mathbf{q}\_{\mathcal{Y}},\dot{\mathbf{q}}\_{\mathcal{Y}}\Big) = A\_{\mathcal{Y}}^{-1}\Big[\left(b\_{3} - b\_{4}\cos\theta\_{\mathcal{Y}}\right)\Big(b\_{4}\sin\theta\_{\mathcal{Y}}\dot{\theta}\_{\mathcal{Y}}^{2} - b\_{x}\dot{\mathbf{x}}\_{k}\Big) + b\_{1}\Big(b\_{5}\sin\theta\_{\mathcal{Y}} - b\_{\mathcal{Y}}\dot{\theta}\_{\mathcal{Y}}\Big)\Big], \end{aligned}$$

**106**

*Hierarchical Sliding Mode Control for a 2D Ballbot That Is a Class of Second-Order… DOI: http://dx.doi.org/10.5772/intechopen.101855*

$$G\_{\circ 2} \left( \mathbf{q}\_{\circ} \right) = A\_{\circ}^{-1} r\_{w}^{-1} \left( r\_{k} b\_{1} - b\_{3} + b\_{4} \cos \theta\_{\circ} \right),$$

$$A\_{\circ} = b\_{1} a\_{2} - \left( b\_{4} \cos \theta\_{\circ} - b\_{3} \right)^{2}.$$
