International Journal of Electrical and Computer Engineering (IJECE) Vol. No. August 2017, pp. ISSN: 2088-8708. DOI: 10. 11591/ijece. Modeling. Simulation, and Optimal Control for Two-Wheeled Self-Balancing Robot Modestus Oliver Asali. Ferry Hadary. Bomo Wibowo Sanjaya Department of Electrical Engineering. Tanjungpura University. Indonesia Article Info ABSTRACT Article history: Two-wheeled self-balancing robot is a popular model in control system experiments which is more widely known as inverted pendulum and cart This is a multi-input and multi-output system which is theoretical and has been applied in many systems in daily use. Anyway, most research just focus on balancing this model through try-on experiments or by using simple form of mathematical model. There were still few researches that focus on complete mathematic modeling and designing a mathematical model based controller for such system. This paper analyzed mathematical model of the Then, the authors successfully applied a Linear Quadratic Regulator (LQR) controller for this system. This controller was tested with different case of system condition. Controlling results was proved to work well and tested on different case of system condition through simulation on matlab/Simulink program. Received Feb 12, 2017 Revised May 20, 2017 Accepted Jun 26, 2017 Keyword: Inverted pendulum Matlab/simulink Modeling and simulation Optimal control Self-balancing robot Copyright A 2017 Institute of Advanced Engineering and Science. All rights reserved. Corresponding Author: Modestus Oliver Asali. Department of Electrical Engineering. Tanjungpura University. Jalan Jendral Ahmad Yani. Pontianak 78124. Indonesia. Email: modestus_oliver@yahoo. 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. , 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 . 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 . a fuzzy logic based controller was designed and proven successful to control an inverted pendulum model. In . , motion control of two-wheeled self-balancing robot was proposed using linear state-space model. In . , dynamics was derived using a Newtonian approach and the control was design by the equations linearized around an operating point. In . , and . a linear stabilizing Proportional Integral Derivative (PID) and Linear Quadratic Regulator (LQR) controller was derived by a planar model without considering robotAos heading The above control law was designed by a planar model without considering robotAos heading angle therefore still cannot be implemented into a real system. In . , a comparison between PID and LQR has Journal homepage: http://iaesjournal. com/online/index. php/IJECE IJECE ISSN: 2088-8708 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 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 . with associated angle ( ), and able to rotate around the y-axis . 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 . The objectives of the control schemes are to control the systemAos model shown in Figure 1 to move to a desired position while keeping the robotAos tilt angle in the upright The controller must be able to stabilize the system with acceptable overshoot and settling time. Figure 1. A model of two-wheeled self-balancing robot Table 1. List of parameters of two-wheeled self-balancing robot Symbol Parameter Unit Fl . F r Hl . Hr Interacting forces between the left and right wheels and the platform Friction forces acting on the left and right wheels Torques provided by wheel actuators acting on the left and right wheels Rotational angles of the left and the right wheels Displacements of the left and right wheels along the x-axis Tilt angle of the robot Heading angle of the robot with respect to the z-axis Mass of the each wheel Moment of inertia of the wheel about the y-axis Radius of the wheel Mass of the pendulum Gravity acceleration Distance from the platform to the center of mass of the pendulum along the z-axis Distance between the left and right wheels along the y-axis Mass of the platform Moment of inertia of the platform about the y-axis Moment of inertia of the platform and pendulum about the z-axis Interacting forces between the pendulum and the platform on the x-axis Interacting moment between the pendulum and the platform about the y-axis The forward velocity of the robot The rotation velocity of the robot N/m Kg. m/s2 Kg. Kg. N/m rad / s xl, xr Modeling. Simulation, and Optimal Control for Two-Wheeled Self-Balancing A. (Modestus Oliver Asal. A ISSN: 2088-8708 With assumption that there is no slip between the wheels and the ground, by applying NewtonAos law for the linear and rotational motion based . , 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: By subtracting . respectively then substituting it to . result in: ( O O ) ( O O ) By adding . respectively then substituting it to . , we have: IJECE Vol. No. August 2017 : 2008 Ae 2017 IJECE ISSN: 2088-8708 Adding . we have: By substituting . we obtain: By substituting . result in: ) O From the above derivation, we can obtain the dynamics equation of motion of the two-wheeled selfbalancing robot as . , . , and . Assuming that the robot only around a small operating point, the dynamic model of the robot is then linearized around the point N Equation . , and . then became: ) O )) O By defining the following 5-dimensional vector of state variable: [ N] [ ] Using . , . , and . the linearized two-wheeled self-balancing robot model can be expressed in the following state-space form: [ O] ] [ N] )) ( )) ( )) ( ))) )) ( ))) )) ( ))) Modeling. Simulation, and Optimal Control for Two-Wheeled Self-Balancing A. (Modestus Oliver Asal. A ISSN: 2088-8708 )) ( ))) 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. Table 2. Specifications of the two-wheeled self-balancing robot Symbol Value Unit Kg. m/s2 Kg. Kg. Based on the value in Table 2, it is easy to have a linear state-space equation as: ] [ N] [ O] 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 . The schematic of this type of control system for a two-wheeled self balancing robot is shown in Figure 2. Referring to . 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: O ( () ( )) 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: ( ) IJECE Vol. No. August 2017 : 2008 Ae 2017 IJECE ISSN: 2088-8708 left torque x4 reference Error Error x' = Ax Bu y = Cx Du right torque Two-wheeled self balancing robot Figure 2. The LQR control scheme for two-wheeled self-balancing robot where a symmetric positive definite matrix is a solution to the following equation: 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 robotAos pitch angle ( ) while control the heading angle ( ) toward the reference angle, so designate as two main control variables 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 . , the control gains in . 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, robotAos pitch angle ( ) and the heading angle ( ). In this research, the initial value of pitch angle ( ) of the balancing robot was set to Ae 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 Modeling. Simulation, and Optimal Control for Two-Wheeled Self-Balancing A. (Modestus Oliver Asal. A ISSN: 2088-8708 color line. From the 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 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 systemAos 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 systemAos heading angle = 1 rad and the system try to follow the reference signal. Two-wheeled self-balancing Two-wheeled self-balancing Two-wheeled self-balancing robot robot angle angle Two-wheeled self-balancing pitch pitch heading angle response pitch angle . Heading angle. pitch angle . Heading agle. Figure 3. Two-wheeled self-balancing robot pitch angle response in normal condition time . Figure 4. Two-wheeled self-balancing robot heading angle response in normal condition Figure 6 shows the response of two-wheeled self-balancing robot pitch angle ( ) with the pendulumAos mass being decreased to 40 Kg. From the figure it can be seen that the LQR controller are capable to control and balance the pitch angle despite the change in the pendulumAos mass. It show that the result has got similar pattern and not much different from the normal condition system. Almost no significant differences were apparent from controllerAos performance in normal condition with decreased mass condition as shown by Figures 3 and Figure 6. Control effort of two-wheeled self-balancing robot Two-wheeled self-balancing robot pitch angle response Two pitch angle response Left Torque . Right Torque . H e a d i n g a n g l e ( r a . pitch angle . Torque (N/. Figure 5. Control effort of two-wheeled selfbalancing robot in normal condition time . Figure 6. Two-wheeled self-balancing robot pitch angle response with decreased mass of the pendulum = 40 Kg Meanwhile. Figure 7. shows the response of two-wheeled self-balancing robot pitch angle ( ) with the pendulumAos mass being increased to 110 Kg. From the figure it can be seen that the systemAos response became a little bit quicker while changes in the steady-state error is relatively small and can be ignored. When the pendulumAos mass were being increased, there is a significance increase in systemAos maximum IJECE Vol. No. August 2017 : 2008 Ae 2017 IJECE ISSN: 2088-8708 overshoot and steady-state error but overall, the performance of the controller was still acceptable because it can still maintain itAos 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 pendulumAos mass from the normal 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 pendulumAos 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. Two-wheeled self-balancing robot pitch angle response Two-wheeled self-balancing robot heading angle response Two-wheeled self-balancing robot pitch angle response pitch angle response heading angle response pitch angle response H e a d i n g a n g l e ( r a . pitch angle . H e a d i n g a n g l e ( r a . pitch angle . Figure 7. Two-wheeled self-balancing robot pitch angle response with increased mass of the pendulum = 110 Kg time . Figure 8. Two-wheeled self-balancing robot pitch angle response with disturbance applied to the body pitch angle Control effort of two-wheeled self-balancing robot Left Torque . Right Torque . Torque (N/. Figure 9. Control effort of two-wheeled self-balancing robot during disturbance rejection 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 Modeling. Simulation, and Optimal Control for Two-Wheeled Self-Balancing A. (Modestus Oliver Asal. A ISSN: 2088-8708 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. Table 3. Specifications of the two-wheeled self-balancing robot SystemAos condition Pitch angle ( ) Heading angle ( ) . Normal condition Increased pendulumAos Decreased pendulumAos 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 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 robotAos 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 pendulumAos 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 pendulumAos 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. REFERENCES