Modelling, Simulation, and Stabilization of a Two- Wheeled Inverted Pendulum Robot Using Hybrid Fuzzy Control

Article Info Abstract Article History: Received July 20, 2020 Revised August 14, 2021 Accepted August 16, 2021 Two wheels inverted pendulum robot has the same characteristics as inverted pendulum, which are unstable and nonlinear. Nonlinear systems can often be linearized by approximating them by a linear system obtained by expanding the nonlinear solution in a series, and then linear techniques can be used. Fuzzy logic control is the famous nonlinear controller that has been used by researchers to analyze the performance of a system due to the easiness to understand the nature of the controller. This research discusses about two wheels inverted pendulum robot design using hybrid fuzzy control. There are two types of fuzzy control, namely Fuzzy Balanced Standing Control (FBSC) to maintain stability and Fuzzy Traveling and Position Control (FTPC) to maintain position. Based on TakagiSugeno (T-S) fuzzy model on two wheels inverted pendulum robot, FBSC control used Parallel Distributed Compensation (PDC) with pole placement technic. Based on two wheels inverted pendulum robot movement characteristics, FTPC was designed using Mamdani Fuzzy architecture. FTPC control is used to help FBSC to maintain robot stability and to adjust to the desired position. Simulation result shows that controller for two wheels inverted pendulum robot can stabilize pendulum angle in 0 radian and close to the desired position.


I. INTRODUCTION
Two wheels inverted pendulum robot is a robot that has 2 (two) wheels that work like reversed pendulum. This robot has the same characteristics as inverted pendulum, which are unstable and nonlinear. The main goal of this research is to stabilize the robot to its reversed position and back to its previous position or desired position.
In recent years, fuzzy control design based on Takagi-Sugeno (T-S) model had been widely used on wider applications such as manipulator robot [1], trailer [2], hovercraft [3], and helicopter [4]. Fuzzy control had been well implemented in so many nonlinear systems. However, systematically, fuzzy control design for system stability analysis is still an interesting challenge, especially in nonlinear system control design. This is because nonlinearity is always interfering real system control since it is only partially known, it is hard to described, and there are only a few measured states [5].
There have been several studies on two-wheeled inverted pendulum robots with fuzzy control, among others, those conducted by Almeshal et al. who used robust hybrid fuzzy logic control with movable loads [6], in addition, Kharola's research made a control design using the fuzzy method. logic control strategy to control and stabilize the robot [7], then [8] the author developed a fuzzy logic controller for the two-wheeled LEGO EV3 robot and finally the research conducted by Huang et al designed a type-2 interval fuzzy logic modeling and inverted pendulum control two-wheel moving [9].

94
There two fuzzy controls in the controller design, namely fuzzy balanced standing control (FBSC) and fuzzy traveling and position control (FTPC). FBSC uses parallel distributed compensation (PDC) concept with pole placement technic to stabilize the robot based on fuzzy Takagi-Sugeno. While FTPC uses heuristic rule Mamdani architecture to design movement and position. The robot is a nonlinear model and need to be changed to linear model via linearization process. This paper organized into five sections. Section I contains introduction of this research. The next section discusses the mathematical model of two wheels inverted pendulum robot and hybrid fuzzy control Section III explains about the result of the two wheels inverted pendulum robot while section IV contains discussion about the results, limitation and compare the results with others Lastly, conclusion for this research is stated in section V.

A. Mathematical Model of Two Wheels Inverted Pendulum
Robot There are two steps to obtain mathematical model of two wheels inverted pendulum robot. First is knowing the coordinate system used by two wheels inverted pendulum robot with geometric parameters shown in Fig. 1. ϕ is pendulum tilt angle and θ is the average value of motor rotary angle, described as follows = ( + ) 2 ⁄ . and is rotary angle of left motor and right motor respectively. The geometric parameters and values of a two-wheeled inverted pendulum robot is presented on Table 1 [10]. Based on concept of physic, force resultant of x-axis described in equation (1).
where is force given by motor rim along x-axis, described as = + , where and describes the forces of rim of right motor and left motor respectively, the momentum on the pendulum circle point describes equation (2).
While the torque is described in equation (3).
Two wheels inverted pendulum robot consist of 4 states that describe as a vector ( ) = [ ̇ ̇ ] where 1 = declares pendulum tilt angle, 2 = ̇ declares pendulum angle speed which is the first derivative of pendulum tilt angle ( 2 = 1 ⁄ ), 3 =̇ declares motor rotational angle speed which is the first derivative of motor rotational angle ( ⁄ ), and 4 = declares motor rotational angle. The following is two wheels inverted pendulum robot state equation (4).

B. Hybrid Fuzzy Control on Two Wheels Inverted Pendulum Robot 1) Mamdani Fuzzy Controller Design
FTPC controller for position of the two wheels inverted pendulum robot is using Mamdani Fuzzy model with 2 premises and 49 if-the rules. This control design is used not only 95 to help FBSC controller to maintain robot stability but also to guide to the desire position. At the initial condition, positive or negative direction value is assigned to the pendulum angle, then the two wheels inverted pendulum robot will move forward or backward preventing pendulum from falling and keeping the robot walking through to the desired position. If an error occurs, the two wheels inverted pendulum robot position describes in equation (5).
where declares the two wheels inverted pendulum robot desired position and ( ) declares the two wheels inverted pendulum robot current position, so the desired state will be ( ) = [ ( ) 0 0 0] , while state error ( ) describes equation (6).
where ( ) declares pendulum angle error.  Membership function used in , ,̇ and are triangle and describes as follows (7): There are 7 (seven) fuzzy sets used in , ̇, and , namely negative big (NB), negative medium (NM), negative small (NS), zero (ZO), positive small (PS), positive medium (PM), and positive big (PB). If consequence "u is " is a conclusion obtained when premises "x is " and "x is ̇ " are fulfilled, then there are 49 fuzzy rules for robot control position shown in Table 2. Fig. 2 depicts membership function with two inputs (premises), i.e., position error ( ) and wheel rotation speed () also output (consequence) shown as pendulum desired angle ( ).

2) Fuzzy Takagi-Sugeno Controller Design
Fuzzy T-S model design for balancing the two wheels inverted pendulum robot is using 2 rules. Membership function in this fuzzy rule only implemented for pendulum angle output ( ). Membership function in this research is triangle membership function describes in equation (8).
where is the left limit parameter, is the midpoint and is the right limit, while x is a variable.

96
This research is conducted using 2 rules. The first rule is used when the angle is 0 radian and the second is when the angle ±0.2 radian, so the membership grade can be depicted in Fig. 3. Henceforth, Parallel Distributed Compensation (PDC) is used to specify controller parameter state ( ) in equation (6). Control rules in PDC designed based on corresponding plant rule in equation (9) are specified as follows: rule 1 for controller: Result from all control signal written as an equation 11.
where 1 is the weight of rule 1 and 2 is the weight of rule 2.
Block diagram of two wheels inverted pendulum robot using hybrid fuzzy control is depicted in Fig. 4.  In this part, the designed controller is simulated on two wheels inverted pendulum robot plant. Based on equation 4 Linearization, robot system state-space equation is obtained in equation (12).
With working point 1 is 0; 0,2 dan are then obtained as follows respectively: Peak time used to measure robot position performance and pendulum angle is determined when reached the highest point. Fig. 5 shows performance measure for robot position compared to initial angle 0.2 radian and initial angle 0.3 radian with the robot position is back to the initial position. Peak time at initial angle 0.2 radian is around 0.61 second with maximum overshoot is around 1.465 meters, and settling time is around 5.91 seconds, while peak time at initial angle 0.3 radian is around 0.72 second with maximum overshoot is around 2.053 meters, and settling time is around 6.29 seconds. Fig. 5 also shows that pendulum robot is experiencing deviation before moving back to its original position. At initial angle 0.3 radian, robot experiencing the largest deviation compare to when the initial angle is 0.2 radian. To be concluded that the larger the given initial angle, the larger the peak time likely to be and the maximum overshoot as well. Fig. 6 depicts control signal performance measurement with comparison between initial angle 0.2 radian against initial angle 0.3 radian. The generated control signal is 20 Newton meter.
Pendulum angle performance is shown in Fig. 7. Peak time at initial angle 0.2 radian is around 0.61 second with maximum undershoot is around 0.008755 radian, and settling time is around 1.83 seconds, while peak time at initial angle 0.3 radian is around 0.81 second with maximum undershoot is around 0.01215 radian, and settling time is around 1.86 second. Based on the responses, it can be concluded that the larger the initial angle the larger the undershoot value.   The following is examination simulation using initial angle 0.2 radian with = 0.2 meter and = 0.4 meter. Fig. 8 depicts performance measurement for robot position with initial angle 0.2 radian and = 0.2meter, peak time is around 0.65 second, with maximum overshoot is around 1.554 meter, settling time is around 7.67 seconds and robot position 0.1847 meter.
Pendulum angle response can be seen in Fig. 9, with peak time when initial angle 0.2 radian is around 0.61 second with maximum undershoot is around 0.0102 radian, and settling time is around 2.08 seconds.
Simulation in Fig. 10 with initial angle 0.2 radian and = 0.4 meter. Peak time when the initial angle 0.2 radian is around 0.69 second with maximum overshoot is around 1.7 meters, and settling time is around 7.2 seconds and robot position 0.3679 meter.
Pendulum angle performance is shown in Fig. 11 with initial angle 0.2 radian, peak time when initial angle 0.2 radian is around 0.62 second with maximum undershoot is around 0.01269 radian, and settling time is around 2.14 seconds.
Based on the available data and compare it with the error obtained from simulation result against the desired position, it is can be concluded that the greater the desired position ( ), the greater the position error. When = 0.2 meter, position error is 7.65%, while when = 0.4 meter, position error is 8.02%.

IV. DISCUSSION
Simulation result shows that controller for two wheels inverted pendulum robot can stabilize pendulum angle in 0 radian and close to the desired position. The simulation results on fuzzy traveling and position control (FTPC) have an error of about 8% to control and stabilize the two-wheeled inverted pendulum robot in the desired position. Huang et-al developed design and implementation of fuzzy control on a two-wheeled inverted pendulum. The combination of FTPC and FBSC works very well. The proposed FTPC can enhance the performance of the FBSC. For the purpose of the FBSC, the TWIP moves backward quickly to avoid falling down. Then, the TWIP travels forward to reach the desired position due to the effort of the FTPC.

V. CONCLUSION
Based on testing result of Mamdani and Takagi-Sugeno fuzzy control system simulation using Parallel Distributed Compensation (PDC) concept and pole placement technic in this research, it can be concluded that the simulation result of the FBSC controller is that the two wheels inverted pendulum robot system is able to maintain the upright pendulum position at angle 0 radian. Meanwhile the result of the FTPC controller simulation is that the two wheels inverted pendulum robot system can approach to the desired position with an error of about 8%. Research can be developed by implementing hybrid fuzzy control on a two-wheeled pendulum robot.