This is an old revision of the document!
Table of Contents
Inverted Cart-Pendulum
The inverted cart-pendulum is a classic example of an underactuated, naturally unstable, nonlinear system. It is somewhat simple as the project is single input. However, it does involve unmatched nonlinearities which does involve more advanced concepts.
Equations of Motion
There are many instances or versions of the equations of motion for this classical problem, depending on the nature of the pendulum. Here, we try to include the dynamics of the more general configuration. The equations of motion are usually derived from the energy of the cart-pendulum pairing, \begin{equation} \begin{split} \mathcal{E} & = \frac 12 m_c \dot x^2 + \frac 12 m_p \left(\dot x + l \cos(\theta) \dot \theta \right)^2 + \frac 12 m_p l^2 \sin^2(\theta) \dot \theta^2 + \frac 12 J_p \dot \theta^2 + m_pgl(1 - \cos(\theta)) \\ & = \frac 12 (m_c + m_p) \dot x^2 + m_p l \cos(\theta) \dot x \dot \theta + \frac 12 (J_p + m_p l^2) \dot \theta^2 - m_pgl(1 - \cos(\theta)) \end{split} \end{equation} or the Lagrangian \begin{equation} \mathcal{L} = \frac 12 (m_c + m_p) \dot x^2 + m_p l \cos(\theta) \dot x \dot \theta + \frac 12 (J_p + m_p l^2) \dot \theta^2 + m_p g l(1 - \cos(\theta)), \end{equation} where $x$ describes the cart position and $\theta $ describes the pendulum angle. Working out the Euler-Lagrange equations and adding in dissipation (which is more of a Lagrange-d'Alembert derivation if I am not mistaken) leads to \begin{equation} \begin{bmatrix} m_c + m_p & m_p l\cos(\theta) \\ m_p l \cos(\theta) & J_p + m_p l^2 \end{bmatrix} \begin{bmatrix} \ddot x \\ \ddot \theta \end{bmatrix} - \begin{bmatrix} m_p l \dot \theta^2 \sin(\theta) \\ m_p g l \sin(\theta) \end{bmatrix} = \begin{bmatrix} u - \delta_\theta \dot x \\ -\delta_\theta \dot \theta \end{bmatrix} \end{equation} If the pendulum is a ball at the end of a think stick, then the inertia is negligible and $J_p$ can be ignored. If the pendulum is a dense rod with no ball at the end, then the inertia $J_p$ should not be ignored. The coefficients $delta_x$ and $\delta_\theta$ are coefficients of friction.
Given the prevalence of $m_p l$ almost everywhere, it is useful to factor the product out \begin{equation} \begin{bmatrix} \frac{m_c + m_p}{m_p l} & \cos(\theta) \\ \cos(\theta) & \frac{J_p}{m_p l} + l \end{bmatrix} \begin{bmatrix} \ddot x \\ \ddot \theta \end{bmatrix} - \begin{bmatrix} \dot \theta^2 \sin(\theta) \\ g \sin(\theta) \end{bmatrix} = \frac{1}{m_p l} \begin{bmatrix} u - \delta_x \dot x \\ -\delta_\theta \dot \theta \end{bmatrix} \end{equation} Simplifying things with a variable substitution, \begin{equation} \begin{bmatrix} M & \cos(\theta) \\ \cos(\theta) & L \end{bmatrix} \begin{bmatrix} \ddot x \\ \ddot \theta \end{bmatrix} = \begin{bmatrix} \dot \theta^2 \sin(\theta) - D_x \dot x + u \\ g \sin(\theta) -D_\theta \dot \theta \end{bmatrix} + \begin{bmatrix} b u \\ 0 \end{bmatrix} \end{equation} where \begin{equation} M = \frac{m_c + m_p}{m_p l},\ \ L = \frac{J_p}{m_p l} + l,\ \ b = \frac{1}{m_p l}, \ \ D_x = \frac{\delta_x}{m_p l},\ \ D_\theta = \frac{\delta_\theta}{m_p l}. \end{equation} The inverse of the matrix on the left is \begin{equation} \begin{bmatrix} M & \cos(\theta) \\ \cos(\theta) & L \end{bmatrix}^{-1} = \frac{1}{ML - \cos^2(\theta)} \begin{bmatrix} L & -\cos(\theta) \\ -\cos(\theta) & M \end{bmatrix} \end{equation} Applying to the derived equations thus far, \begin{equation} \begin{split} \begin{bmatrix} \ddot x \\ \ddot \theta \end{bmatrix} & = \frac{1}{ML - \cos^2{\theta}} \begin{bmatrix} L\sin(\theta) \dot \theta^2 - g \cos(\theta)\sin(\theta) - L D_x \dot x + D_\theta \cos(\theta) \dot \theta + L b u \\ -\cos(\theta)\sin(\theta) \dot \theta^2 + Mg\sin(\theta) + D_x \cos(\theta) \dot x - M D_\theta \dot \theta - b \cos(\theta) u \end{bmatrix} \\ & = \frac{1}{ML - \cos^2{\theta}} \begin{bmatrix} L\sin(\theta) \dot \theta^2 - g \cos(\theta)\sin(\theta) - L D_x \dot x + D \cos(\theta) \dot \theta \\ -\cos(\theta)\sin(\theta) \dot \theta^2 + Mg\sin(\theta) + D_x \cos(\theta) \dot x - M D \dot \theta \end{bmatrix} + \frac{1}{ML - \cos^2{\theta}} \begin{bmatrix} b L u \\ -b \cos(\theta) u \end{bmatrix} \end{split} \end{equation} Next, expose the structure of the control input as something like $\Lambda B u $ \begin{equation} \begin{bmatrix} \ddot x \\ \ddot \theta \end{bmatrix} = \frac{1}{ML - \cos^2{\theta}} \begin{bmatrix} L\sin(\theta) \dot \theta^2 - g \cos(\theta)\sin(\theta) - L D_x \dot x + D_\theta \cos(\theta) \dot \theta \\ -\cos(\theta)\sin(\theta) \dot \theta^2 + Mg\sin(\theta) + D_x \cos(\theta) \dot x - M D_\theta \dot \theta \end{bmatrix} + \frac{b}{ML - \cos^2{\theta}} \begin{bmatrix} L & 0 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} 1 \\ -\cos(\theta) \end{bmatrix} u \end{equation} The $\Lambda$ equivalent term is on the wrong side, but that's OK. It will have to do.
Parameters and Limits
Parameter | Value |
---|---|
$m_c$ | 0.5 kg |
$m_p$ | 0.1 kg |
$J_p$ | 0.006 kg m$^2$ |
$l$ | 0.3 m |
$\delta_\theta$ | 0.05 N m / rad s |
$\delta_x$ | 0.01 N m / s |
$g$ | 9.8 m / s$^2$ |
My units might be off for the friction, but the values are fine.
Activities
Step 1: Linear Controller
Linearized System: Pendulum Stabilization
You should notice that the control input affects both the cart and the pendulum, meaning that control of both simultaneously is not possible. One state coordinate will have to be uncontrolled or poorly controlled while the other will be nicely controlled. Which to do depends on the task at hand. For example, stabilizing the pendulum to the up position only will lead the cart to slowly drift away from the origin. Putting a small amount of control effort to return to the origin is possible, but it should not dominate the pendulum control. Stabilizing the location of the cart will lead to the pendulum falling.
Linearize the equations of motion of the system and provide the linearized equations. Start by specifying the control task to be stabilization of the pendulum and show that it can be stabilized from non-zero angular deflection values. Add in a less aggressive cart stabilization term to bring the cart back to the origin. Show that you can achieve both objectives for reasonable pendulum angle and cart position offsets.
Implement on the linear and nonlinear dynamics. Compare the outcomes.
Linearized System: Cart Trajectory Tracking
Derive a tracking controller for the system so that it can track a cart trajectory while maintaining the pendulum upright. You should be able to identify a reasonable trajectory to track. Implement on the linear and nonlinear dynamics. Compare the outcomes.
Adaptive System
Perturb the underlying parameters by 10-20% and compare the outcomes for the perturbed system to those from the unperturbed system. Quantify the additional control effort for the stabilization and trajectory tracking cases. Quantify the increase in tracking error for the trajectory tracking case. It is assumed you know how to compute the $L_2$ signal norms to quantify the control effort and state error.
Implement an adaptive system and compare the outcomes. Run the adaptive system twice. Once with the incorrect values, then once with the final adaptive coefficients from the first run as that initial adaptive coefficients for the second run. Compare the quantitative values of the incorrect run, the first adaptive run, and the second adaptive run (where compare means to provide the outcomes and to discuss them).
Step 2: Nonlinear Controller
TBD
Step 3: What
TBD