# Equations of Motion for Inverted Pendulum

1. Nov 5, 2008

### KLoux

I'm working on a simple simulation for an inverted pendulum mounted on a cart. I derived the equations of motion using Lagrangian dynamics, but I want to go back and add viscous damping terms to the linear motion of the cart, as well as the angular motion of the pendulum. I also want to add a driving force to the cart (my end goal is a non-linear controls simulation). Can I add these terms to the equation I initially derived, or do I need to re-derive the equations from the beginning? I think I know the answer to this, but I was hoping someone might have better advice - it's been a long time since I've done anything with Lagrange multipliers (or Lagrange dynamics at all, for that matter).

This is what I came up with for the conservative system: $$x$$ is the position of the cart, and $$\theta$$ is the angular position of the pendulum, with zero being straight up (vertical) from the cart. The cart has mass $$m_{c}$$ and the pendulum has mass $$m_{p}$$ and length $$l$$. The below equation is a combination of the equations for both generalized coordinates.

$$\stackrel{..}{x}(m_{c} + m_{p} - cos(\theta)) + \stackrel{..}{\theta}(m_{p}l cos(\theta) - l/4) + sin(\theta)(g/2 - m_{p}l\stackrel{.}{\theta}^{2})=0$$

My gut feeling is that I cannot simply add $$B_{c} \stackrel{.}{x} + B_{p} \stackrel{.}{\theta}$$ to the left hand side and set the equation equal to $$F(t)$$... Am I wrong?

-Kerry

2. Nov 5, 2008

### KLoux

OK, after some re-arranging and substitution, I get the following:

$$\stackrel{..}{x} = \frac{gtan(\theta)}{2} - \frac{l\stackrel{..}{\theta}}{4cos(\theta)}$$
$$\stackrel{..}{\theta} = \frac{-2sin(\theta)(g(m_{c} + m_{p}) + 2m_{p}l\stackrel{.}{\theta}^{2}cos(\theta))}{l(4m_{p}cos^{2}(\theta) - m_{c} - m_{p})}$$

I'm somewhat confident that I can add my damping and forcing terms to the $$\stackrel{..}{x}$$ equation, and the position of the cart will calculate correctly. I'm also somewhat confident that doing this will make the equation for $$\stackrel{..}{\theta}$$ incorrect, even if I don't add the rotational damping term to that equation. Similarly, adding the rotational damping will make the cart position calculation wrong. Since the pendulum position is affected by cart motion, the rotational damping term will also make the pendulum position calculation incorrect. Is this thought process right?

Thanks,

Kerry