Loading...
Searching...
No Matches
dynamicgraph::tutorial::InvertedPendulum Class Reference

Inverted Pendulum on a cart. More...

#include <dynamic-graph/tutorial/inverted-pendulum.hh>

Inheritance diagram for dynamicgraph::tutorial::InvertedPendulum:
Collaboration diagram for dynamicgraph::tutorial::InvertedPendulum:

Public Member Functions

 InvertedPendulum (const std::string &inName)
 Constructor by name.
 
 ~InvertedPendulum ()
 
virtual const std::string & getClassName (void) const
 Each entity should provide the name of the class it belongs to.
 
virtual std::string getDocString () const
 Header documentation of the python class.
 
void incr (double inTimeStep)
 Integrate equation of motion over time step given as input.
 
Parameters
void setCartMass (const double &inMass)
 Set the mass of the cart.
 
double getCartMass () const
 Get the mass of the cart.
 
void setPendulumMass (const double &inMass)
 Set the mass of the cart.
 
double getPendulumMass () const
 Get the mass of the pendulum.
 
void setPendulumLength (const double &inLength)
 Set the length of the cart.
 
double getPendulumLength () const
 Get the length of the pendulum.
 

Static Public Attributes

static const std::string CLASS_NAME
 

Detailed Description

Inverted Pendulum on a cart.

This class represents the classical inverted pendulum on a cart. The equation of motion is:

\begin{eqnarray*}
\left ( M + m \right ) \ddot x - m l \ddot \theta \cos \theta + m l \dot
\theta^2 \sin \theta &=& F\\ m l (-g \sin \theta - \ddot x \cos \theta + l
\ddot \theta) &=& 0 \end{eqnarray*}

where

  • the state is a vector of dimension 4 $(x,\theta,\dot{x},\dot{\theta})$ represented by signal stateSOUT,
  • $x$ is the position of the cart on an horizontal axis, $\theta$ is the angle of the pendulum with respect to the vertical axis,
  • the input is a vector of dimension 1 $(F)$ reprensented by signal forceSIN,
  • m, M and l are respectively the mass of the pendulum, the mass of the cart and the length of the pendulum.

A more natural form of the above equation for roboticists is

\[
\textbf{M}(\textbf{q})\ddot{\textbf{q}} +
\textbf{N}(\textbf{q},\dot{\textbf{q}})\dot{\textbf{q}} +
\textbf{G}(\textbf{q}) = \textbf{F}
\]

where

\begin{eqnarray*}
\textbf{q} &=& (x, \theta) \\
\textbf{M}(\textbf{q}) &=& \left( \begin{array}{cc}
M + m & -m\ l\ \cos\theta \\
-m\ l\ \cos\theta & m\ l^2 \end{array}\right) \\
\textbf{N}(\textbf{q},\dot{\textbf{q}}) &=& \left( \begin{array}{cc}
0 & m\ l\ \dot{\theta} \sin\theta \\
0 & 0 \end{array}\right)\\
\textbf{G}(\textbf{q}) &=& \left( \begin{array}{c}
0 \\ -m\ l\ g\ \sin\theta \end{array}\right)\\
\textbf{F} &=& \left( \begin{array}{c}
F \\ 0 \end{array}\right)
\end{eqnarray*}

In order to make the system intrinsically stable, we add some viscosity by rewriting:

\begin{eqnarray*}
\textbf{N}(\textbf{q},\dot{\textbf{q}}) &=& \left( \begin{array}{cc}
\lambda & m\ l\ \dot{\theta} \sin\theta\\
0 & \lambda \end{array}\right)
\end{eqnarray*}

where $\lambda$ is a positive coefficient.

Constructor & Destructor Documentation

◆ InvertedPendulum()

dynamicgraph::tutorial::InvertedPendulum::InvertedPendulum ( const std::string &  inName)

Constructor by name.

◆ ~InvertedPendulum()

dynamicgraph::tutorial::InvertedPendulum::~InvertedPendulum ( )

Member Function Documentation

◆ getCartMass()

double dynamicgraph::tutorial::InvertedPendulum::getCartMass ( ) const
inline

Get the mass of the cart.

◆ getClassName()

virtual const std::string & dynamicgraph::tutorial::InvertedPendulum::getClassName ( void  ) const
inlinevirtual

Each entity should provide the name of the class it belongs to.

◆ getDocString()

virtual std::string dynamicgraph::tutorial::InvertedPendulum::getDocString ( ) const
inlinevirtual

Header documentation of the python class.

◆ getPendulumLength()

double dynamicgraph::tutorial::InvertedPendulum::getPendulumLength ( ) const
inline

Get the length of the pendulum.

◆ getPendulumMass()

double dynamicgraph::tutorial::InvertedPendulum::getPendulumMass ( ) const
inline

Get the mass of the pendulum.

◆ incr()

void dynamicgraph::tutorial::InvertedPendulum::incr ( double  inTimeStep)

Integrate equation of motion over time step given as input.

◆ setCartMass()

void dynamicgraph::tutorial::InvertedPendulum::setCartMass ( const double &  inMass)
inline

Set the mass of the cart.

◆ setPendulumLength()

void dynamicgraph::tutorial::InvertedPendulum::setPendulumLength ( const double &  inLength)
inline

Set the length of the cart.

◆ setPendulumMass()

void dynamicgraph::tutorial::InvertedPendulum::setPendulumMass ( const double &  inMass)
inline

Set the mass of the cart.

Member Data Documentation

◆ CLASS_NAME

const std::string dynamicgraph::tutorial::InvertedPendulum::CLASS_NAME
static

The documentation for this class was generated from the following file: