Fuzzy fractional-order PID control for two-wheeled self-balancing robots on inclined road surface

Two-wheeled self-balancing robots (TWSBR) is a highly nonlinear and inherently unstable under-driving system. When controlling its movement on an inclined surface, it is more difficult than when it is on a level road. This paper proposes a fuzzy fractional-order PID (FFOPID) controller for the motion control of a TWSBR system in an inclined environment. The control goal of TWSBR is to realize the wheel position control and to stabilize the non-vertical direction of intermediate body (IB). Finally, we compare the control effect of the proposed FFOPID controller with that of the integer-order PID controller, the fuzzy PID (FPID) controller, and the fractional-order PID (FOPID) controller when TWSBR moving on the inclined plane. The simulation results show that the FFOPID controller has better control performance and anti-interference ability.


Introduction
TWSBR is usually composed of two wheels and the intermediate body (IB). Comparing with multiwheeled robot, TWSBR has some advantages, such as turning in place, small structure, flexible movement and so on Wang et al. (2018). TWSBR system is a typical nonlinear system, which has many factors, such as multi-variable, inherent instability, under-actuated and non-holonomic constraints. Therefore, TWSBR has become an ideal platform to verify advanced control algorithms. The goal of the controller is to realize the position control of the robot and the balance control of the IB.
In view of the stability control problem of TWSBR on the horizontal ground, the existing literature has proposed many types of controller design schemes. The traditional PID controller is proposed in Lee and Lee (2012) and Juang and Lum (2013). Linear quadratic regulator (LQR) (Prasad et al., 2012) controller and pole assignment method (Siradjuddin et al., 2017) can control the position of robot or the vertical stability of IB without steady-state error. Due to the poor control effect of PID controller on the system with high order and extra noise, in these literatures (Bingul & Karahan, 2011;Kumar & Dinesh, 2014;Paliwal, 2017;Singh, 2015), based on the integer-order PID controller, the FOPID controller is designed for TWSBR system. Comparing with the former, the latter adds two adjustable parameters, which expand the parameter tuning range and improves the control ability. In view of the good nonlinear approximation ability of fuzzy controller, it is often used alone or combined with other controllers to form a composite controller, and then applied to TWSBR system to improve the control ability of the controller, just to take a few examples (Jian et al., 2018;Paliwal et al., 2016;Qiu, 2015;Shi et al., 2020;Wu & Zhang, 2011;Wu et al., 2012).
The above methods are only for balancing robots moving on horizontal plane. However, in reality, TWSBR's motion environment is more on uneven road, including sloping road, undulating road and irregular road. The research in this paper is to control the position and balance of the robot in a sloping road environment. When TWSBR is stable on the inclined road, there is a fixed angle between the IB and the vertical axis, which is related to the ground inclination angle, and the wheel torque is not equal to zero (Kausar et al., 2012). In Liang et al. (2017) and Peng et al. (2012), they established the dynamic model of the robot on the inclined road with Lagrange method and designed the linear controller with LQR method after getting the equilibrium state, while the overshoot is very large at the beginning. In Huang et al. (2010), a sliding mode controller is designed for the speed tracking problem of TWSBR system, which basically realizes the speed tracking control under the condition of unknown ground inclination. A new Takagi-Sugeno fuzzy logic controller is designed in Xu et al. (2013), which implements TWSBR position control and verifies the effectiveness of the controller through experiments. It is worth noting that the control effect of type-1 fuzzy controller is not particularly prominent when the system is uncertainty. Therefore, on the basis of the previous robot model, the authors of Dian et al. (2019) are designed and applied a generalized type-2 T-S fuzzy balance controller to achieve the balance control of TWSBR and designed a generalized type-2 Mamdani fuzzy position controller to make TWSBR reach the set position. The simulation results show that the controller has good control effect.
Due to the new λ and µ two adjustable parameters, FOPID controller increases the parameter tuning range, and thus the control performance is better than the integer-order PID controller (Paliwal, 2017). According to the investigation of the existing literature, FFOPID controller is superior to the traditional controller in the control performance and robustness in the field of power control and manipulator control (Barbosa & Jesus, 2013a;George et al., 2021;Sharma et al., 2018). According to the literature survey, FFOPID controller has not been used in position and balance control of TWSBR. In this paper, combining the advantages of Fuzzy Logic Controller (FLC) and FOPID controller, a FFOPID controller suitable for TWSBR control of slope roads is designed. By adding new parameters in the fractional-order controller and increasing the parameter tuning range, FLC can adjust the fractional-order parameters online and improve the control quality and anti-interference ability. The contributions of the current work are described below: • Combining the advantages of FOPID and FLC, the FFOPID controller is designed to achieve dual control of the position and balance of TWSBR when it moves on a sloping road. • The FLC in the FPID and FFOPID controllers is one of the difficult points in the design. Based on the control experience of the self-balancing robot, the fuzzy rule library and the membership function are redesigned. • The PID, FPID, FOPID and FFOPID controllers are studied, respectively, and these controllers are used to control the position and stability of the TWSBR moving on the slope. • In the simulation experiment, two slope environments with different inclination and two disturbance conditions are designed to compare the performance of the four controllers. The results show that the FFOPID controller has good control effect and anti-disturbance ability.
The other parts of this paper are as follows. In Section 2, the dynamic model of TWSBR on the inclined plane is introduced. Section 3 mainly introduces the design process of FFOPID controller, briefly explain the other three controllers. In Section 4, the simulation tests on the controller are performed to verify the effectiveness of the FFOPID controller. The conclusions and future work are drawn in Section 5. Figure 1 is a sectional view of the TWSBR dynamic model on an inclined road surface (Xu et al., 2014). In this paper, the wheel is always in contact with the inclined plane, and there is no sliding phenomenon. The displacement and velocity of the robot are defined as x andẋ. θ is the inclination angle of the IB, with the vertical direction as the zero point, and the angle is positive when rotating clockwise.θ is the angular velocity of rotation. ϕ indicates the angle between the inclined road surface and the horizontal plane. u is the output torque of the drive motor and the input of TWSBR system. When u is positive, it means that the motor rotates clockwise; when the number is negative, it means that the motor rotates counterclockwise. f is the friction between the wheel and the ground. u f refers to the rolling resistance between the wheel and the road surface. F is the interaction force between the IB and the wheel in the inclined plane component. The direction indicated by a single arrow indicates the direction of motion when the relevant parameter is positive. In this paper, the system is regarded as an ideal state temporarily, that is, u f and f are both zero. Due to the small mass and volume of the robot, there is no requirement for the characteristics of the inclined road surface in the simulation experiment. The parameters of the robot are shown in Table 1.

TWSBR model
Lagrange method is used to establish the dynamic model of the two-wheeled self-balancing robot. The following formula is derived, the Lagrange function scalar is defined as the difference between the kinetic energy and potential energy of the system (Liang et al., 2017):  Distance between centre of IB and chassis 0.13 m r The radius of the road 0.08 m g Acceleration of gravity 9.81 m/s 2 where T, V are the total kinetic and potential energy of the TWSBR, respectively. T consists of four parts: the wheel moving kinetic energy, the wheel rotating kinetic energy, the kinetic energy of movement of IB and the kinetic energy of rotation of IB; V contains the potential energy of body and wheel. The kinetic energy of the IB is expressed as follows: The rotational kinetic energy of the IB is 1 2 I pθ 2 , the kinetic energy of the wheel is 1 2 m w (ẋ 2 L +ẋ 2 R ), the rotational kinetic energy of the wheel are as follows (ẋ L ,ẋ R is the speed of the left and right wheels) : The total potential energy V: Substitute Equations (2)-(4) into Equation (1) yields: According to the force relationship shown in Figure 1, the differential equations for wheel displacement and vehicle body inclination can be obtained by taking the derivative of the Lagrangian equation, as shown below: Substituting Equations (5) into (6) to obtain the secondorder nonlinear model of TWSBR on the inclined plane: Define the state variable vector: According to Equations (7)-(9), the state space expression of TWSBR is derived: where a = m p + m w + I w r 2 , b = m p l and c = m p l 2 + I p .

Systematic analysis in steady state
When TWSBR is stable on an inclined road surface, as shown in Figure 2,ẍ = 0,θ = 0 andθ = 0, substituting in the formula (7) (8), the following equation are obtained: From the above equation, it can be concluded that: where θ b is the inclination angle of the robot when it is stable on the inclined road, the inclination angle is only determined by the ground tilt angle, and the other parameters are the robot's own parameters. Equation (11) is the torque provided by the wheels when the robot is stabilized to counteract the effect of gravity.

Controller design
This section will introduce the design and implementation of the FFOPID controller in detail. Briefly introduce the design of FOPID, PID and FPID controller.

FOPID controller
FOPID was first proposed by professor Podlubny (1999). Compared with the integer-order PID controller, it adds two variable parameters, λ-order integral and µ-order derivative. The general form is denoted as PI λ D μ , and the control action can be described by Equation (14).
is used to represent the component number order operator, and a simple G-L definition is used to solve the fractional-order operator (Barbosa & Jesus, 2013b): The output equation of discrete FOPID controller is as follows: where is binomial coefficient, the simplified expression is as follows: The recurrence formula is as follows: when the step size T is very small, the approximate value of fractional calculus can be obtained directly according to the recursive formula.

PID controller
The standard PID control equations and traditional functions are expressed as follows: Comparing the transfer functions of the two controllers, it can be seen that the four common types of PID controllers (P, PI, PD, PID) are all special cases of FOPID controllers. For example, when λ = μ = 1, the FOPID controller degenerates into a regular integer-order PID controller.

FPID controller
The principle of converting FFOPID to FPID is the same as that of degenerating FOPID to PID. As shown in Figure 3, if the fractional integral operator λ = 1 and the differential operator μ = 1 in the FFOPID controller, then the FPID controller is obtained. Figure 3 is the structure block diagram of the FFOPID controller. In this paper, the integrator/differentiator is set to a fractional-order form based on the relatively simple fuzzy PD and fuzzy PI parallel FPID controller structure to obtain the FFOPID controller. Taking the error and fractional-order error as the input of the FLC. G E and G EC are the input scaling factor, G PD and G PI are the output scaling factor, λ and µ are fractional orders. They are all optimization variables in particle swarm optimization (PSO) algorithm. According to the schematic diagram, the controller output u can be expressed by Equation (21):

Design of FFOPID controller
Due to the characteristics of the fuzzy controller, it can be concluded that the control law U FLC of the fuzzy logic controller is a nonlinear function of the error and the fractional derivative of the error. The input and output of the FLC are usually a nonlinear complex mapping relationship, where the function f represents a nonlinear function. Use the linear approximation method  (Jantzen, 1998) to process f into a linear function. Then the control rate u is expressed as: Compared with (14), the scaling factor in FFOPID controller is defined as follows: G E G PD is the proportional term, G EC G PD is a fractional differential term, G E G PI is a fractional integral term, G EC G PI is a fractional-order action term. Whether it is a fractional integral term or a fractional differential term depends on the size of λ and µ.
There is an information fusion link in the structure diagram. Since TWSBR system has four variables, in order to prevent the explosion of designing multiple FLC and fuzzy rules, the information fusion method is used to fuse the four state variables into two variables, which reduces the difficulty of controller design. The specific process of information fusion is as follows: • A state feedback gain matrix K 1×4 is constructed. In the previous section, the state space model of the selfbalancing robot nonlinear system has been derived, and the state feedback matrix K 1×4 is designed by using the linear quadratic optimal control theory. • The fusion matrix K 2×4 is constructed by state feedback gain matrix. In this paper, the fusion matrix is designed as follows: • Error e and error change rate ec are obtained by parameter fusion.
According to the structure of the controller, only the error e is used in the input. After fusion, the input of the controller still contains all the information of position and tilt angle, which reduces the variable dimension and the difficulty of controller design.
The error (e) and fractional derivative of error ( d μ dt μ e) are selected as the inputs of the controller. Figure 4 shows the membership function of input, which is divided into three linguistic variables, namely, negative small (NS), zero (ZO) and positive small (PS). Fuzzy logic rules are usually set according to expert knowledge and practical experience. In this paper, the logic rules are summarized through practical experience. For example, at the beginning, there is a big difference between the set value and the target value, which needs to produce a large control output. At this time, K P and K I choose the larger value, K D select the smaller value. When moving to the target value, in order to reduce the steady-state error, K P and K I choose the smaller value, K D select the larger value. Therefore, the fuzzy rule table is shown in Table 2.
The next section applies the FFOPID controller into the TWSBR system to realizes the position and balance control and gives the corresponding numerical simulation.

Simulation results and analysis
The proposed FFOPID controller is simulated on the MAT-LAB platform and applied to the position and stability control of the TWSBR. The control effect and robustness are compared with those of FOPID, PID and FPID controllers. In order to quantitatively compare the performance index parameters of the four controllers, three evaluation functions ISE, IAE and ITAE are used in this section to comprehensively evaluate the control performance of the controller. Definition of evaluation function index (Lin et al., 2010): The weighting matrix Q, R and state feedback matrix K (Xu et al., 2013) and fusion matrix K 2×4 are used in the simulation experiment are as follows:  Table 3.

Position and balance control
In the first case, we first set the slope angle ϕ = 5 • , according to Equation (11) and (13), when the robot tends to be stable, θ b = 0.1058 rad, control rate u = 0.2156 N.m.
The simulation results are shown in Figure 5; Figure 5(a,b) show the changes of x and θ of the system with the participation of four controllers, and Figure 5(c) shows the output of the FFOPID controller. In Figure 5(a), the reason why the robot moves in the opposite direction at the beginning is that the torque is too large at the beginning. In order to prevent the IB from falling, the robot moves in the opposite direction to the target until the IB tilts to the target again. The four controllers can realize the position and balance control of TWSBR, but the stabilization time is different. The tilt angle of θ approaches 0.1058 rad, and the control rate is close to 0.2156 N.m, which is consistent with the theoretical calculation. According to Figure 5 and Table 4, the performance of the PID controller is the worst, which is characterized by the largest oscillation during the motion process and a longer stabilization time; secondly, the system reduces the oscillation under the parameters of the FPID controller and stabilizes earlier time; The FOPID controller has good performance, but the overshoot is larger in position control; Compared with the FOPID controller, FFOPID has the same settling time, but the oscillation is smaller and the performance is the best.
In the second case, we change the tilt angle and set ϕ = 10 • . When TWSBR stabilizes, at this time θ b = 0.2120 rad, control rate u = 0.4156 N.m. It can be seen from the Figure 6 that when TWSBR stabilizes on the slope, the inclination angle θ tends to 0.2120 rad, and the control rate tends to 0.4156 N.m, which is consistent with the theoretical calculation.    Figure 6(a,b) shows the changes of x and θ of the system with the participation of four controllers, and Figure  6(c) shows the output of the FFOPID controller. In Figure  6(a), the movement in the opposite direction at the beginning is caused by the excessive torque at the beginning. Compared with the former case, the angle of the inclined road is larger, and the movement in the opposite direction is more obvious. Combined with Figure 6 and Table 5, the system has a large oscillation phenomenon in the whole dynamic motion process with the participation of the other three controllers. With the participation of the FFOPID controller, TWSBR is superior to the other three controllers in terms of position movement and time to stabilize.

Anti-disturbance performance
To verify the anti-random disturbance performance of the proposed controller, a random disturbance of 0.05 * randn is added to the TWSBR system to simulate the internal disturbance caused by inaccurate derivation of the system dynamic model. Figure 7 shows the performance of the four controllers in position and balance control in the case of two inclined planes. Since the random disturbance is added to the state space model of the system, the stability value changes with the disturbance. The system manifests that the robot oscillates in a certain range above and below the theoretical position and the balance tilt angle to maintain dynamic stability. In the case of disturbance, the control performance of the four controllers for TWSBR system is compared.
In the experiment, in order to avoid the incompatibility of performance between controllers caused by random numbers, after adding random interference, various controllers are tested for 10 times, and the best result is the final result. Combined with Figure 7 and the Tables 6 and 7, since the input of the PID controller is directly an error, it is most affected by the disturbance, and the system shows a great shock. Because of the addition of two adjustable parameters, the FOPID controller is better than the traditional PID controller in terms of disturbance performance. The FPID controller uses manual control experience to fuzzify the error within a certain range, so as to effectively adjust the system output. The result also proves that its controller effect is better than the previous two controllers. The FFOPID controller mentioned in this article combines the advantages of the FPID and FOPID controllers. It is mainly manifested in the smallest dynamic swing amplitude of the robot, especially in the case of a large tilt angle, the swing amplitude is significantly smaller than that of the other three controllers.  The system also shows that the controller has good antirandom disturbance ability. Next, we consider another kind of interference, adding a signal of 0.5 rad to the state variable z 3 in the ninth second to simulate when the robot is in a stable state, its tilt   angle state quantity z 3 suddenly receives an amplitude magnitude pulse interference of 0.5 rad. Figure 8 shows the control performance of the four controllers under disturbance interference when ϕ = 5 • and ϕ = 10 • . Tables 8  and 9 shows the performance index results of the four controllers under two disturbance conditions. When the system is affected by instantaneous disturbance, the performance of the traditional PID controller is obviously insufficient. It can be seen that the position changes greatly, and the time to stabilize is the longest. With the participation of FPID and FOPID controllers, the system will produce a larger oscillation process when it is disturbed, but the overall performance of the controller is better than that of the PID controller. Combined with the controller performance indicators, with the participation of the FFOPID controller, the robot displacement change is small, the dynamic process vibration is small, and the system performs better in the case of instantaneous disturbances, indicating that the FFOPID controller participates in the system's anti-interference ability better.

Conclusion
Based on the derivation of TWSBR dynamic equation on inclined surface, the fusion function is used to reduce the input parameters of the system and prevent the explosion of fuzzy rules. The FFOPID controller is designed to achieve the position and balance control of TWSBR when it moves on inclined pavement. The simulation results show that the TWSBR system with the participation of FFOPID controller has smaller overshoot, shorter motion time and better anti-interference performance. The future work is to apply the controller proposed in this article to the Arduino self-balancing robot to verify the actual control effect of the controller. Secondly, for more complex and more realistic terrain conditions, the fuzzy rules, membership functions and controller parameters in the FFOPID controller are designed to realize the position and balance control of the TWSBR system in a complex road environment.

Disclosure statement
No potential conflict of interest was reported by the author(s).

Data availability statement
The datasets generated during and/or analysed during the current study are available from the corresponding author on reasonable request.