Abstract
Two-wheeled self-balancing vehicle system is a kind of naturally unstable underactuated system with high-rank unstable multivariable strongly coupling complicated dynamic nonlinear property. Nonlinear dynamics modeling and simulation, as a basis of two-wheeled self-balancing vehicle dynamics research, has the guiding effect for system design of the project demonstration and design phase. Dynamics model of the two-wheeled self-balancing vehicle is established by importing a TSi ProPac package to the Mathematica software (version 8.0), which analyzes the stability and calculates the Lyapunov exponents of the system. The relationship between external force and stability of the system is analyzed by the phase trajectory. Proportional–integral–derivative control is added to the system in order to improve the stability of the two-wheeled self-balancing vehicle. From the research, Lyapunov exponent can be used to research the stability of hyperchaos system. The stability of the two-wheeled self-balancing vehicle is better by inputting the proportional–integral–derivative control. The Lyapunov exponent and phase trajectory can help us analyze the stability of a system better and lay the foundation for the analysis and control of the two-wheeled self-balancing vehicle system.
Introduction
In recent years, two-wheeled self-balancing vehicle is widely used for its advantages such as energy saving, environmental protection, simple structure, flexible operation, and so on. The research has a strong theoretical significance and practical value. In 1986, Yamato Gaoqiao, professor of Tokyo Electric Communication University, first designed the mobile robot of double coaxial and self-standing. 1 In 2002, the first two-wheeled self-balancing vehicle Segway human transporter (HT) was produced. 2 Now, a variety of standing and sitting vertical two-wheeled self-balancing vehicles have been developed. Two-wheeled self-balancing vehicles can maintain dynamics balance, but they also have an unstable dynamics characteristic. 3 As a result, the stability of the two-wheeled self-balancing vehicles is the key factor to be considered in the research and design. 4,5 At present, the research on the two-wheeled self-balancing vehicles mainly focused on the design and control of stability. A variety of control algorithms have been developed. The Segway personal transporter used redundant control algorithm, 6,7 the HT vehicle of Camosun College used the fuzzy control algorithm, 8 the two-wheeled vehicle of Adelaide University used proportional-derivative (PD) control method, and “free mover” in China University of Science and Technology used proportional–integral–derivative (PID) control algorithm. 9 These algorithms can ensure dynamics stability of two-wheeled self-balancing vehicles and users can flexibly operate through a simple training. But as a nonlinear system, two-wheeled self-balancing vehicles have many characteristics, such as multivariable, 10 strong coupling, 11 and nonholonomic constraints and parameter uncertainty. 12,13 Analysis and study of the dynamics characteristics of the two-wheeled vehicles are very complicated. At present, the research in this area is relatively few. It has become a focus of how to understand its intrinsic characteristics by the simple external structure of the two-wheeled self-balancing vehicle.
In this article, a dynamics modeling method with software package ProPac TSi is used and a PID controller is designed for its simple structure and other advantages. Also, a method based on Lyapunov exponent 14 is used to analyze the stability of the vehicle system. 15 And Lyapunov exponent, which is related to system stability, is an average of the contraction and expansion characteristics of the orbits in different directions in the phase space. Then, according to the system phase trajectory attractor types, influence of different PID coefficients on the stability of the system is analyzed. The control effectiveness is validated through the numerical simulation, and the results demonstrate that PID controller can effectively ensure stability and provide robust self-balancing control.
The rest of this article is organized as follows. Section “Methodology” describes the methodology of the proposed vehicle including dynamics modeling and calculation of Lyapunov exponents. Section “Simulation” shows the simulation results of Lyapunov exponents and PID controller. Finally, some conclusions are presented in the last section.
Methodology
Dynamics modeling
Two-wheeled self-balancing vehicle system mainly consists of two parts, namely, the body and the pendulum bar, and the pendulum bar is mainly used to control the motion of the vehicle. 16 Two-wheeled self-balancing vehicle has three degrees of freedom, that is, rotation of pendulum bar around wheel set, translational motion, and turning motion of body in the horizontal plane. We selected angle Φ 17 between pendulum bar and vertical direction, body turning angle θ, and body translational displacement x as the generalized coordinates, corresponding to the pseudo velocity, respectively, wy , wz , and vx .
In order to facilitate the analysis, some assumptions are made as follows: The body and pendulum bar are regarded as rigid body. The influence of different users’ weight and height is reflected on body weight and pendulum bar’s center of gravity. Wheels only scroll without sliding and sideslip. Ignoring air resistance and other tiny friction.
The working principle of two-wheeled self-balancing vehicle is similar to that of an inverted pendulum. 18,19 In order to facilitate the modeling, the two-wheeled vehicles can be reduced to a physical model as shown in Figure 1.

Simplified model of two-wheeled vehicle.
In Figure 1, the position and orientation of the two-wheeled vehicles are described by the coordinates of the three-dimensional coordinate system o-xyz fixed to the rigid body and the inertial reference frame O-XYZ. Then, import the ProPac TSi dynamics modeling software package into the Mathematica software, building dynamics modeling of the two-wheeled vehicle system, solving the equations of its kinematics and dynamics. The main parameters of the model are as follows:
m
1: Sum of the mass of the vehicle body and the person
m
2: Pendulum bar weight
g: Acceleration of gravity
a: Body and person’s centroid position
b: Pendulum bar height
c: Body width
F: Output force of motor
I
1, I
2: Inertia tensor of vehicle body and pendulum bar
The units of the aforementioned parameters are the international standard units. Through consulting data, we get its value.
The Euler–Poincare equation is used to establish the system model. The dynamics modeling process is as follows: Step 1: Initialization
Define joint data
Define body data
Define interconnection structure
Define potential energy g = gc PE = 0 Q = {0, F1, 0, T2} Step 2: Dynamics modeling
Step 3: Parameterization END
The kinematics and dynamics equations are shown in the following equation 20
where q is the generalized coordinate vector and
F (p, q) is the viscous friction and gravity and Q is the external forces and moments. By establishing the model and numerical calculation, parameter matrixes of the above two equations are obtained as follows
where
where
Jzz is the moment of inertia around Z axis and Iy is the moment of inertia around the Y axis. From equation (1), the generalized coordinate vector q and the quasi-velocity vector p can be obtained as equations (2) and (3)
Equations (2) and (3) are transformed into the form of the system state equation, that is, equation (4)
where
Calculation of Lyapunov exponents
Lyapunov exponent, which is calculated as equation (5), is related to the initial moments of the system’s motion track with two infinitely close points that are separated by time. It is an average of the contraction and expansion characteristics of the orbits in different directions in the phase space. 21 N dimensional system has n Lyapunov exponents, and each Lyapunov exponent can be regarded as the phase space in all directions of motion relative to the local deformation of the average
This article is based on the dynamics equation method to calculate the Lyapunov exponent. Let W denotes the tangent vector of the system track, and it can be obtained from equation (4), which can be represented as
where
The sampling instant T is fixed at 0.1 s and the iterative value K is fixed at 100 in order to calculate the Lyapunov exponent. The initial condition of equation (6) is set as

Flowchart of Lyapunov exponent calculation.
This article is based on the Lyapunov exponent method to judge the stability of a two-wheeled vehicle system. When the Lyapunov exponents are greater than 0, the system is unstable or chaotic. 22,23 When the Lyapunov exponent is 0, the phase trajectory is periodic motion. 24 When the Lyapunov exponent of all states of the system is less than 0, the phase orbit of the system is attracted to a stable fixed point, and the whole system is stable. 25
Simulation
Simulation and analysis based on Lyapunov exponents
By means of symbolic computation software Mathematica, the dynamics equations of the system are programmed and simulated, and the Lyapunov exponent spectrum of each variable of the two-wheeled vehicle system is obtained. The vehicle system is an eight-dimensional system with four generalized coordinates and four pseudo speeds, and the Lyapunov exponent spectrums are also eight dimensional. The corresponding exponential spectra of the calculated variables are shown in Figure 3.

Lyapunov exponent.
It can be seen from the exponential spectrum curve of the whole system that the Lyapunov exponent of three variables in the system is greater than 0. Therefore, the two-wheeled vehicle system is a super chaotic system, 17 and its motion behavior is closely related to the initial condition and the movement behavior is extremely complex and difficult to predict.
Two-wheeled vehicle has unstable dynamics characteristics, and stability is influenced by three main factors, namely, system structure parameters, external forces and moments applied to the system and the initial conditions. Phase trajectory curve can be used to analyze the impact of the external forces and moments on the stability of the two-wheeled vehicle.
PID control is used in this article. We selected angle Φ between pendulum bar and vertical direction as control variables, and the expectation is set to 0.03sinΦ. By changing the proportionality coefficient Kp , integral coefficient Ki , and differential coefficient Kd and simulation, phase trajectory can be obtained as shown in Figure 4, and then we analyze the influence of the coefficients on the dynamics characteristics of the system. Three coefficients of PID are shown below figure 4(a), the same as figure 4(b), figure 4(c) and figure 4(d).

Trajectory simulation.
Figure 4 shows phase trajectory simulation of two-wheeled self-balancing vehicle whose driving force is controlled by PID algorithm. According to the phase trajectory direction, we can see that the force applied in the two-wheeled self-balancing vehicle has great influences on the stability of the system. The trajectory of Figure 4(a) is more chaotic and disorder, and the system has a super chaotic attractor. Its appearance is closely related to the instability of the system. Under the force, the two-wheeled vehicle is more sensitive to initial conditions, and its motion behavior is more complex, which cannot meet the self-balance of two-wheeled vehicle. When reducing integral coefficient, the phase trajectory simulation diagram is shown as Figure 4(b), and its trajectory relative to Figure 4(a) is more clear. It shows that the integral coefficient has an influence on the stability of the system. When the coefficient decreases, the system tends to be stable, but the system is still chaotic. When integral coefficient is 0, the simulation is shown as Figure 4(c) and the trajectory is more clear. It displays system seems to have fixed point attractor, but there is a downward extension of the line. With the combination of practical and two-wheeled vehicle simulation results, two-wheeled vehicle is not up to predetermined requirements. Figure 4(d) is a phase trajectory simulation diagram when the proportional and differential coefficients based on Figure 4(c) are constantly adjusted. At this time, proportion coefficient is 3860 and differential coefficient is 1980. It can be seen under the control of PD, angle Φ between pendulum bar and vertical direction and the angular velocity of the pendulum bar can tend to the point near (0,0) point. Two-wheeled system can be approximated to reach the equilibrium state. Simulation results are similar under the conditions of changing the initial value. Here, we can have a more intuitive understanding of the motion state of the two-wheeled vehicle system through the simulation diagram of the state of two-wheel vehicle.
Simulation and analysis of PID control
The principle of self-balance can be simply understood that when the pendulum bar moves forward in the direction of tilt, two-wheeled vehicle should accelerate to avoid the pendulum bar down. The same way when the pendulum rod back tilt, two-wheeled vehicle decelerates. In this article, the angle of the pendulum bar forward is recorded as positive, and the backward tilt is negative. Now let the car in normal travel by different disturbance, in order to observe the degree and the time to restore the stability of the state.
First of all, let the two-wheeled vehicle is subjected to a forward tilt of the disturbance
The diagrams of pendulum bar angle, angular velocity, two-wheeled vehicle translational velocity, and translational displacement with time variation are shown in Figure 5(a) to (d).

Two-wheeled vehicle acceleration state simulation diagram.
Figure 5(a) and 5(b) shows the curve of pendulum angle and angular velocity with time after the disturbance. It can be seen that the curve in the wave after a period of time can be restored to a stable state. Figure 5(c) shows that translational velocity can also tend to be stable after an acceleration fluctuation, and the vehicle runs smoothly with new speed. Figure 5(d) shows the displacement curve over time of the two-wheeled vehicle and the time change, from which we can work out the speed, and it is roughly consistent with Figure 5(c). Combined with practical experience, we can know that the control is generally in line with the requirements.
Then, let the two-wheeled vehicle is subjected to a backward tilt of the disturbance
The diagrams of pendulum bar angle, angular velocity, two-wheeled vehicle translational velocity, and translational displacement with time variation are shown in Figure 6(a) to (d).

Two-wheeled vehicle deceleration state simulation diagram.
Similar to the acceleration process, Figure 6(a) and (b) shows that the pendulum angle and angular velocity return to point near the zero after a period of fluctuations, that is, the pendulum bar approximates to maintain in the vertical direction and two-wheeled vehicle system achieves self-balance. Figure 6(c) shows that the translational velocity tends to be stable after reduction in volatility. Translational displacement increment speed shown in figure 6(d) is relatively slow compared with figure 5(d). Simulation results show that this article can achieve a series of operations such as start, stop, acceleration, deceleration, and disturbance self-recovery by driving force of PID control. The controlled angle range of pendulum bar is large, so it has a certain practical significance.
Conclusion
For two-wheeled self-balancing vehicle system, stability is the key factor to affect the performance characteristic. In this article, stability of two-wheeled self-balancing vehicle system is analyzed by the method of Lyapunov exponent. Phase trajectory is used to analyze influence on dynamics characteristics of the system. Researches show that Lyapunov exponent and system phase trajectory can help to understand the dynamics characteristics of the system. Finally, through numerical simulation, it is concluded that PID controller can effectively ensure stability and provide certain robustness for two-wheeled self-balancing vehicle system.
Footnotes
Acknowledgements
The authors thank the anonymous reviewers for helpful and insightful remarks. The authors also acknowledge helpful discussions with Professor Wu Qiong from Canada University of Manitoba on his guidance in Lyapunov exponent theory.
Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This research is supported by the National Natural Science Foundation of China (51575283, 51405243, 51405241), the Natural Science Foundation of Jiangsu province (BK20130999), the open project (KDX1102) of Jiangsu Key Laboratory of Meteorological Observation and Information Processing, and Nanjing University of Information Science and Technology.GQ: Please confirm that the Funding and Conflict of Interest statements are accurate.]
