Skip to content
Snippets Groups Projects
Select Git revision
  • f8f8c621e9ffc2b1e84eaa9cfb11026f4f06001d
  • main default protected
  • rosification
  • refactoring
  • pp
  • mpc
  • realtimelogplotter
  • alv
  • gitlab_ci_podman
  • restructuring
  • viz_fix
11 results

create_dmp.py

Blame
  • modeling.tex 3.01 KiB
    \documentclass[12pt,a4paper]{report}
    \usepackage[utf8]{inputenc}
    \usepackage{amsmath}
    \usepackage{amsfonts}
    \usepackage{amssymb}
    \usepackage{tikz}
    \usetikzlibrary{patterns,angles,calc,quotes}
    
    \begin{document}
    
    \section*{Dynamics from Euler-Lagrange equations}
    
    \begin{figure}
    \begin{center}
    \begin{tikzpicture}[thick,>=latex]
        \begin{scope}
        %\draw[step=1cm,gray,very thin] (-1,-1) grid (4,5);
        \draw[->,thick] (-0.1,0) -- (4,0) node[anchor=west]{x}; 
        \draw[->,thick] (0,-0.1) -- (0,4.5) node[anchor=south]{y};
        \coordinate (cart) at (2,0);
        \coordinate (mass1) at ($(cart) + (104:4)$);
        \coordinate (mass2) at ($(cart) + (127:2.5)$);
        \coordinate (upp) at ($(cart) + (0,5)$);
        
        \draw[draw=black,fill=black] (cart) circle (.1cm) node (cart){};
        \draw[dashed] (cart.center) -- (upp) {};
        \node at (cart.south) [anchor=north] {$(x,0)$}; 
        
        \draw (cart.center) -- (mass1)  node[midway,xshift=2mm,yshift=5mm] (mid1) {};
        \draw[draw=black,fill=white] (mass1.center) circle (.15cm);
        \node at (mass1.north) [anchor=south,xshift=1mm,yshift=1mm] { $(x_1,y_1)$};
        \pic["$\theta_1$", draw=black, ->, angle eccentricity=1.15, angle radius=2.2cm]
        {angle = upp--cart--mass1};
        \draw (cart.center) -- (mass2) node[midway,xshift=1mm,yshift=3mm] (mid2) {};
        \draw[draw=black,fill=white] (mass2.center) circle (.15cm);
        \node at (mass2.north) [anchor=south,xshift=1mm,yshift=1mm] { $(x_2,y_2)$};
        %\pic [draw, ->,  angle eccentricity=1] {angle = upp--cart--mass2};
        \pic["$\theta_2\;$", draw=black, ->, angle eccentricity=1.25, angle radius=1.2cm]
        {angle = upp--cart--mass2};
        \end{scope}
    \end{tikzpicture}
    \label{fig01}
    \caption{Two pendulums on a moving cart}
    \end{center}
    \end{figure}
    Two pendulums with lengths $l_1$ and $l_2$ and masses $m_1$ and $m_2$ are mounted on a moving cart with mass $M$, see Figure~\ref{fig01}. Introduce $L = T - V$ where kinetick and potential energies are given by
    \begin{align}
    T &= \frac{1}{2}M\dot x^2 + \frac{1}{2}m_1(\dot x_1^2 + \dot y_1^2) + \frac{1}{2}m_2(\dot x_2^2 + \dot y_2^2)\\
    V &= m_1gl_1 c_1 + m_2gl_2c_2
    \end{align}
    where $c_i$ and $s_i$ and short for $\cos(\theta_i)$ and $\sin(\theta_i)$, $i=1,2$ respectively.
    Note that $x_i = x-l_is_i$ and $y_i = l_ic_i$. 
    The Euler-Lagrange equations
    \begin{align}
    \begin{cases}
    0=\dfrac{\partial L}{\partial \theta_i} - \dfrac{d}{dt}\left(\dfrac{\partial L}{\partial \dot{\theta}_i} \right), & i=1,2 \\
    F=\dfrac{\partial L}{\partial x} - \dfrac{d}{dt}\left(\dfrac{\partial L}{\partial \dot{x}} \right).
    \end{cases}
    \end{align}
    give after some calculations that
    \begin{align}
    l_i \ddot \theta_i &= gs_i + c_i \ddot x, \quad i=1,2\\
    F&=M\ddot x + m_1(\ddot x - l_1c_1\ddot \theta_1 + l_1s_1\dot{ \theta}_1^2) + m_2(\ddot x - l_2c_2\ddot \theta_2+ l_2s_2\dot{ \theta}_2^2).
    \end{align}
    For $m_i\approx 0$ and setting $u = \frac{F}{M}$, this simplifies to
    \begin{align}
    l_1 \ddot \theta_1 &= g\sin(\theta_1) + \cos(\theta_1) u\\
    l_2 \ddot \theta_2 &= g\sin(\theta_2) + \cos(\theta_2) u\\
    \ddot x &= u
    \end{align}
    
    \end{document}