dynamicgraph::tutorial::InvertedPendulum Class Reference

Inverted Pendulum on a cart. More...

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

Inheritance diagram for dynamicgraph::tutorial::InvertedPendulum:
[legend]
Collaboration diagram for dynamicgraph::tutorial::InvertedPendulum:
[legend]

Public Member Functions

 InvertedPendulum (const std::string &inName)
 Constructor by name. More...
 
 ~InvertedPendulum ()
 
virtual const std::string & getClassName (void) const
 Each entity should provide the name of the class it belongs to. More...
 
virtual std::string getDocString () const
 Header documentation of the python class. More...
 
void incr (double inTimeStep)
 Integrate equation of motion over time step given as input. More...
 
Parameters
void setCartMass (const double &inMass)
 Set the mass of the cart. More...
 
double getCartMass () const
 Get the mass of the cart. More...
 
void setPendulumMass (const double &inMass)
 Set the mass of the cart. More...
 
double getPendulumMass () const
 Get the mass of the pendulum. More...
 
void setPendulumLength (const double &inLength)
 Set the length of the cart. More...
 
double getPendulumLength () const
 Get the length of the pendulum. More...
 
- Public Member Functions inherited from dynamicgraph::Entity
 Entity (const std::string &name)
 
virtual ~Entity ()
 
const std::string & getName () const
 
bool hasSignal (const std::string &signame) const
 
SignalBase< int > & getSignal (const std::string &signalName)
 
const SignalBase< int > & getSignal (const std::string &signalName) const
 
std::ostream & displaySignalList (std::ostream &os) const
 
virtual std::ostream & writeGraph (std::ostream &os) const
 
virtual std::ostream & writeCompletionList (std::ostream &os) const
 
virtual void display (std::ostream &os) const
 
virtual void commandLine (const std::string &cmdLine, std::istringstream &cmdArgs, std::ostream &os)
 
virtual SignalBase< int > * test ()
 
virtual void test2 (SignalBase< int > *)
 
const std::string & getCommandList () const
 
CommandMap_t getNewStyleCommandMap ()
 
command::CommandgetNewStyleCommand (const std::string &cmdName)
 
SignalMap getSignalMap () const
 

Static Protected Attributes

static const std::string CLASS_NAME
 
  More...
 

Additional Inherited Members

- Public Types inherited from dynamicgraph::Entity
typedef std::map< std::string, SignalBase< int > * > SignalMap
 
typedef std::map< const std::string, command::Command * > CommandMap_t
 
- Protected Member Functions inherited from dynamicgraph::Entity
void addCommand (const std::string &name, command::Command *command)
 
void entityRegistration ()
 
void entityDeregistration ()
 
void signalRegistration (const SignalArray< int > &signals)
 
void signalDeregistration (const std::string &name)
 
- Protected Attributes inherited from dynamicgraph::Entity
std::string name
 
SignalMap signalMap
 
CommandMap_t commandMap
 

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

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

Constructor by name.

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

Member Function Documentation

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

Get the mass of the cart.

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

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

Implements dynamicgraph::Entity.

References CLASS_NAME.

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

Header documentation of the python class.

Reimplemented from dynamicgraph::Entity.

References incr().

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

Get the length of the pendulum.

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

Get the mass of the pendulum.

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

Integrate equation of motion over time step given as input.

Referenced by getDocString().

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

Set the mass of the cart.

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

Set the length of the cart.

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

Set the mass of the cart.

Member Data Documentation

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

 

Referenced by getClassName().