# Constrained Second Angle Double Pendulum

If I am trying to model the dynamics of a double-pendulum (on a horizontal plane without the effects of gravity), in which the second angle is constrained to range between values of [-10 deg, 10 deg], how would I derive the equations of motion? I'm having trouble identifying whether I would use some method involving solving the Lagrangian with holonomic or non-holonomic constraints.

• What would constrain a real pendulum to that range? Resiliency of the material (how hard/soft/elastic it is) plays a big role in what the outcome of the simulation would be. Is the impulse at the end stops a large force over a short duration or vice-versa? Do you care how a real system would behave? Jan 18 '17 at 16:28

The derivation of double pendulum system is indeed trivial but tedious because of computing some derivatives. The first step is to tackle the problem from a geometric perspective. My drawing of double pendulum is shown in the following picture:

From the preceding figure, we can write down some equations. The derivatives of these equations are needed subsequently, therefore, we compute them as well. The independent time variable is omitted for the sake of simplicity. $$\begin{array} xx_1 = a_1 \sin\theta, & \qquad y_1 = -a_1 \cos\theta, \\ \dot{x}_1 = a_1 \dot{\theta} \cos\theta, & \qquad \dot{y}_1 = a_1 \dot{\theta} \sin\theta, \\ %#################################################### x_2 = x_1 + a_2 \sin\phi, & \qquad y_2 = y_1 - a_2 \cos\phi, \\ \dot{x}_2 = \dot{x}_1 + a_2 \dot{\phi} \cos\phi, & \qquad \dot{y}_2 = \dot{y}_1 + a_2 \dot{\phi} \sin\phi, \end{array}$$ To derive the dynamics equation of the system, I will use the Lagrangian approach. We need the kinetic and potential energies of masses. Let's start off with the kinetic energy.

The kinetic energy of $m_1$ is computed as follows:

\begin{align} \mathcal{K}_1 &= \frac{1}{2}m_1 v^2_1 \\ &= \frac{1}{2}m_1 (\dot{x}^{2}_1+\dot{y}^{2}_1) \\ &= \frac{1}{2}m_1 (a^{2}_1 \dot{\theta}^{2} \cos^{2}\theta+a^{2}_1 \dot{\theta}^{2} \sin^{2}\theta) \\ &= \frac{1}{2}m_1 [a^{2}_1 \dot{\theta}^{2} (\cos^{2}\theta+ \sin^{2}\theta)] \\ &= \frac{1}{2}m_1 a^{2}_1 \dot{\theta}^{2} \end{align}

The kinetic energy of $m_2$ is computed as follows:

\begin{align} \mathcal{K}_2 &= \frac{1}{2}m_2 v^2_2 \\ &= \frac{1}{2}m_2 (\dot{x}^{2}_2+\dot{y}^{2}_2) \\ &= \frac{1}{2}m_2 [(\dot{x}_1 + a_2 \dot{\phi} \cos\phi)^{2}+(\dot{y}_1 + a_2 \dot{\phi} \sin\phi)^{2}] \\ %=============================================== &= \frac{1}{2}m_2 [(\dot{x}^{2}_1 + 2a_2 \dot{\phi} \cos\phi \dot{x}_1 + a^{2}_2 \dot{\phi}^{2} \cos^{2}\phi) + \\ & \qquad \ \ \ \quad (\dot{y}^{2}_1 + 2a_2 \dot{\phi} \sin\phi \dot{y}_1 + a^{2}_2 \dot{\phi}^{2} \sin^{2}\phi)] \\ %=============================================== &= \frac{1}{2}m_2 [(a^{2}_1 \dot{\theta}^{2} \cos^{2}\theta + 2a_2 \dot{\phi} \cos\phi a_1 \dot{\theta} \cos\theta + a^{2}_2 \dot{\phi}^{2} \cos^{2}\phi) + \\ & \qquad \ \ \ \quad (a^{2}_1 \dot{\theta}^{2} \sin^{2}\theta + 2a_2 \dot{\phi} \sin\phi a_1 \dot{\theta} \sin\theta + a^{2}_2 \dot{\phi}^{2} \sin^{2}\phi)] \\ %=============================================== &= \frac{1}{2}m_2 [a^{2}_1 \dot{\theta}^{2} [\cos^{2}\theta+\sin^{2}\theta] + 2a_2 a_1 \dot{\phi} \dot{\theta}[ \cos\theta \cos\phi + \sin\theta \sin\phi ] + \\ & \qquad \qquad a^{2}_2 \dot{\phi}^{2}[ \cos^{2}\phi+\sin^{2}\phi] ] \\ %=============================================== &= \frac{1}{2}m_2 [a^{2}_1 \dot{\theta}^{2} + 2a_2 a_1 \dot{\phi} \dot{\theta} \cos(\theta-\phi) + a^{2}_2 \dot{\phi}^{2} ] \end{align} The kinetic energy of the whole system is then: \begin{align} \mathcal{K} &= \mathcal{K}_1 + \mathcal{K}_2 \\ &= \frac{1}{2}m_1 a^{2}_1 \dot{\theta}^{2} + \frac{1}{2}m_2 [a^{2}_1 \dot{\theta}^{2} + 2a_2 a_1 \dot{\phi} \dot{\theta} \cos(\theta-\phi) + a^{2}_2 \dot{\phi}^{2} ] \end{align}

The second step is to compute the potential energy of the whole system. We start off with the potential energy of $m_1$ which is computed as follows: \begin{align} \mathcal{P}_1 &= m_1 y_1 g \\ &= m_1(-a_1 \cos\theta)g \\ &= -a_1 m_1 g \cos\theta \end{align}

The potential energy of $m_2$ is computed as follows: \begin{align} \mathcal{P}_2 &= m_2 y_2 g \\ &= m_2(y_1 - a_2 \cos\phi)g \\ &= m_2(-a_1 \cos\theta - a_2 \cos\phi)g \\ &= -a_1 m_2 g \cos\theta - a_2 m_2 g \cos\phi \end{align}

The potential energy of the whole system is then: \begin{align} \mathcal{P} &= \mathcal{P}_1 + \mathcal{P}_2 \\ &= -a_1 m_1 g \cos\theta -a_1 m_2 g \cos\theta - a_2 m_2 g \cos\phi \end{align}

To construct the Lagrangian equation, we take the difference between the kinetic $\mathcal{K}$ and potential $\mathcal{P}$ energies of the whole system, hence:

\begin{align} \mathcal{L} &= \mathcal{K} - \mathcal{P} \end{align}

At this moment, we will compute dynamics equation of the double pendulum system. Remember this system has two degrees of freedom, therefore, we need two differential equations to describe the motion of the system. Let's start off with the first equation (i.e. the equation for $\theta$). This can be done by determining the following equations: $$\frac{\partial \mathcal{L}}{\partial \dot{\theta} }, \ \ \frac{d}{dt} \left( \frac{\partial \mathcal{L}}{\partial \dot{\theta} } \right) \text{and} \frac{\partial \mathcal{L}}{\partial \theta}.$$ For the second equation of dynamics equation, we do the following: $$\frac{\partial \mathcal{L}}{\partial \dot{\phi} }, \ \ \frac{d}{dt} \left( \frac{\partial \mathcal{L}}{\partial \dot{\phi} } \right) \text{and} \frac{\partial \mathcal{L}}{\partial \phi}.$$

I will leave the rest as an exercise. Once you came up with the dynamics equation, you can use some controllers to limit the range of the second pendulum.

I don't think you need to worry about the constraint. You can derive the non linear equation using Lagrangian. Once you have the non linear model, you will have to linearize it at the equilibrium point which is simply valid only for angle around 0 deg. This condition is much more strict then your mechanical limitations. Therefore you don't need to consider the limitations that you have mentioned. And I assume you will modeling the friction as a viscous damper which is a linear model. This assumption makes the system holonomic.

Here I assume that you will use linear model to control the system. However, if you want to use non linear control then you will probably need to worry about the constraints.

At first it is important to understand the double pendulum problem as a hybrid system. To solve these kinds of task a combination of a finite state machine plus mathematical equations are the best way. On page 26 of On-Line Symbolic Constraint Embedding for Simulation of Hybrid Dynamical Systems is a automaton given which consists of three modes: double-pendulum, slider-crank and stuck. Additional sourcecode in Matlab are not given, but this paper is the way to go.

A sourcecode for a simpler version (the single pendulum problem) is the following:

def fsmstart(self):
# strategy: if pole is on 180 Degree, move in other direction
for i in range(10000):
a1=self.angPole()
pygame.time.wait(50)
a2=self.angPole()
middle=False
if a1>160 and a1<200: middle=True
direction="left"
if a2<a1: direction="right"
if middle==True:
print direction
if direction=="right": self.setspeed(0, .7) # move left
if direction=="left": self.setspeed(0, -.7) # move right
pygame.time.wait(500)
self.setspeed(0, 0)
def angPole(self):
return self.getangle(4)