**4. Simulation result**

A numerical simulation investigates the stabilize, robustness, and transfer of the proposed controller for the Ballbot. The decoupled dynamics (15) and (16), and (19) and (20) with the proposed control schemes (36) and (37) are modeled in Matlab/Simulink real-time environment with ODE45 and a sampling time of 0.01 seconds.

The parameters of the Ballbot for both simulation and experiment are shown in **Table 1**. For the numerical simulation, the control parameters are tuned by the trial-and-error method and then selected as in **Table 1**.

Various simulations are conducted by considering the stabilizing controls with an initial nonzero tilt angle and with external disturbances and tracking control.

### **4.1 Stabilizing control with nonzero initial tilt angles**

In this simulation, the tilt angles about *x*- and *y*-axes are initialized as 6.3° and �6.5°, respectively for checking the behavior. Simulation results are shown in **Figure 5**. The tilt angles responses and the angular velocities are depicted in **Figure 5(a)** and **(b)**, respectively. The position of the ball is shown in **Figure 5(c)**. **Figure 5(d)** shows the curves of the control inputs.

These numerical results demonstrate that the proposed robust controller enables to maintain stabilizing of the Ballbot.


### **Table 1.** *System parameters and control gains.*

### **Figure 5.**

*Simulation results of stabilizing while station-keeping. (a) Tilt angles of the body. (b) Angular velocities of the body. (c) Trajectory of the contact point between the ball and the floor. (d) Control inputs.*

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

### **4.2 Stabilizing control with external disturbances**

In the second simulation, the stabilizing control of the Ballbot is investigated under an external disturbance. An external force of 300 N is applied to the Ballbot system at the sixth second while the Ballbot is stabilizing on the floor. As the results, the body tilt angles and angular tilt angles are depicted in **Figure 6(a)** and **(b)**, respectively. Under the external disturbance, The Ballbot cannot maintain its original position of *xk*, *yk* <sup>¼</sup> ð Þ 0, 0 . Instead, the robot has traveled to a new position of *xk*, *yk* <sup>¼</sup> ð Þ �7*:*4cm, 3*:*1cm as shown in **Figure 6(c)**. The control inputs by the proposed control are converged to zeros after 2 seconds, as depicted in **Figure 6(d)**.

### **4.3 Tracking control**

In the third simulation, the Ballbot is commanded to track a rectangular trajectory with a dimension of 75 cm � 90 cm in 40 s. The system responses of the tilt angles of the body are shown in **Figure 7(b)**. As indicated in **Figure 7(a)**, the proposed control system performs well in tracking desired rectangular trajectory.
