Anda di halaman 1dari 6

EECS 106A Final Project: BalletBot

by Richard Aik Ho Tan, Jianshu Chi


Modeling the Inverted Pendulum

Consider the system consisting of a cart with a rod placed on its center as shown on the diagram
above.
𝑚0 = Mass of the car
𝑚1 = Mass of the rod
𝐿1 = Length of the rod
𝜃0 = Distance of the cart’s center from the wall located on the left
𝜃1 = Angle of deviation of the rod from the vertical axis
𝑢 = Force applied on the cart
𝐼 = Moment of inertia of the rod with respect to its center of mass
g = Gravitational constant
Finally, we make the assumption that there is no friction between the cart and the floor or the
cart and the rod
Our goal is to determine the equations that describe the system’s motion using the Euler-
Lagrange equations. The Lagrangian function L is defined as the difference of the system’s
kinetic and potential energy. The system’s kinetic energy T equals the sum of kinetic energy for
each of the system’s two bodies, the cart and the rod. The system’s potential energy P is the sum
of the potential energy of the cart and the rod. The level of the cart is considered the zero
potential energy level for the system. Hence:

Denoting by 𝑇0 , 𝑃0 𝑎𝑛𝑑 𝑇1 , 𝑃1 the kinetic and potential energy of the car and the rod
respectively, we obtain

1
EECS 106A Final Project: BalletBot
by Richard Aik Ho Tan, Jianshu Chi

Applying the basic laws of physics leads to formulas for the kinetic and potential energy for each
of the system’s bodies as follows:

Substituting the above into the Lagrangian (2) gives:

2
EECS 106A Final Project: BalletBot
by Richard Aik Ho Tan, Jianshu Chi
Calculating the partial derivatives using the chain rule gives:

Substituting these quantities in (7) leads to:

Equations (8) and (9) describe the system’s motion. For the sake of simplicity, these equations
can be written in matrix form using the column vector 𝜃 defined above. Thus, (8) - (9) can be
written equivalently as

Where the matrices 𝐷(𝜃), 𝐶(𝜃̇ , 𝜃), 𝐺(𝜃)𝑎𝑛𝑑 𝐻(𝑢) are time varying

3
EECS 106A Final Project: BalletBot
by Richard Aik Ho Tan, Jianshu Chi
and the moment of inertia equals to 𝐼 = 𝑚1 𝐿1 /12. It is observed that the system is strongly
nonlinear since there exist products of different states and states appear as arguments of
trigonometric functions. This makes the system hard to control.
The next goal, after finding the equations of motion, is to define an equivalent system that
consists of first order differential equations. Such systems are called state space models. Define
the column vector:

Using the model description (1) and multiplying from the left by the inverse of 𝐷(𝜃),
equation (10) is written as

In (13), the matrices are denoted only by name without mentioning the variables on which they
depend. This was made for the sake of brevity, but the dependence of each matrix form the
variables still holds as before.

Linearization
The system can be linearized around its upright equilibrium, 𝜃1 = 0. This means that it is
possible to obtain a simplified linear version of the system that describes its behavior around this
point. Thus, we can work with this simplified version in order to design a control law, which
when applied to the system, will be able to keep it balanced on the upright position. For the
nonlinear system described by 𝑥̇ = 𝑓(𝑥, 𝑢) , the upright equilibrium is the point

For small deviations from this point, the angle 𝜃1 is very small, so we can make the
approximations 𝑠𝑖𝑛(𝜃1 ) = 𝜃1 , 𝑐𝑜𝑠(𝜃1 ) = 1 and 𝜃̇ 2 = 0 .
Under these approximations, the system becomes

4
EECS 106A Final Project: BalletBot
by Richard Aik Ho Tan, Jianshu Chi

Or equivalently in state space form

where

This system is linear and the matrices A and B are time invariant.
Simulation
We then simulate the above linear model in Matlab. We define the linearized system (15) as a
state space system, where the output and states are the same, 𝑦(𝑡) = 𝑥(𝑡) . Subsequently, using
the Linear Quadratic Regulator (LQR) method, we determine a feedback control law of the form
𝑢(𝑡) = −𝐾𝑥(𝑡) , that maintains the pendulum in the upright position. This LQR method is based
on minimizing the cost function

Where Q and R are symmetric, positive semidefinite and positive definite weight matrices
respectively, that are used to assign cost in the states for which we have the strictest
requirements. In our example, since we do not want the cart to move far away on the x-axis and
because we do not want large deviations of the rod from its equilibrium (because this will lead to
a loss of linearity), we will choose larger values for the corresponding entries of the matrix Q.
This entries of Q corresponding to the cart velocity and the angular velocity are set to zero, since
we assume they do not post any limitations for this particular example. As initial conditions, we
choose the position and the velocity of the cart to be zero, a 5° angle for the rod and an angular
velocity of 5°/sec. Simulation results can be seen on the diagram below. We can see that for
different values of the matrix Q, the solution of the system is significantly different. Putting a higher

5
EECS 106A Final Project: BalletBot
by Richard Aik Ho Tan, Jianshu Chi
cost on the rod displacement, we obtain smaller oscillations and the system returns to the
equilibrium faster.

Anda mungkin juga menyukai