Simple State Space Model of a Pendulum

This is the first post of a series that will build on simple pendulum dynamics to investigate different control laws and how model uncertainty affects the linear model approximation.

Pendulum diagram and Free Body Diagram

Pendulum Model

We will start by deriving the equations of motion for the simple pendulum shown below. The mass mm is suspended by a massless rod of length ll. The angle θ\theta is measured from the downward vertical with positive counter clockwise direction. The vectors ere_r and ete_t are the radial and tangential unit vectors respectively.

The first step is to draw a free body diagram showing all the forces acting on the mass. Using Newton’s Second Law to write the equations of motion for the mass (in radial coordinates).

Tmgcosθ=mr¨ermgsinθ=mr¨et \begin{alignedat}{1} T - mg\cos\theta &= m\ddot{r}_{e_r} \\ -mg\sin\theta &= m\ddot{r}_{e_t} \end{alignedat}

Assume the length of the rod is constant, then r˙\dot{r} and r¨\ddot{r} in the ere_r direction are both zero. Now we must find the tangential component r¨et\ddot{r}_{e_t}. To do this, we write position as a vector from the origin to the mass and take derivatives as follows:

r=ler+lθetr˙=lθ˙etr¨=lθ¨et \begin{alignedat}{1} r &= l{e_r} + l\theta{e_t} \\ \dot{r} &= l\dot{\theta}{e_t} \\ \ddot{r} &= l\ddot{\theta}{e_t} \end{alignedat}

Now we can substitute this into our dynamics equations and get the following:

mgcosθ=Tmgsinθ=mlθ¨ \begin{alignedat}{1} mg\cos\theta &= T \\ -mg\sin\theta &= ml\ddot{\theta} \\ \end{alignedat}

Simplifying the second equation and rearranging gives us the nonlinear ODE of the mass:

θ¨=glsinθ \begin{alignedat}{1} \ddot{\theta} = -\frac{g}{l}\sin\theta \end{alignedat}

State Space Form

To get the above equation into state space form, start by introducing a change of variable that will reduce the order of the ODE:

x1=θx2=θ˙ \begin{alignedat}{1} x_1 &= \theta \\ x_2 &= \dot{\theta} \end{alignedat}

Then take derivatives of these two substitutions and it follows:

x1˙=θ˙=x2x2˙=θ¨=glsinx1 \begin{alignedat}{1} \dot{x_1} = \dot{\theta} &= x_2 \\ \dot{x_2} = \ddot{\theta} &= -\frac{g}{l}\sin{x_1} \end{alignedat}

Jacobian

Calculate the Jacobian by first taking partial derivatives of the equations above with respect to each variable: x1x_1 and x2x_2.

J=fxx~=x[x2glsinx1]=[01glcosx10]x~\begin{alignedat}{1} J &= \frac{\partial\boldsymbol{f}}{\partial{\boldsymbol{x}}}\Big|_{\tilde{x}} \\ &=\tfrac{\partial}{\partial{x}} \begin{bmatrix} x_2 \\ -\frac{g}{l}\sin{x_1} \end{bmatrix} \\ &= \begin{bmatrix} 0 & 1 \\ -\frac{g}{l}\cos{x_1} & 0 \end{bmatrix} \Big|_{\tilde{x}} \\ \end{alignedat}

The state space model can be created by evaluating the matrix of partial derivatives at the nominal trajectory x~=(π,0)\tilde{x} = (\pi, 0), the result is the Jacobian.

A=xf(x~)=[01gl0] A = \frac{\partial}{\partial{x}}f(\tilde{x}) = \begin{bmatrix} 0 & 1 \\ -\frac{g}{l} & 0 \end{bmatrix}

State Space Form

The final linear model can now be represented as follows:

x˙=[01p0]x\dot{x} = \begin{bmatrix} 0 & 1 \\ -p & 0 \end{bmatrix} x wherep=glwhere \quad p = \frac{g}{l}

Stability

Looking at the matrix AA, we see it is full rank and controllable, however there is no control signal present in this example. We can check the stability of the nominal trajectory by looking at the eigenvalues of AA by solving for the roots of det(AIλ)det(A - I\lambda). Solving for λ\lambda results in λ=±p\lambda = \pm\sqrt{p}, with one positive real root indicating the system is unstable around x~=(π,0)\tilde{x} = (\pi, 0).

As a quick example, picking the equilibrium point of (0,0)(0, 0) (downward resting position) results in eigenvalues of λ=±ip\lambda = \pm{i}\sqrt{p} with no real part. Given this model, a perturbation of the pendulum from its downward resting point will continue to oscillate indefinitely.