# Inverted pendulum

Balancing cart, a simple robotics system

An inverted pendulum is a pendulum that has its center of mass above its pivot point. It is often implemented with the pivot point mounted on a cart that can move horizontally and may be called a cart and pole. Most applications limit the pendulum to 1 degree of freedom by affixing the pole to an axis of rotation. Whereas a normal pendulum is stable when hanging downwards, an inverted pendulum is inherently unstable, and must be actively balanced in order to remain upright; this can be done either by applying a torque at the pivot point, by moving the pivot point horizontally as part of a feedback system, changing the rate of rotation of a mass mounted on the pendulum on an axis parallel to the pivot axis and thereby generating a net torque on the pendulum, or by oscillating the pivot point vertically. A simple demonstration of moving the pivot point in a feedback system is achieved by balancing an upturned broomstick on the end of one's finger. The inverted pendulum is a classic problem in dynamics and control theory and is used as a benchmark for testing control strategies.

A second type of inverted pendulum is a tiltmeter for tall structures, which consists of a wire anchored to the bottom of the foundation and attached to a float in a pool of oil at the top of the structure that has devices for measuring movement of the neutral position of the float away from its original position.

## Overview

The inverted pendulum is a classic problem in dynamics and control theory and is widely used as a benchmark for testing control algorithms (PID controllers, state space representation, neural networks, fuzzy control, genetic algorithms, etc.). Variations on this problem include multiple links, allowing the motion of the cart to be commanded while maintaining the pendulum, and balancing the cart-pendulum system on a see-saw. The inverted pendulum is related to rocket or missile guidance, where the center of gravity is located behind the center of drag causing aerodynamic instability.[1] The understanding of a similar problem can be shown by simple robotics in the form of a balancing cart. Balancing an upturned broomstick on the end of one's finger is a simple demonstration, and the problem is solved in the technology of the Segway PT, a self-balancing transportation device.

Another way that an inverted pendulum may be stabilized, without any feedback or control mechanism, is by oscillating the support rapidly up and down. This is called Kapitza's pendulum. If the oscillation is sufficiently strong (in terms of its acceleration and amplitude) then the inverted pendulum can recover from perturbations in a strikingly counterintuitive manner. If the driving point moves in simple harmonic motion, the pendulum's motion is described by the Mathieu equation.

## Equations of motion

The equations of motion of inverted pendulums are dependent on what constraints are placed on the motion of the pendulum. Inverted pendulums can be created in various configurations resulting in a number of Equations of Motion describing the behavior of the pendulum.

### Stationary pivot point

In a configuration where the pivot point of the pendulum is fixed in space, the equation of motion is similar to that for an uninverted pendulum. The equation of motion below assumes no friction or any other resistance to movement, a rigid massless rod, and the restriction to 2-dimensional movement.

${\displaystyle {\ddot {\theta }}-{g \over \ell }\sin \theta =0}$

Where ${\displaystyle {\ddot {\theta }}}$ is the angular acceleration of the pendulum, ${\displaystyle g}$ is the standard gravity on the surface of the Earth, ${\displaystyle \ell }$ is the length of the pendulum, and ${\displaystyle \theta }$ is the angular displacement measured from the equilibrium position.

When added to both sides, it will have the same sign as the angular acceleration term:

${\displaystyle {\ddot {\theta }}={g \over \ell }\sin \theta }$

Thus, the inverted pendulum will accelerate away from the vertical unstable equilibrium in the direction initially displaced, and the acceleration is inversely proportional to the length. Tall pendulums fall more slowly than short ones.

Derivation using torque and moment of inertia:

The pendulum is assumed to consist of a point mass, of mass ${\displaystyle m}$, affixed to the end of a massless rigid rod, of length ${\displaystyle \ell }$, attached to a pivot point at the end opposite the point mass.

The net torque of the system must equal the moment of inertia times the angular acceleration:

${\displaystyle {\boldsymbol {\tau }}_{\mathrm {net} }=I{\ddot {\theta }}}$

The torque due to gravity providing the net torque:

${\displaystyle {\boldsymbol {\tau }}_{\mathrm {net} }=mg\ell \sin \theta \,\!}$

Where ${\displaystyle \theta \ }$ is the angle measured from the inverted equilibrium position.

The resulting equation:

${\displaystyle I{\ddot {\theta }}=mg\ell \sin \theta \,\!}$

The moment of inertial for a point mass:

${\displaystyle I=mR^{2}}$

In the case of the inverted pendulum the radius is the length of the rod, ${\displaystyle \ell }$.

${\displaystyle m\ell ^{2}{\ddot {\theta }}=mg\ell \sin \theta \,\!}$

Mass and ${\displaystyle \ell ^{2}}$ is divided from each side resulting in:

${\displaystyle {\ddot {\theta }}={g \over \ell }\sin \theta }$

### Inverted pendulum on a cart

A schematic drawing of the inverted pendulum on a cart. The rod is considered massless. The mass of the cart and the point mass at the end of the rod are denoted by M and m. The rod has a length l.

An inverted pendulum on a cart consists of having a horizontally moving base as shown in the image to the right. The cart is restricted to linear motion and is subject to forces resulting in or hindering motion. The equations of motion can be derived using Lagrange's equations. We refer to the drawing to the right where ${\displaystyle \theta (t)}$ is the angle of the pendulum of length ${\displaystyle l}$ with respect to the vertical direction and the acting forces are gravity and an external force F in the x-direction. Define ${\displaystyle x(t)}$ to be the position of the cart. The Lagrangian ${\displaystyle L=T-V}$ of the system is:

${\displaystyle L={\frac {1}{2}}Mv_{1}^{2}+{\frac {1}{2}}mv_{2}^{2}-mg\ell \cos \theta }$

where ${\displaystyle v_{1}}$ is the velocity of the cart and ${\displaystyle v_{2}}$ is the velocity of the point mass ${\displaystyle m}$. ${\displaystyle v_{1}}$ and ${\displaystyle v_{2}}$ can be expressed in terms of x and ${\displaystyle \theta }$ by writing the velocity as the first derivative of the position;

${\displaystyle v_{1}^{2}={\dot {x}}^{2}}$
${\displaystyle v_{2}^{2}=\left({\frac {d}{dt}}{\left(x-\ell \sin \theta \right)}\right)^{2}+\left({\frac {d}{dt}}{\left(\ell \cos \theta \right)}\right)^{2}}$

Simplifying the expression for ${\displaystyle v_{2}}$ leads to:

${\displaystyle v_{2}^{2}={\dot {x}}^{2}-2\ell {\dot {x}}{\dot {\theta }}\cos \theta +\ell ^{2}{\dot {\theta }}^{2}}$

The Lagrangian is now given by:

${\displaystyle L={\frac {1}{2}}\left(M+m\right){\dot {x}}^{2}-m\ell {\dot {x}}{\dot {\theta }}\cos \theta +{\frac {1}{2}}m\ell ^{2}{\dot {\theta }}^{2}-mg\ell \cos \theta }$

and the equations of motion are:

${\displaystyle {\frac {\mathrm {d} }{\mathrm {d} t}}{\partial {L} \over \partial {\dot {x}}}-{\partial {L} \over \partial x}=F}$
${\displaystyle {\frac {\mathrm {d} }{\mathrm {d} t}}{\partial {L} \over \partial {\dot {\theta }}}-{\partial {L} \over \partial \theta }=0}$

substituting ${\displaystyle L}$ in these equations and simplifying leads to the equations that describe the motion of the inverted pendulum:

${\displaystyle \left(M+m\right){\ddot {x}}-m\ell {\ddot {\theta }}\cos \theta +m\ell {\dot {\theta }}^{2}\sin \theta =F}$
${\displaystyle \ell {\ddot {\theta }}-g\sin \theta ={\ddot {x}}\cos \theta }$

These equations are nonlinear, but since the goal of a control system would be to keep the pendulum upright the equations can be linearized around ${\displaystyle \theta \approx 0}$.

### Pendulum with oscillatory base

The equation of motion for a pendulum connected to a massless, oscillating base is derived the same way as with the pendulum on the cart. The position of the point mass is now given by:

${\displaystyle \left(-\ell \sin \theta ,y+\ell \cos \theta \right)}$

and the velocity is found by taking the first derivative of the position:

${\displaystyle v^{2}={\dot {y}}^{2}-2\ell {\dot {y}}{\dot {\theta }}\sin \theta +\ell ^{2}{\dot {\theta }}^{2}.}$
File:Pendulum-plots.png
Plots for the inverted pendulum on an oscillatory base. The first plot shows the response of the pendulum on a slow oscillation, the second the response on a fast oscillation

The Lagrangian for this system can be written as:

${\displaystyle L={\frac {1}{2}}m\left({\dot {y}}^{2}-2\ell {\dot {y}}{\dot {\theta }}\sin \theta +\ell ^{2}{\dot {\theta }}^{2}\right)-mg\left(y+\ell \cos \theta \right)}$

and the equation of motion follows from:

${\displaystyle {\mathrm {d} \over \mathrm {d} t}{\partial {L} \over \partial {\dot {\theta }}}-{\partial {L} \over \partial \theta }=0}$

resulting in:

${\displaystyle \ell {\ddot {\theta }}-{\ddot {y}}\sin \theta =g\sin \theta .}$

If y represents a simple harmonic motion, ${\displaystyle y=A\sin \omega t}$, the following differential equation is:

${\displaystyle {\ddot {\theta }}-{g \over \ell }\sin \theta =-{A \over \ell }\omega ^{2}\sin \omega t\sin \theta .}$

This equation does not have elementary closed-form systems, but can be explored in a variety of ways. It is closely approximated by the Mathieu equation, for instance, when the amplitude of oscillations are small. Analyses show that the pendulum stays upright for fast oscillations. The first plot shows that when ${\displaystyle y}$ is a slow oscillation, the pendulum quickly falls over when disturbed from the upright position. The angle ${\displaystyle \theta }$ exceeds 90° after a short time, which means the pendulum has fallen on the ground.
If ${\displaystyle y}$ is a fast oscillation the pendulum can be kept stable around the vertical position. The second plot shows that when disturbed from the vertical position, the pendulum now starts an oscillation around the vertical position (${\displaystyle \theta =0}$). The deviation from the vertical position stays small, and the pendulum doesn't fall over.

## Types of inverted pendulums

Achieving stability of an inverted pendulum has become a common engineering challenge for researchers.[2] There are different variations of the inverted pendulum on a cart ranging from a rod on a cart to a multiple segmented inverted pendulum on a cart. Another variation places the inverted pendulum's rod or segmented rod on the end of a rotating assembly. In both, (the cart and rotating system) the inverted pendulum can only fall in a plane. The inverted pendulums in these projects can either be required to only maintain balance after an equilibrium position is achieved or be able to achieve equilibrium by itself. Another platform is a two wheeled balancing inverted pendulum. The two wheeled platform has the ability to spin on the spot offering a great deal of maneuverability.[3] Yet another variation balances on a single point. A spinning top, a unicycle, or an inverted pendulum atop a spherical ball all balance on a single point. As derived above the inverted pendulum can also be achieved by having a vertically oscillating base.

## Examples of inverted pendulums

There are many instances of the inverted pendulum model both man made and found in the natural world.

Arguably the most prevalent example of an inverted pendulum is a human being. A person with an upright body needs to make adjustments constantly to maintain balance whether standing, walking, or running.

Some simple examples include the metronome and balancing brooms or meter sticks by hand.

The inverted pendulum has been employed in various devices and trying to balance an inverted pendulum presents a unique engineering problem for researchers.[4] The inverted pendulum was a central component in the design of several early Seismometers due to its inherent instability resulting in a measurable response to any disturbance.[5]

The inverted pendulum model has been used in some forms of personal transportation devices. Two-wheeled wheel chairs and other two wheeled motorized vehicles can offer enhanced mobility for the driver.