Modeling, Simulation, and Optimal Control for Two-Wheeled Self-Balancing Robot

ABSTRACT


INTRODUCTION
The research on two-wheeled Self-balancing robot has gain momentum over the last decade due to its nonlinearity and unstable nature dynamic system. Motion of two-wheeled self-balancing robot is governed by under-actuated configuration, i.e., the number of control input is less than the number degrees of freedom to be stabilized which makes it difficult to apply the conventional robotic approach for controlling the system therefore, the two-wheeled self-balancing robot is a good platform for researchers to investigate the efficiency of various controllers in control system. The research on two-wheeled self-balancing robot is originally based on inverted pendulum and cart model. However, the two-wheeled self balancing robot system is no longer constrained to the guide rail but moves in its terrain while balancing the pendulum. Thus, it needs a good controller to control itself in upright position and desired heading angle without the needs from outside [1].
Various design of controllers and analysis technique had been proposed by numerous researchers to control the two-wheeled self-balancing robot such that the robot able to balance itself. In [2][3][4] a fuzzy logic based controller was designed and proven successful to control an inverted pendulum model. In [5], motion control of two-wheeled self-balancing robot was proposed using linear state-space model. In [6], dynamics was derived using a Newtonian approach and the control was design by the equations linearized around an operating point. In [7][8][9], and [10] a linear stabilizing Proportional Integral Derivative (PID) and Linear Quadratic Regulator (LQR) controller was derived by a planar model without considering robot's heading angle. The above control law was designed by a planar model without considering robot's heading angle therefore still cannot be implemented into a real system. In [11], a comparison between PID and LQR has been presented while the heading angle of the robot was also studied in the dynamic equation that was derived using Lagrangian method. This paper concerns the two-wheeled self-balancing robot system as the research object, which uses the Newtonian mechanics equation method to derive the dynamic equation. The linear state-space model that approximates the nonlinear system in the region of operation than obtained by assuming the system operates only around an operating point and the signals involved are small signal. Based from the mathematical model of the system, LQR Controller is designed to control the system tilt angle and heading angle so that the system can be controlled to move to a desired position. Performance of control strategy with respect to the output tilt angle ( ) and heading angle ( ) are examined and presented by using matlab / Simulink program.

RESEARCH METHOD 2.1. Mathematical Modeling of the Robot
The robot consists of 3 major parts, namely the wheels, platform, and the pendulum as the mass. The robot with its three degrees of freedom is able to linearly move which is characterized by position x, able to rotate around the z-axis (yaw) with associated angle ( ), and able to rotate around the y-axis (pitch) where the movement is described by angle ( ) as shown in Figure 1. The inputs of the system are the torques and which both are applied to the two wheels which located on the left side and right side of the robot. List of parameters for the two-wheeled self-balancing robot are shown in Table 1. These parameters are based on the project conducted by Li as stated by [12]. The objectives of the control schemes are to control the system's model shown in Figure 1 to move to a desired position while keeping the robot's tilt angle in the upright position. The controller must be able to stabilize the system with acceptable overshoot and settling time.  With assumption that there is no slip between the wheels and the ground, by applying Newton's law for the linear and rotational motion based [13] and [14], balancing forces and moment acting on the left wheel results in the following equations of motion: Similiarly, for the right wheel we have: Balancing forces acting on the pendulum on the x-axis direction and moments between the pendulum and the platform about the y-axis results in: Balancing the moments acting on the platform and pendulum about the z-axis gives: The relationship between the displacements of the wheel along the x-axis and the rotational angle of the wheel about the y-axis is: On the other hand, the relationship between the heading angle ( ) of the robot about the z-axis and the displacement of the wheel along the x-axis is: (11) By subtracting (1) and (2) from (3) and (4) respectively then substituting it to (11) result in: By adding (1) and (2) with (3) and (4) respectively then substituting it to (10), we have: Adding (16) and (17) we have: By substituting (18) to (5) and (6) we obtain: By substituting (7) to (8) result in: From the above derivation, we can obtain the dynamics equation of motion of the two-wheeled selfbalancing robot as (15) By defining the following 5-dimensional vector of state variable: Using (15), (21), and (22) the linearized two-wheeled self-balancing robot model can be expressed in the following state-space form: where: From the state-space model described above, there are a number of dynamic parameters in the system which will result in variation of the state matrices. In order to simplify the problem and give a clear physical meaning to the state matrix and input matrix to design a controller, the value of parameters of the system was shown in Table 2. Based on the value in Table 2, it is easy to have a linear state-space equation as:

LQR Controller Design and Simulation
LQR is a method in modern control theory that uses state-space approach to analyze such a system. Using state-space methods, it is relatively simple to work with a multi-input multi-output system. Assuming all state variables are available for feedback, the system described in previous section can be stabilized using full state feedback [15]. The schematic of this type of control system for a two-wheeled self balancing robot is shown in Figure 2.
Referring to [16] For the Linear Time Invariant (LTI) system, the LQR control theory involves choosing a control law: which stabilizes the origin while minimizing the quadratic cost function which can be presented: where is a symmetric positive definite or positive semi-definite matrix, R is a symmetric positive definite matrix and is unconstrained. The final control law can be derived as: In designing LQR controller, LQR function in matlab m-file can be used to determine the value of the vector K which determines the feedback control law. This is done by choosing two parameter values, matrix and . The objective of controlling the two-wheeled self-balancing robot system is to minimize robot's pitch angle ( ) while control the heading angle ( ) toward the reference angle, so designate and as two main control variables and and is given larger weights. After tuning the value of matrix and matrix using the trial and error method, we found the following state weighting matrix and input weighting matrix to be appropriate: Using (38) and (37), the control gains in (36) are found to be:

RESULTS AND ANALYSIS
In this section, the simulation results of the proposed controller, which is performed on the model of a two-wheeled self-balancing robot are presented. In order to design and stimulate the LQR Controller for system, matlab/simulink simulation tool is used. Performance characteristics of the controller are also discussed in details in this section.
Two wheeled self balancing robot system with LQR controller method produced two output responses, robot's pitch angle ( ) and the heading angle ( ). In this research, the initial value of pitch angle ( ) of the balancing robot was set to -1 rad to simulate the performance of the controller. It means that the initial condition of the robot is very unstable. On the other hand, the initial state of the heading angle ( ) was set to 0 rad and given a unit step as the reference signal. Figure 3 shows the response of two-wheeled self-balancing robot pitch angle ( ) in normal condition while Figure 4 shows the responses of two-wheeled self-balancing robot heading angle ( ) in normal condition. In the Figure, the response for the pitch angle ( ) and heading angle ( ) is represented by straight line or red color line and the reference for the system response is represented by dotted line or blue  figure, it can be seen that the LQR controller are capable to control the pitch angle and heading angle of the robot to the desired value. The settling time for the pitch angle to reach balance state in 2.23 sec while the steady-state error is 0.0086 rad. Meanwhile, the settling time for the heading angle to reach the steady-state value is 2.76 sec while the steady-state error is 0 rad. The control effort of the system's response is as shown in Figure 5. The torques applied to the left and the right wheel show a slight difference. This is due to the desired value of the system's heading angle = 1 rad and the system try to follow the reference signal.   Meanwhile, Figure 7. shows the response of two-wheeled self-balancing robot pitch angle ( ) with the pendulum's mass being increased to 110 Kg. From the figure it can be seen that the system's response became a little bit quicker while changes in the steady-state error is relatively small and can be ignored. When the pendulum's mass were being increased, there is a significance increase in system's maximum overshoot and steady-state error but overall, the performance of the controller was still acceptable because it can still maintain it's upright position. The performance of the controller in Figure 7 gives the conclusion that the performance of LQR controllers is limited to a certain range of pendulum's mass from the normal conditions. If the pendulum mass is increased to a certain point, it is possible that the controller will fail to control the system so that the robot will fall. Therefore, when designing LQR controllers it should also take into account the range of pendulum's mass in which the system will operate most. The disturbance rejection performance of the controller is shown in Figure 8. An impulse disturbance is applied at around 5 sec to the robot while it is stabilizing. It can be observed that the robot is able to reject this disturbance and regains its balance position in a short amount of time. A greater control effort is used by the robot to overcome the disturbance force as shown in Figure 9.   Table 3 shows the summary of the performance characteristics of the two-wheeled self-balancing robot in various conditions. Based on the data tabulated in Table 3, it can be seen that the responses of the self-balancing robot pitch angle and heading angle have acceptable overshoot and undershoot.
From this research it can be seen that LQR controllers can be implemented to control the twowheeled self-balancing robot system and provide quite good results. In this research, we also tested the controller on various state of the system which has not been shown so clearly in previous research. From the simulation, it can be seen that although the controller is capable of controlling the system despite being subjected to a change in mass or disturbance to the body pitch angle, there is a tolerable limit of mass change or pitch angle change. Therefore, when designing the controller, the values of the system parameters should be considered sothat the controller can work well under ideal or non ideal conditions.

CONCLUSION
In this paper, the design and implementation of LQR controller for stabilizing a two-wheeled selfbalancing robot is presented. The performance of LQR is simulated and analyzed with matlab/simulink program. Based on the results and the analysis, a conclusion has been made that the LQR controller are capable of controlling the two-wheeled self-balancing robot's pitch angle and heading angle and yields acceptable and good results without falling. In normal condition the system can be engaged to balance itself and give transient response characteristics settling time = 2.23 sec and steady-state error = 0.0086 rad for tilt angle response and settling time = 2.76 sec and steady-state error = 0 rad for heading angle response. When the pendulum's mass is being increased by 30 Kg, the system give transient response characteristics settling time = 7.04 sec and steady-state error = 0.0144 rad for tilt angle and when the pendulum's mass is being decreased by 30 Kg the system give transient response characteristics settling time = 0.52 sec and steadystate error = 0.0057 rad for tilt angle. However, more experiment needs to be performed to evaluate the robustness of the system. Nonlinear controller is fully recommended for balancing the two-wheeled selfbalancing robot as it will upgrade the robustness of the system.