Balancing a Segway robot using LQR controller based on genetic and bacteria foraging optimization algorithms

ABSTRACT


INTRODUCTION
The Segway robot is an electric, two-wheeled self-balancing human transporter with a computercontrolled gyroscopic stabilization and control system.This new vehicle is a complex and hybrid machine that requires engineering competence in many fields; vehicle dynamics, automatic control, battery technology, power electronics, software engineering, microcomputer programming, network and communication engineering.The two-wheeled robot was revealed by Dean Kamen in 2001 to replace the car or buggies which were more polluting [1].The personal transporter has the wide applications in the military and civilian field due to its simple construction, high energy using rate, stable movement and ability to adapt with surrounding environmental conditions.However, the single-seat robot faces many challenges related to nonlinearity, high order variables, strong coupling and inherent unstable dynamics of the system.Therefore, balance problem and development of this type of vehicle is a hot research topic of interest to many robotics laboratories around the world.Segway is a known two-wheeled single-seat mobile robot which has been utilized as a commercial personal transportation vehicle.In the Segway robotic system a collection of tiltsensors and five gyroscopes are TELKOMNIKA Telecommun Comput El Control  Balancing a Segway robot using LQR controller based on genetic and… (Ibrahim K. Mohammed) 2643 used to remain the human user in the straight position [2].Moreover, [3] use two teams, human transporter platform (HT) and robot mobility platform (RMP), to created a new mobile robot, called Segway Soccer.The walking robotic system is used to examine the coordination of dynamically formed, mixed personal-mobile robot teams within the domain of a team function that requires making a decision and response.
An initial model of a digitally controlled mobile robot has been constructed in [4].In the presented prototype, which is based on the inverted pendulum, the human rider is simulated by attaching weights to the scheme.A linear state feedback controller is used to stabilize the proposed personal mobile robot based on sensory information from motor encoders and a gyroscope.A new two-wheeled inverted pendulum mobile robot is presented by [5].A control system based on pole placement technique is designed to stabilize the rider in an upright position.It is worth considering that, there are another models for two-wheeled self-balancing human vehicles invented by robotic engineers.In 2003, David P. A. built the Nbot balancing robot used a human transporter provided by a linear controller used to stabilize the system using information from motor encoder and the inertial sensor.Furthermore, [6] has successfully fabricated a new model of robot called Legway based on Mindstorms robotics kit.A linear controller is used to stabilize the electric vehicle based information of the tilt angle obtained from two electro-optical proximity detector (EOPD) sensors.However, fine tuning for the controller parameters is required to achieve a peter performance.Hussien et al. [7] introduced another model for two-wheeled mobile robot.Nonlinear control system based on model reference adaptive control (MRAC) using Lpayunovs stability theorem is employed to balance the proposed single-seat electric vehicle.Simulation and experimental results are presented to validate tracking performance of the proposed robot actuation system.However, the performance of the robot control system is based on the controller coefficients, which are chosen arbitrary, therefore, for peter performance an optimization algorithm should be used.All the proposed controllers used to stabilize the mobile robots are not optimized using optimization methods, the gain parameters are obtained using trial and error procedure.In order to achieve a stable actuation performance for mobile robot system a proper controller technique based on tuning algorithm should be used.The linear quadratic regulator (LQR) is among most popular linear state feedback controllers implemented in field of industrial applications.The implementation of the LQRcontroller can be noticed by research works published by [4,[8][9][10][11].
In this study, the LQR controller is adopted to implement the control system used to balance the two-round human vehicle as it seeks basically a trade off between the best control performance and minimum power input [12,13].However, using this controller approach includes many problems and disadvantages such as relying on the designer experience and skill and the trial and error procedure in the determine of the controller weighting matrices  and .Therefore, there is a enormous concern by robotic engineers in computer-aided optimization algorithms that can be considered to obtain the global optimum solution of  and  matrices..There are many optimization approaches that have been adopted by control engineers to obtain optimum values for elements of LQR matrices, such as a particle swarm inspired evolutionary algorithm (PS-EA), particle swarm optimization (PSO), genetic algorithm (GA) [14], combination of simulated annealing (SA) and GA [15], differential evaluation (DE) [16] and ant colony optimization (ACO) [17].These intelligent optimization tools make the LQR controller system very robust, and insensitive to noisy and/or missing data.Bacteria foraging optimization algorithm (BFOA) is a new tuning algorithm that can be applied to optimize the cost function of several problems in different application fields.The BFOA is a combinatorial optimization algorithm which applied to achieve the best global solution for the proposed LQR controller.It is worth considering that there is a significant improvement inthe control response of the LQR controller is achieved by using these tuning algorithms, however, the research work is still open to explore for further controller improvements and developments.In this research, two tuning algorithms, GA and BFOA are utilized to improve the behavior of the LQR controller.
The remainder of the paper is organised as follows: section 2 presents modelling and dynamics of the proposed two-wheeled self-balancing human robot.In section 3, the technique of the controller system is introduced.Section 4, presents optimization methods of LQR controller.Section 5 and section 6 introduce controller design and simulation results of GA-LQR and section 7 introduce BFOA-LQR controllers for the robot system respectively.Conclusions and future work are presented in section 8.

SYSTEM MODELING
The performance of a walking robot depends on the reliability of the system modeling and robustness of the controller design.The structure of the two-wheeled Segway personal robot composes mainly of an electrical sub system and mechanical subsystem.Figure 1 demonstrates graphic model of the Segway robot.In this section, the motion equation of the inverted pendulum is derived and the dynamic model of the motors is formulated.The motor model is then utilized in formulation the dynamic model of the personal robot scheme to give a functional relationship between applied voltage to the DC motors and adjusting magnetic torque required to stabilize the human mobile robot.

Electrical subsystem modeling
The main part of the electric sub system is the DC motors, which are used to rotate the left and right wheel of the robot.The electric circuit of the DC motor is shown in Figure 2. Applying voltage   () to the motor terminals generates a current () () in the motor armature.The excited motor produces a torque () governed by the following relationship.
where   is torque constant (/).The back electromotive (emf) voltage   () produced in the motor coil can be approximated as a linear function of motor angular velocity  ̇ (/), as follows: where   is torque constant (/).Applying Kirchoff's voltage law to the motor circuit shown in Figure 2 yields the following expression: It is worth considering that the dynamic of the mechanical system is considered slow compared to that of electrical system, therefore, the current transients of the system can be omitted.Hence, solving (3) for the current yields: based on ( 2), ( 4) can be written as follows: substituting ( 5) in ( 1) gives an expression for the torque produced by DC motor: Figure 1.Model of the two-wheeled robot [18] Figure 2. Electric model circuit of DC motor

Mechanical subsystem modeling
It consists of chassis, which behaviors as inverted pendulum, and the left and right wheels.In this study, the parameter of mass, radius and moment of inertia of the two wheels are assumed the same.Based on this assumption the dynamic modeling of the right wheel is the same as that of the left wheel.In this research, formulation of the right wheel model is considered in detail.It is worth considering that the modeling strategy of the mechanical robot subsystem is based on an idea that the dynamics of TELKOMNIKA Telecommun Comput El Control  Balancing a Segway robot using LQR controller based on genetic and… (Ibrahim K. Mohammed) 2645 the inverted pendulum and wheels are modeled separately at the beginning, and then equations of motion which completely describe the dynamic behavior of the system are derived [19].

Wheel model
Figure 3 presents the free body diagram of the left and right wheels for the mobile Segway transport system.Using second Newton's law of motion, the sum of the external forces () exerted on the wheel, which governs its translation motion in the horizontal x-direction is given by [20].
Figure 3. Free body diagram of the robot wheels where   () is the wheel mass of the robot, a is the gravity acceleration (/ 2 ) and  is the friction force between ground and wheels().While the rotational motion   of the wheel is given by: go where   ( 2 ) and  ̈ (/ 2 ) are moment of inertia and acceleration of the wheels respectively, and r is the radius of wheel ().Based on (6), the above equation becomes: where  ̇is the angular velocity of wheel (/).Substituting ( 12) into ( 8) yields ( 13) and ( 14) for the left and right wheels respectively.
Because the center of the robot wheel is acted by the linear motion, the angular rotation of the wheel can be transformed into linear motion by the following simple transformation,  ̈ = ̈→  ̈= / ,  ̇ = ̇→  ̇= /.By the linear transformation, ( 13) and ( 14) become as follows: Adding ( 15) and ( 16) together yields the following expression,

Chassis model
The chassis of the mobile robot can be modeled as an inverted pendulum, Figure 4 presents the free body diagram of the chassis.Again, based on Newton's law of motion, the sum of forces acting on the chassis in the horizontal x-direction is given by [20]: where   is the wheel mass of the robot () and   is the rotational angle of the chassis ().The above equation is rearranged as follows: The sum of perpendicular forces acting on the pendulum is: where   and   are the reaction forces between left and right wheel and chassis () respectively and  ̈ is chassis angular acceleration(/ 2 ), sum of moments around the center of pendulum mass is given by: where   and   are the motor torque applied to left and right wheels respectively () the motor torque exerted on the pendulum applied as defined in (6) and after linear transformation, substituting ( 25) into (24) yields, substitute (26) in (22) after multiply ( 22) by(−) yields: Sum of moments around the center of pendulum mass is given: to eliminate the term (  +   ) from the motor dynamic (20) is substituted in (17).It is worth considering that the system modeling is based on the supposition that both wheels of the walking robot are assumed in state of contact with the ground and without sliding.Cornering forces produced by vehicle wheels during cornering are also considered negligible [19].

CONTROLLER TECHNIQUE
In this research, LQR technique is utilized to implement the proposed robot control system.LQR is a common controller approach used effectively in the control applications of the movement systems.Figure 5 shows block diagram of the Segway robot control system based on LQR controller.The state and output matrix equations describing the Segway robot equations of motion are given by:  ̇() = () + () (33) where (), (), (), () are the system, input, output and feed forward matrix respectively.In this approach, the input vector: where () and() are weighting state and input matrices respectively.The feedback gain matrix K can be determined by using the following: where P denotes the solution of the following Riccati: The controller weighting matrices should be tuned properly in order to minimize the following performance index where  11 ,  22 ,  33 and 44 q represent the weighting elements of position, speed, angle and angular velocity of the proposed robot system respectively.It is worth considering that by using controller weighting matrices () and () which govern the behavior of the robot system states and control effort respectively, the optimal LQR gain matrix  is computed based on the Matlab command " lqr ".
Figure 5. Segway robot control system using LQR controller

LQR OPTIMIZATION METHODS
In this research, two optimization algorithms, GA and BFOA, are used to tune the () and () matrices of the LQR controller, which are adopted to calculate the gain matrix required to balance the Segway system.Based on optimized gain matrix  a good output time response with minimal of rise time (  ), settling time(  ), maximum overshoot () and steady state error(  ) can be investigated.

Genetic algorithm
GA is an optimization technique used to find global solution for more control problems.Based on the mechanisms of natural selection.In this optimization approach, the solution space is selected by generating a population of candidate individuals to find optimum values for the problem.The procedure of GA optimization method includes three basic steps, namely selection, crossover and mutation.By applying these stages new individuals can be created, which, could be better than their parents.Based on the fitness function of the system, the GA steps are repeated for many generations and eventually stop at generating candidate individual elements that can represent the best solution for the application problem [14].Figure 6 shows the graphical illustration of the GA loop.
The definition of the GA steps is as follows Abdulla [14]: Random initial population -Choose individuals for mating -Mate the population to generate progeny -Mutate progeny -New individuals inserted into population -Are criteria satisfied?-End of solution searching.Each chromosome represented by five real value cells that correspond to the LQR controller weighting matrices () and () as shown in Figure 7.The chromosome elements  11 ,  22 ,  33 ,  44 and R should be adjusted properly by optimum positive numbers in order to achieve best control performance.

BFO algorithm
The bacteria foraging behavior is a computational model, which, has attracted more attention as it is a rich source of potential engineering applications.BFO is a simple and powerful population-based numerical optimization algorithm that has been introduced by Passino in 2002 [21].The BFO algorithm has been gaining a considerable interest in researchers due to its efficiency in solving and optimizing more engineering problems in several application domains, such as optimal control [22], harmonic estimation [23] and transmission loss reduction [24].The strategy of bacteria selection for the BFO algorithm bases on an idea that the bacteria with poor foraging is eliminated and following up those bacteria which have successful foraging to maximize energy obtained per unit time [21].It is worth considering that, in this new optimization algorithm a social foraging approach of the E-coli bacteria can be applied successfully to solve multi-optimal function optimization problem.The E-coli bacteria can move in two ways namely, swimming and tumbling.Figure 8 shows the swim and tumble movement of a bacterium.

BFO foraging strategy [25]
− Chemotaxis: This process is related to movement of bacterium during search for food.The E-coli bacteria can move in two ways namely, swimming and tumbling, and they are able to alternate between these two movement styles for the whole of their lifetime.In the swimming mode, the bacteria walk in a certain direction for gathering food, while in the tumbling mode, they move with random directions.− Swarming: The swarming action means the bacteria with a good fitness value, try to attract others to form groups, so that they all can arrive at the desired location.These groups of E-coli cells arrange themselves, in which, they can move as concentric patterns for food searching.− Reproduction: In this stage, all the bacteria population are classified based on health status.
The healthier bacteria, which, have had sufficient nutrients will be reproduced, while the less healthy bacteria will die.The surviving bacteria will split into an identical replica of itself placed in the same locations with a that number equals to the number of the dead ones.− Elimination and Dispersal: During this evolutionary step, gradual or sudden events or attacks in the local living environment of the bacteria, may occur due to significant rising of the temperature caused by occupancy of a high density of bacteria for a specific area.This high temperature may kill a group of bacteria and dispersal of others into some new locations.

ROBOT CONTROL SYSTEM DESIGN
In this research, an optimal control system for the Segway robot is designed using the state feedback LQR controller.The gain parameters of the controller are tuned effectively, using optimization algorithms, GA and BFOA.The proposed controller design is validated using Matlab programming.Based on step input, the control system is designed for the following requirements: rise time less than 10 (ms), settling time less than 30 (ms), maximum overshoot percentage less than 5%.The fitness function of the robot control system is as follows: where  is the closed-loop transfer function of the Segway robot scheme   is the rise time (s),   is the maximum rise time (s),   is the settling time (s),   is the maximum settling time (s),  is the overshoot value of the output response and  is the maximum over shoot value.This function is considered in optimization process of the controller gain matrix using GA and BFO tuning algorithms.

GA-LQR CONTROLLER DESIGN AND RESULTS
The block diagram of the Segway control system using GA-LQR controller is shown in Figure 9. Based on the system parameters ( =1.6,  =1.2,  =0.16,   =0.02,   =0.52,   =0.0032 2 ,   =0.0038  2 ) the state and output equation are given in ( 41) and ( 42) respectively.The global optimal solution for the LQR controller problem is achieved using genetic algorithm programming.This solution includes determine optimum values for the weighting matrices elements, which, are given below.Based on the optimized weighting matrices, the LQR gain matrix K was computed using the Matlab command "" as follows: = ( The response of the system output () and () using the above optimized feedback gain matrix is shown in Figure 10. Figure 11 presents the input signal of the Segway system.It is clear from Figures 10 and 11 that the tuned controller utilizing the GA tuning method can effectively perform a fast and stable response under an acceptable input effort.Based on Figure 10, the output states () and () tracked the demand input trajectories without overshoot, rise time and settling time of approximately 80 ms and 95 ms respectively and approximately zero steady state error.Figure 12 presents converging of the LQR weighting matrices through iterations based on GA tuning method.

BFO-LQR CONTROLLER DESIGN AND RESULTS
The design of LQR controller based on BFOA method is analogous to that of the GA-LQR control system as previously presented in Figure 9 The time response of the robot states (), () using BFOA-LQR controller is shown in Figure 13. Figure 14 shows the control effort required to stabilize the Segway robot system.Regarding the optimization of the controller, Figure 15 introduces converging elements of weighting matrices of the LQR controller through iterations based on BFOA tuning algorithm.By comparing the behavior of the robot system shown in Figures 10,11,13 and 14.It should be noted that the BFOA-LQR controller can achieve more stable and faster response through following the desired trajectories effectively.Table 1 shows comparison results between the GA-LQR controller and BFOA-LQR controller based on control criteria parameters.Based on Table 1, the BFOA-LQR controller enabled the walking robot to follow the demand trajectories effectively.

CONCLUSIONS
In this research, an optimal linear control system was adopted to balance a Segway two-wheeled mobile robot.The dynamics of the robot system is modeled in state space form in order to design a state feedback stabilizing controller for the Seqway robot system.A LQR controller was proposed to stabilize the Segway robot in upright position.The controller is optimized using two tuning algorithms, GA and BFO.
TELKOMNIKA Telecommun Comput El Control  Balancing a Segway robot using LQR controller based on genetic and… (Ibrahim K. Mohammed) 2653 An active stabilizing scheme for the Segway robot system has been implemented successfully using GA-LQR controller and BFOA-LQR controller.Simulation results of the controllers are introduced and then compared based on standard stabilizing parameters.The comparison revealed that the BFOA-LQR controller can be adopted to implement faster and a more stable balancing system for the Segway vehicle.

Figure 4 .
Figure 4. Free body diagram of the chassis

Figure 8 .
Figure 8. movement modes of a bacterium

Table 1 .
Performance parameters of the Segway using GA-LQR and BFOA-LQR controller