You are on page 1of 5

Dynamic Modeling and Simulation for Virtual

Evaluation of Inverted Wheeled Robot Controllers

Khalifa H. Harib, Kamal A.F. Moustafa Shaima Al Hebsi


Department of Mechanical Engineering Department of Electrical Engineering
UAE University UAE University
Al-Ain, UAE Al-Ain, UAE
k.harib@uaeu.ac.ae

Abstract—This paper develops a mathematical model of an


inverted wheeled robot and uses it to simulate and animate the
robot dynamics. The robot is modeled as a three-body system
consisting of a pendulum and two wheels where the Newtonian
mechanics is employed to derive the dynamical equations. The
proposed model, in its current configuration, is designed to
simulate and animate the controlled robot for forming a virtual
controller-testing setup. The open-loop system is simulated by
solving the nonlinear dynamic equations recursively within an
animation loop by using the Runge-Kutta 4 (RK4) method. The
nonlinear model is linearized for designing a PID controller to
stabilize the closed-loop system of the robot. The animation
process is conducted by creating two graphical objects that
resemble the wheel and pendulum in a graphical user interface
window. The keyboard arrows are used to interactively input the
horizontal motion of the robot cart to the animation process where Fig. 1. Schematic diagram for a two-dimensional model of an inverted
there is also an option to switch the controller off. Simulation wheeled robot
results are provided for both the open-loop and closed-loop cases
to illustrate the effectiveness of the results.
processes establishes the importance of accurate mathematical
Keywords—dynamic modeling; simulation; animation; model derivation. Also, various ground and airborne vehicles
inverted pendulum; wheeled robot are examples of multi-degrees of freedom unstable and
underactuated systems where the only way to stabilize and
control the system is through precise modeling and simulation.
I. INTRODUCTION The main contributions of this work are summarized as
The two-wheeled inverted pendulum has been an below:
interesting dynamic and control problem which merges variety (1) Derivation of an accurate mathematical model for a
of contemporary sciences [1]. Inverted pendulum is a fast, high nonlinear unstable multi-variable high order system
order, multi-variable system which combines nonlinearity, using nonlinear differential equation
intrinsic instability and strong coupling [2-4,7, 10]. All these (2) Verification of the derived model by using it as a base
characteristics have made this system a benchmark problem [5, to design a PID controller and successfully control the
6, 11] to test newly proposed control techniques. In this work, under-actuated system
an inverted pendulum on a cart is used, where the cart has two (3) Introducing a visual simulation of the nonlinear
differential wheels moving it freely to balance the inverted unstable system to visually observe the impulse
pendulum at the upright position. This system has three degrees unstable response as well as the closed loop stable
of freedom (DOF) with only two inputs [9]. This makes the behavior of the system
system under-actuated [2, 8], which makes the system more
challenging to control. This paper is structured as follows: after the introduction,
The main goal of this work is to derive an accurate model Section II describes the derivation of the dynamic model of the
system and the visual simulation. Section III introduces the
of a representative complex unstable nonlinear system, then
design of the controller that is used to stabilize the system.
demonstrate how to stabilize and control it using a PID Numerical evaluation of the closed loop system is detailed in
controller, which works satisfactorily only if the system model Section IV, while drawn conclusions are listed in Section V.
was correctly derived [5]. Existence of unstable industrial

978-1-5090-5454-1/17/$31.00 ©2017 IEEE


Fig. 3. Animation window showing the free response of the inverted
wheeled robot

the center of rotation of the wheel, and FRy is the horizontal


reaction force component between the wheel and the pendulum.
Similarly, from the FBD of the pendulum (Fig. 2), we obtain
the following equations

− − − + =
 + ( cos − sin ) 
 =  

where mp is the mass of the pendulum, Jp is the mass moments


of inertia of the pendulum about the center of rotation, lG is the
distance to the center of mass of the pendulum, and g is the
acceleration due to gravity. Substituting the components of the
acceleration of the center of mass of the pendulum, aGx and aGy,
in (3) and (4), and combining them with (1) and (2), we arrive
at the following final modeling equations
Fig. 2. Free-Body diagrams of the wheel and the pendulum
 ( + + ) + cos =
 + sin + ( − ) 
II. DYNAMIC MODELING AND SIMULATION  cos +( + ) =
A. The Modeling Equations  sin − − ( − ) 
The inverted wheeled robot is modeled as a three-body system As depicted by these equations, the system is highly nonlinear
consisting of a pendulum and two wheels. However, to derive and coupled. Since the number of actuators are less than the
the equations of motion, we only consider the motion along one number of degrees of freedom, the system is under-actuated. For
axis, and thus only the pendulum and one of the wheels will be such 2-Dimesnional case, the degrees of freedom are two with
used as shown in Fig 1. The Newtonian mechanics is employed one actuator, whereas for the 3-Dimensional case the degrees of
here to obtain the modeling equations. Figure 2 shows the free- freedom are three and the actuators are two.
body diagrams (FBD) of the pendulum and the wheel including
the force and torque components on the two bodies. Performing B. Open Loop Simulation
a dynamic balance of the force and torque components that act The equations of motion represented by (5) and (6) can be
on the wheel and the pendulum, as shown in the two free body simulated using various available simulation tools as part of
diagrams, yields the required equations of motion. From the software packages like MATLAB or Octave. For example, the
FBD of the wheel (Fig. 2), we obtain the following equations MATLAB ode45() solver could be used within the MATLAB
command window or through the graphical interface
 − + − =   SIMULINK. Since the two acceleration variables and do
 − =   not present explicitly in (5) and (6), solution of the two
simultaneous equations for the two unknown variables and
where  is the input motor torque,  is the angular displacement are needed, while the input and the states from the previous time
of the pendulum,  is the angular displacement of the wheel, R step are assumed to be known. This could be done numerically,
is the radius of the wheel, mw is the mass of the wheel, Ff is the although symbolic solution of the two equations is also possible.
rolling friction force component between the wheel and the Since the explicit equations that result from the symbolic
ground, B is the damping coefficient between the wheel and the solution will be lengthier than (5) and (6), the equations are not
pendulum, Jw is the mass moments of inertia of the wheel about displayed here.
Since our intention here is to solve the dynamic equations
recursively within an animation loop in iterative fashion in time,
it is necessary to use a recursive solver for the ordinary 6

differential equation that can be implemented online. The solver


uses the previous solution xi-1 to return the current solution xi. As 5

such we define the state vector x as 
4

 = , , ,   3

Torque (N.m)
which is the solution of the system. The vector function of the 2

system equations can be written as function f (t, x)


1

 ( , )= = , , ,   0

Here we will use the RK4 method to find the current solution xi -1
0 5 10 15 20 25 30 35 40 45 50
Time (sec)
using the solution xi-1 from the previous time step
Fig. 4. Open loop free response of the inverted wheeled robot

 = + ( /6) ∗ ( + 2 + 2 + ) 

where
III. STABILIZING CONTROL
= ( , ), The control problem can be pursued by solving the
= ( + /2, + ∗ /2), stabilization problem independent of the steering problem.

= ( + /2, + ∗ /2), A. Linearized Model and Transfer Function


= ( + , + ∗ ), The nonlinear model as represented by (5) and (6) is
and T is the fixed time step size used. linearized about an operating point = = = = 0. The
linearized model is used in designing a linear feedback controller
to stabilize the system. The linearization yields the following
C. Animation Using MATLAB linear model.
Although we use MATLAB here to demonstrate the
animation process, other object oriented programming
languages could also be used including Java, Python, C++ and ( + + ) + = + ( − ) 
C#. In a graphical user interface window, two graphical object +( + ) = − − ( − ) 
are created to resemble the wheel and the pendulum as shown in
Figure 3. In an iterative procedure, the x and y data of the two To obtain the transfer function between  (s) and  (s), we apply
objects are updated using the RK4 solution x. With no feedback Laplace transform on (10) and (11), and combine the two
control, the system should exhibit a free response from some resulting equations to eliminate  (s). This yields the following
nonzero initial conditions near the upright position and oscillate transfer function.
around the stable downward position. A numerical example is
used in the next section to demonstrate and validate the
simulation and animation. + + + +
+[2 + + + + +
D. Numerical Example
]
In this subsection, the open loop uncontrolled system is − + +
simulated using a numerical example. In this study, the
following parameters are used: mp = 0.3 kg, mw = 0.5 kg, Jp = − } ( )
0.01 kg.m2, Jw = 0.0025 kg.m2, g = 9.81 m/s2, R = 0.1 m, and B = −( + + + ) ( ) 
= 0.01 N.m.s. Fig. 4 shows the angular displacements  and .
The two variables start near zero, which is the upright position B. Closed Loop Controller Design
for the pendulum, and increase to oscillate around  rad (the
stable position) with a frequency of 0.8 Hz. This response is also Using the parameters of Section II.D, we obtain the
demonstrated using the animation process shown in Fig. 3. In following transfer function for the linearized model
such animated motion, the robot starts near the unstable upright
position, and move to the downward stable position exhibiting  ( )/ ( ) = −84.6154 / ( + 2.2821 − 31.6938 
under-damped oscillation, validating the correctness of the  −30.1846) 
simulation.
As can be seen in (13), the system has a zero at the origin and
three poles at -6.4632, 5.0974, and -0.9162. The pole at 5.0974 10

renders system unstable. 8

A PID controller with a pole at the origin and a pair of 6

conjugate zeros at -5±j2 are added to the open loop transfer 4

function (13). The added pole cancels the zero of the open loop 2

system. On the other hand, adding the two zeros attracts the

Imag
0

unstable pole at 5.0974 and the pole at -0.9162 to the left-hand -2


side of the s-plane, while moving the poles at -6.4632 further to
the left. As shown in the root locus plot of Fig. 5, two of the four -4

closed loop poles move to the two zeros, one stays with the zero -6

at the origin while the fourth one moves to -∞. This design -8

strategy allows to move all the closed loop poles to stable -10

locations, and hence stabilize the system. Among possible stable


-20 -15 -10 -5 0 5 10
Real

locations, we choose here a conjugate pair closer to the zeros of Fig. 5. Root locus plot of the system using the open-loop transfer function
the controller which corresponds to a root locus gain of -5.0. (13), and a PID controller with a pole at 0 and two zeros at -5± j3
This yields the following controller
5,
and 7 seconds. The actuation torque, as indicated in Fig. 8,
( ) = −5( + 5 + 2)( + 5 − 2)(1/ ) ( )  increased at these instances to cope with the transient responses.
Rewriting (14) as
V. CONCLUSIONS

 ( ) = −5(10 + 29/ + ) ( )  The inverted wheeled robot is a classical problem that is
used intensively to test proposed controllers for a wide class of
it can be seen that the resulting PID controller has a proportional inherently unstable systems. A coupled nonlinear model that
gain Kp = -50.0, an integral gain KI = -145.0, and a derivative describes the dynamics of such robot is derived in this paper.
gain KD = -5.0. In the time domain, the controller that regulate The developed model is employed to simulate and animate the
the system in an upright position could thus be implemented as controlled robot for forming a virtual controller-testing setup.
Both open-loop and closed loop control systems are simulated
 ( ) = −50 ∗ ( ) − 145 ∗ ( ) − 5 ∗ ( )  and animated. The open-loop simulation is conducted by
solving the nonlinear dynamic equations recursively using the
RK4 method. The nonlinear model is linearized and used to
To control the horizontal motion = ( ), a simple
control the considered robot in a closed-loop configuration. In
Proportional controller could be used as indicated below
the closed-loop configuration, the pendulum tilting angle and the

 ( ) = −2 ∗ ( )− ( )  
6
A controller that stabilizes and control the motion of the robot
is obtained by adding (16) and (17). 5

IV. SIMULATION OF THE CLOSED LOOP SYSTEM 4


Angular Displacement (rad)

The PID controller (13), designed in the previous section, is 3

implemented to stabilize the system as shown in the closed loop


simulated response in Fig. 6. The horizontal motion is also 2

controlled and inputted into the animated simulation using the


arrow keys on the keyboard, as indicated in Fig. 7. In the 1

animated simulation, an option to switch off the controller is also


added. As shown in the response of Fig. 6, the controller was 0

turned off and turned on again at t = 2.5 seconds. This resulted


in a perturbation in the response, which the system recovered -1
0 1 2 3 4 5 6 7 8 9

from as indicated on the figure. The robot picked up a motion in Time (sec)

the positive y-direction. The motion was then intentionally


increased at t = 5 seconds using the arrow keys. The motion was Fig. 6. Closed loop response of the inverted wheeled robot
reversed at t = 7 seconds. Figure 6 shows that  went into
transient responses when the system was perturbed at t = 0, 2.5,
8

Torque (N.m)
2

0
Fig. 7. Animation window for the controlled inverted wheeled robot with a
instruction and notification for the user and display of values of the states
-2

horizontal motion of the cart are controlled, respectively, using


-4
a PID and P controllers. These controllers are designed in the s- 0 1 2 3 4
Time (sec)
5 6 7 8 9

domain by choosing their gains to stabilize the inherently


Fig. 8. Actuation torque for the closed loop response of the inverted
unstable system. The animation process is implemented in the
wheeled robot
MATLAB environment by creating two graphical objects that
resemble the wheel and pendulum in a graphical user interface
[6] S. Hanwate, A. Budhraja, Y. Hote, "Improved Performance of Cart
window. Simulation results are provided for both the open-loop Inverted Pendulum System Using LQR Based PID Controller and ANN",
and closed-loop cases to illustrate the validation and IEEE UP Section Conference on Electrical Computer and Electronics
effectiveness of the modeling and animation. (UPCON), 2015
[7] Q. Liang, L. Qi, L. Chuang, "Inverted pendulum controller design based
REFERENCES on swarm algorithm", International Symposium on Computer, Consumer
and Control, 2016
[1] L. Hong-yu, F. Jian, "An inverted pendulum fuzzy controller design and [8] N. Minouchehr, S. Hosseini-Sani, N. Vaezi, P. Tavakoli, "LMI-based
simulation", International Symposium on Computer, Consumer and Robust Constrained Model Predictive control of Two-Wheeled Inverted
Control, 2014 Pendulum", Second International Congress on Technology,
[2] S. Ri, J. Huang, C. Tao, M. Ri, Y. Ri, and D. Han, "A High-Order Communication and Knowledge (ICTCK 2015)
Disturbance Observer Based Sliding Mode Velocity Control of Mobile [9] W. Ye, Z. Li, C. Yang, J. Sun, C. Su, R. Lu, "Vision-Based Human
Wheeled Inverted Pendulum Systems", 2016 12th World Congress on Tracking Control of a Wheeled Inverted Pendulum Robot", IEEE
Intelligent Control and Automation (WCICA), 2016, Guilin, China Transactions On Cybernetics, Vol. 46, No. 11, 2016
[3] Z. jie, R. Sijing, "Sliding Mode Control of Inverted Pendulum Based on [10] S. Krafes, Z. Chalh, A. Saka, "Review: Linear, nonlinear and intelligent
State Observer", Sixth International Conference on Information Science controllers for the inverted pendulum problem", 2nd International
and Technology, 2016 Conference on Electrical and Information Technologies ICEIT’2016
[4] L. Hui, Z. Min, G. Chen, "Cloud-Model PID Control of Double Inverted [11] A. Dhar, A. Sengupta, "Sliding Mode Control Algorithm With Adaptive
Pendulum Based on Information Fusion", Proceedings of the 35th Gain and Implementation on Inverted Pendulum System", Michael
Chinese Control Conference, 2016 Faraday IET International Summit: MFIIS-2015
[5] K. Chhabra, M. Rihan, "Design of Linear Quadratic Regulator for Rotary
Inverted Pendulum Using LabVIEW", IEEE, 2016

You might also like