# Dynamic model of an inverted pendulum (part 5)

This page is part of a serie of articles on how to write the model of an inverted pendulum. We strongly recommand to read the previous pages for a better understanding.

## Solving the system

Based on the previous equations, we can formulate $$\lambda_4$$ and $$\lambda_5$$:

$$\begin{array}{r c l} \lambda_4 &=& m_2.\ddot{x_2} \\ \lambda_5 &=& m_2.\ddot{y_2} + g.m_2 \\ \end{array}$$

The previous equations becomes:

$$\begin{array}{r c l} m_1.\ddot{x_1} &=& | \vec{F_t} | -m_2.\ddot{x_2} \\ I_2.\ddot{\Theta_2} &=& m_2.\ddot{x_2}.L.cos(\Theta_2) + (m_2.\ddot{y_2} + g.m_2).L.sin(\Theta_2) \end{array}$$

Thanks to the previous constraints on acceleration:

$$\begin{array}{r c l} m_1.\ddot{x_1} &=& | \vec{F_t} | -m_2.(\ddot{x_1} - L.\ddot{\Theta_2}.cos(\Theta_2) - L.\dot{\Theta_2}^2.sin(\Theta_2) ) \\ I_2.\ddot{\Theta_2} &=& m_2.(\ddot{x_1} - L.\ddot{\Theta_2}.cos(\Theta_2) + L.\dot{\Theta_2}^2.sin(\Theta_2) ).L.cos(\Theta_2) \\ &+& (m_2.(-L.\ddot{\Theta_2}.sin(\Theta_2) - L.\dot{\Theta_2}^2.cos(\Theta_2)) + g.m_2).L.sin(\Theta_2) \end{array}$$

Rewriting the previous equation gives us:

$$\begin{array}{r c l} (m_1+m_2).\ddot{x_1} &-& m_2.L.cos(\Theta_2).\ddot{\Theta_2} &=& | \vec{F_t} | - m_2.L.\dot{\Theta_2}^2.sin(\Theta_2) \\ -m_2.L.cos(\Theta_2).\ddot{x_1} &+& (I_2+ m_2.L^2).\ddot{\Theta_2} &=& m_2.g.L.sin(\Theta_2) \end{array}$$

and:

$$\begin{pmatrix} m_1+m_2 & - m_2.L.cos(\Theta_2) \\ -m_2.L.cos(\Theta_2) & (I_2+ m_2.L^2) \end{pmatrix} . \ddot{q} = \begin{pmatrix} | \vec{F_t} | - m_2.L.\dot{\Theta_2}^2.sin(\Theta_2) \ m_2.g.L.sin(\Theta_2) \end{pmatrix}$$

The general equation of the system is:

$$\ddot{q}=A^{-1}.B$$

where:

$$A=\begin{pmatrix} m_1+m_2 & - m_2.L.cos(\Theta_2) \\ -m_2.L.cos(\Theta_2) & (I_2+ m_2.L^2) \end{pmatrix}$$

$$B= \begin{pmatrix} | \vec{F_t} | - m_2.L.\dot{\Theta_2}^2.sin(\Theta_2) \ m_2.g.L.sin(\Theta_2) \end{pmatrix}$$
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 2, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://lucidar.me/en/control-theory/dynamic-model-of-an-inverted-pendulum-part-5/", "fetch_time": 1723423075000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2024-33/segments/1722641023489.70/warc/CC-MAIN-20240811235403-20240812025403-00482.warc.gz", "warc_record_offset": 292913630, "warc_record_length": 6657, "token_count": 856, "char_count": 1930, "score": 3.734375, "int_score": 4, "crawl": "CC-MAIN-2024-33", "snapshot_type": "latest", "language": "en", "language_score": 0.4878958463668823, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00018-of-00064.parquet"}