IMPLEMENTATION OF MAMDAMI FUZZY CONTROL ON A MULTI-DOF TWO-WHEEL INVERTED PENDULUM ROBOT

. These days a Two-wheel inverted pendulum (TWIP) robot at-tracts public attention as it is an eﬃcient ergonomics and easy to operate by nuance personals. Furthermore it has attractive design features like compact in size and zero turning radius. However, the traditional TWIP robots have to change its posture to reach the desired speedup and deceleration by changing the robot posture forward and backward make it diﬃcult to control its motion process. Thus, this paper presents here the Mamdami fuzzy control logic to overcome the motion control of Multi-DOF TWIP robot and make its motion smooth and steady control. By introducing two additional DOFs the slider and the swinging conﬁguration, the robot can maintain its vertical posture even climbing and descending on slopes. To validate the robustness of the proposed method, classic PID controller is introduced for comparison in simu- lations and experiments. The simulation results demonstrate the eﬀectiveness of the system design and the better performance in robustness over classic PID control strategy. Finally, the control scheme is implemented on the practical self-designed hardware.


1.
Introduction. In last decade new development has been noticed in the advancement of mobile robotics, specially a two-wheel inverted pendulum(TWIP) robot attracted great attention as mode of transport. The TWIP robot is a self-balancing robot with two independent wheels mounted coaxially on the robot body sharing a single axis. TWIP compact design saves space and it is powered by battery source make it inherent great advantages in regard for oil fired engine pollution reduction which is a serious problem of modern society. Currently, peoples are convinced to use it in their daily life in different aspects which never has been thought before as telepresence [10], security [16], goods transportation [3] and so on. When we are talking about TWIP robots, it is hard to ignore Segway [15] which is the most 1252 YUBAI LIU, XUESHAN GAO AND FUQUAN DAI successful cooperation providing various models and types of TWIP robots for the public as a reliable companion for transportation.
On the other hand, the inverted pendulum system as a popular research direction to investigate new aspects for mobile robotics from the last few decades, the study can be regarded as valuable due to complexity of TWIP motion control and nonlinear systems like aircraft, space vehicle and autonomous mobile robotics. Previous work has been done on theoretical analysis, system simulation and practical experiments on prototypes through the dynamic modelling, stability analysis and control scheme design [11,14,26,20]. Although the TWIP system is considered as an under-actuated system and described by nonlinear equations, it can be transform to linear system around the equilibrium point by using the implication of feedback linearization method [20,22] or Jacobian linearization [11,24]. Then, in the operation region, the traditional linear control approaches can be applied such as LQR [4] and PID [19,7]. However, the linear control strategies limit the working scope and rely on the accuracy of dynamic model. Especially, uncertainty and noisy disturbance involves in practical issues. Therefore, to increase the system functionality accuracy modeling and external disturbance, many robust control methods are employed [21,18,23]. As one of the robust control algorithms, sliding mode control scheme has been applied to various robot platforms [13,8,12].
A comprehensive brief about the intelligent control methods are discussed and many are successfully implemented on the TWIP system and achieved satisfactory performance. One of the merits is that the intelligent control method can work as a mode free approach, thus a precise math model of the system is unnecessary which also means that it can accept a wide range of system parameters [6]. In addition, to accommodate system uncertainties the NNs technique is studied for a wide range of complex nonlinear system when the system dynamics is absent or incomplete [14]. Moreover, the fuzzy control algorithm is adopted as it is nonlinear control method with stand robustness. Furthermore, it also provides a better user interface by expressing translating human linguistic to control strategies. Thus, human knowledge and expert experience can be easily combined in control strategy. A TWIP robot is implemented based on T-S fuzzy controller which can accept a wide range of pitch angle input and have excellent interference resistance [5]. And a simple T-S fuzzy controller is implementing on the real-time robot fulfilling motion task [25]. An adaptive fuzzy logic control approach is presented combining a fuzzy logic engine and a systematic online adaptation mechanism to approximate the unknown dynamics [27]. The advantages of the presented optimized self-tuning PID type fuzzy controller is demonstrated by comparing with the conventional PID controllers and self-tuning controller [1].
Two drawbacks of the TWIP system exist as one is the pitch angle to reach the desired velocity and the second is the risk of overturning in sharp turning because of its high center of gravity(CoG). To eliminate the pitch angle error in motion process, an UW-Car which consists of TWIP system and a movable seat is investigated by applying sliding mode control scheme [17,9]. Thus, the robot can reach the target velocity vertically. Moreover, introducing the swing DOF mechanism can reduce the impact of centrifugal force when turning at high speed [2]. The improvement of the TWIP system stability builds on the CoG position control. On the basis of the evaluation, this paper realizes the TWIP system by adding two additional DOF to eliminate the pitch angle in movement process and adjustment of its posture dynamically, thus the robot can keep itself vertical posture all the time. The elimination of pitch angle and the addition of swinging configuration also improve the stability of the system and the comfort for the driver.
The paper is organized as follows. The mechanical structure and dynamic model are described in Section 2. In section 3, the Mamdami fuzzy controller design is introduced. The section 4 illustrates the effectiveness of the proposed method by simulation and experiment results. Section 5 concludes this paper. System description. The MD-TWIP presented in this paper has two independent driving units including a DC servo motor and a gear box that mounted coaxially to each side of the robot as shown in Figure 1. Obviously, the MD-TWIP is an unstable equilibrium system so that the robot can only keep balanced standing in the condition of well-controlled driving units. By introducing a balanced controller, the basic task is completed and then a slider that can move forwards and backwards along the moving direction of the robot is fixed on the guide rail. The motion of the robot is consequently controllable at the equilibrium state and the robot can fulfill further trajectory planning tasks. Moreover, the swinging structure realizes the improvement of robot stability in yaw steering motion.
The STM32F103 microprocessor is the control center which executes the control algorithms and signal processing. The 32-bit microcontroller is produced by STMicroelectronics containing 128KB Flash, CAN, DMA, 7 timers, 2 ADCs and 9 communication interfaces. In the control system, the signals from the sensors feeds back to the processor and the processor channels the command signals for the motor driver. The signals measured by the gyro and accelerator sensors filtered by Kalman filter and then the analogue signals are converted to digital signals through an ADC. Under the same mechanism, the motor encoder information also filtered and handled by the STM32F103. H-bridge circuits are employed to drive the two running motors which are actuated by the pulse width modulation (PWM) generator. The PWM signal delivers the power to the motors. The two running motors keep the robot body up-right and the slide block motor determine the velocity of the running robot. To clarify the hardware system, a block diagram is provided in is under rectilinear motion on the flat ground. Therefore, an X-Y scheme of the MD-TWIP model with geometric parameters is shown in Figure 3. In the figure, θ b is the pitch angle andθ b is the pitch angle rate. To demonstrate the wheel displacement and velocity, the rotation angle θ w and rotation angle rateθ w of the wheel are involved. The parameter clarification is illustrated in Table 1.

Figure 3. Model of MD-TWIP in rectilinear motion
Lagranges equation is employed to analyze the dynamics of the system. Only linear movement is taken into account in the derivation as shown in the 2-D Figure  3. Therefore, the vector q = [θ θ w L] T indicates the dynamic model of the system. The coordinates of the systems are the wheels ( The position and the velocity of the wheel can be achieved. The Lagrangian is L a = T − U , where T is the total kinetic energy and U is the potential energy. The total kinetic energy (T ) is consist of three parts the kinetic energy of the wheels (T w ), the body (T b ) and the slide block(T s ) shown below: Torque of a motor The potential energy of the system is presented as: Three parts of energy dissipation are considered in the system:. The friction between the wheels and the ground: The driving wheel transmission mechanism friction: The moving slide block friction: Hence, the total energy dissipation is The dynamical equations of motion of the model is obtained as: where 3. MD-TWIP control system. The aforementioned dynamic model demonstrates the complexity and nonlinearity of the multi input and multi output system which brings great challenge in the following controller design. While, even though the state variables θ w , θ b and L are interactional and coupled, the slider movement L control can be regarded as position servo control. Thus, the dynamic parameters such as θ w , θ b become the disturbance of the position servo control which means the dynamic equation (12) describing L is unnecessary. Hence, the simplified dynamic model of the system is as follows: From the simplified dynamic model, we can see that the MD-TWIP system has two inputs (pitch angle and wheel velocity) and two outputs (driving voltage of motor and position of the slide block). As we assume that the MD-TWIP stands upright when moving forwards and backwards, the system can be simplified that the pitch angle determines driving voltage to keep the robot balance while the position of the slide block control the wheel velocity separately. Therefore, two PD-like fuzzy controllers are applied, one for the balance control (BFC) and the other one for the velocity control (VFC).
In the fuzzy control mechanism, as both two controllers are two inputs and one output system, considering x and y as the input variables and z as the output. Thus, the fuzzy rules can be written as: If x is A i and y is B i then z is C j ; where A i and B i (i = 1, 2, . . . , n) are the fuzzy sets of x and y on the input dominant, n is the total number of fuzzy sets. C j (i = 1, 2, . . . , m) is the fuzzy sets of output variable and m is the maximum of rule number. Therefore, the crisp output z can be achieved that: Triangular-shaped membership function Three basic consists of fuzzy model includes: fuzzification module, inference process and defuzzification module. The fuzzification module transforms the physical input to the normalized domain and then converts it into fuzzy set. In this paper Mamdani-like inference process is applied in BFC and VFC two controllers, therefore, min and max methods are selected for implication and aggregation. In the defuzzification process which is the reverse process of the fuzzifucation. It converts the set of the output value into the single point-wise value and maps the pointwise value onto the physical domain. In addition, centroid method is chosen in the process.
Then, the specific fuzzy model design for BFC and VFC are provided below. In the balance control schematic, the two inputs are the pitch angle θ and the pitch angle rate ω. The control target of BFC is to keep the MD-TWIP standing upright, in other words, when the pitch angle is positive or negative, drive the robot to move forwards or backwards to keep balance.  If θ is NB and ω is NB then u is PB In addition the VFC inputs wheel velocity V and wheel acceleration α generalize the input fuzzy sets C k (k = 1, 2, . . . , m) and D l (l = 1, 2, . . . , m), respectively, where m represents the dimension of the fuzzy sets. The output of the VFC is y relating to the fuzzy sets F k,l . Figure

Simulation on Matlab.
In this subsection, the Matlab Simulink simulation environment is employed on the basis of dynamic model obtained to evaluate the proposed control method. The system schematic is shown in Figure 8.
In the balance control, the controller designed bears a wide input range from -1.2 rad to +1.2 rad theoretically. Nevertheless, the pitch angle of the robot cannot reach over 0.5 rad (about 30) because of the limitation of the robot such as DC motor torque and the weight of the slide block. Therefore, simulation results with   0.1rad, 0.3rad, 0.5rad are illustrated in Figure 9, respectively. To demonstrate the better performance of BFC and VFC, the traditional PID controller is involved by comparison in Figure 10 and Figure 11. As we can see from Figure 10, the fuzzy controller can balance the robot body within 0.6s and without any overshoot or undershoot, while the PID controller exhibits a longer response time with some overshot. The Figure 11 shows that even though the PID controller has a fast respond as the VFC, the VFC has no overshoot and reaches the setting point which is 1m/s much faster within 2s.
Besides the aforementioned advantages of the fuzzy controller, it shows good robustness as a robust nonlinear control strategy which means it can accept a wide  Figure 11. Wheel velocity comparison between VFC and PID controller range of system parameters and deal with major disturbance. According to the MD-TWIP configuration, the center gravity height of the robot body has a great impact on the system performance. To investigate the effectiveness of system robustness, the following simulations are implemented by selecting the height of center gravity as system parameter variable and the outer torque as the disturbance. Figure 12 shows the pitch angle curve with different height of CoG under PID controller while Figure 13 shows the curve under BFC. It is clear that with the increase of CoG height, the robot body consumes a larger swing range under PID controller. Under the same condition, the curve almost coincides when applying BFC in Figure 13. The robot recover procedure is discrepant under the control of PID controller in Figure 12. The same situation occurs in the velocity control as provided in Figure 14 and Figure 15, respectively. Even though there is a slight change of settling time.
Besides the system parameter variable investigation above, the external disturbance provided in Figure 16 is also introduced to prove the robust of the BFC and VFC. The outer tourque which is considered as the external disturbance is loading on the motor torque directly and the amplitude of the random source is 4Nm. Under the effect of the same external disturbance, the pitch angle fluctuates in the rage of 0.15 rad under the fuzzy control in Figure 18. However, the fluctuation is more violent with PID controller that the maximum pitch angle wave rage is over 0.02 rad in Figure 19. Consequently, the proposed control scheme has a strong immunity to the external disturbance over PID control method. The external disturbance exists widely in real world such as the roughness of the ground and mechanism transmission friction. Under the same disturbance condition, the wave of wheel velocity is provided in Figure 19. Through the comparison of the three waves, the system with fuzzy controllers for both balance control and velocity control has a strong immunity to the torque disturbance, while the PID controllers for two control conditions show the weakest immunity.

Experiment results.
In this section, to validate the effectiveness of the proposed control strategy, experiments are implemented on the self-built physical prototype in this section. Figure 21 shows the pitch angle under BFC and PID controller in equilibrium control, similar to the simulation result, the system has no overshoot under BFC. In order to prove the system robustness, different height of CoG is introduced in simulation. With the same parameters, the experiment results are provided in Figure 22 and Figure 23, respectively. It is obvious that, the system involves fuzzy logic can accept a wide range of system parameters. In velocity control, the experiment results of robot velocity, pitch angle, slider displacement and robot displacement under VFC can be obtain in Figure 24. The robot reaches the target 1m/s in 6s and maintains it stably. During the whole acceleration procedure, the pitch angle of the robot body remains almost zero. It means the robot can keep its posture vertical dynamically by shifting the slider.  As mentioned above, robot can keep its posture when climbing on a slope which is shown in Figure 25.

5.
Conclusion. This paper has implemented the Mamdami-Like fuzzy logic on a Multi-DOF TWIP robot to improve motion control of the system. Two fuzzy controllers(BFC and VFC) are designed to fulfill the balance and velocity control commissions. In order to prove the strong robustness of the proposed control scheme, classic PID controllers are employed for comparisons. The simulation results validate the effectiveness of the proposed control scheme and the merit of robustness over classic PID strategy. Experiment results on the practical prototype shows the efficiency of control method for MD-TWIP system.  Figure 25. Experiment results of robot velocity, pitch angle, slider displacement and robot displacement under VFC for robot velocity control on a slope and the target velocity is 1m/s