Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
dynamicgraph::tutorial::InvertedPendulum Class Reference

Inverted Pendulum on a cart. More...

#include <inverted-pendulum.hh>

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

Public Member Functions

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...
 
 InvertedPendulum (const std::string &inName)
 Constructor by name. More...
 
 ~InvertedPendulum ()
 
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
virtual void display (std::ostream &os) const
 
std::ostream & displaySignalList (std::ostream &os) const
 
 Entity (const std::string &name)
 
const std::string & getCommandList () const
 
LoggerVerbosity getLoggerVerbosityLevel ()
 
LoggerVerbosity getLoggerVerbosityLevel ()
 
const std::string & getName () const
 
command::CommandgetNewStyleCommand (const std::string &cmdName)
 
CommandMap_t getNewStyleCommandMap ()
 
SignalBase< int > & getSignal (const std::string &signalName)
 
const SignalBase< int > & getSignal (const std::string &signalName) const
 
SignalMap getSignalMap () const
 
double getStreamPrintPeriod ()
 
double getStreamPrintPeriod ()
 
double getTimeSample ()
 
double getTimeSample ()
 
bool hasSignal (const std::string &signame) const
 
Loggerlogger ()
 
Logger const & logger () const
 
Loggerlogger ()
 
Logger const & logger () const
 
void sendMsg (const std::string &msg, MsgType t=MSG_TYPE_INFO, const std::string &lineId="")
 
void sendMsg (const std::string &msg, MsgType t=MSG_TYPE_INFO, const std::string &lineId="")
 
void setLoggerVerbosityLevel (LoggerVerbosity lv)
 
void setLoggerVerbosityLevel (LoggerVerbosity lv)
 
bool setStreamPrintPeriod (double t)
 
bool setStreamPrintPeriod (double t)
 
bool setTimeSample (double t)
 
bool setTimeSample (double t)
 
virtual SignalBase< int > * test ()
 
virtual void test2 (SignalBase< int > *)
 
virtual std::ostream & writeCompletionList (std::ostream &os) const
 
virtual std::ostream & writeGraph (std::ostream &os) const
 
virtual ~Entity ()
 

Static Public Attributes

static const std::string CLASS_NAME
 

Private Member Functions

::dynamicgraph::Vector computeDynamics (const ::dynamicgraph::Vector &inState, const double &inControl, double inTimeStep)
 Compute the evolution of the state of the pendulum. More...
 

Private Attributes

double cartMass_
 Mass of the cart. More...
 
SignalPtr< double, int > forceSIN
 Input force acting on the inverted pendulum. More...
 
double pendulumLength_
 Length of the pendulum. More...
 
double pendulumMass_
 Mass of the pendulum. More...
 
Signal< ::dynamicgraph::Vector, int > stateSOUT
 State of the inverted pendulum. More...
 
double viscosity_
 Viscosity coefficient. More...
 

Additional Inherited Members

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

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

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.

Definition at line 72 of file inverted-pendulum.hh.

Constructor & Destructor Documentation

◆ InvertedPendulum()

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

Constructor by name.

Definition at line 29 of file inverted-pendulum.cpp.

◆ ~InvertedPendulum()

InvertedPendulum::~InvertedPendulum ( )

Definition at line 115 of file inverted-pendulum.cpp.

Member Function Documentation

◆ computeDynamics()

Vector InvertedPendulum::computeDynamics ( const ::dynamicgraph::Vector inState,
const double &  inControl,
double  inTimeStep 
)
private

Compute the evolution of the state of the pendulum.

Definition at line 117 of file inverted-pendulum.cpp.

◆ getCartMass()

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

Get the mass of the cart.

Definition at line 104 of file inverted-pendulum.hh.

◆ getClassName()

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

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

Reimplemented from dynamicgraph::Entity.

Definition at line 82 of file inverted-pendulum.hh.

◆ getDocString()

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

Header documentation of the python class.

Reimplemented from dynamicgraph::Entity.

Definition at line 85 of file inverted-pendulum.hh.

◆ getPendulumLength()

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

Get the length of the pendulum.

Definition at line 124 of file inverted-pendulum.hh.

◆ getPendulumMass()

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

Get the mass of the pendulum.

Definition at line 114 of file inverted-pendulum.hh.

◆ incr()

void InvertedPendulum::incr ( double  inTimeStep)

Integrate equation of motion over time step given as input.

Definition at line 160 of file inverted-pendulum.cpp.

◆ setCartMass()

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

Set the mass of the cart.

Definition at line 99 of file inverted-pendulum.hh.

◆ setPendulumLength()

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

Set the length of the cart.

Definition at line 119 of file inverted-pendulum.hh.

◆ setPendulumMass()

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

Set the mass of the cart.

Definition at line 109 of file inverted-pendulum.hh.

Member Data Documentation

◆ cartMass_

double dynamicgraph::tutorial::InvertedPendulum::cartMass_
private

Mass of the cart.

Definition at line 147 of file inverted-pendulum.hh.

◆ CLASS_NAME

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

Definition at line 134 of file inverted-pendulum.hh.

◆ forceSIN

SignalPtr<double, int> dynamicgraph::tutorial::InvertedPendulum::forceSIN
private

Input force acting on the inverted pendulum.

Definition at line 140 of file inverted-pendulum.hh.

◆ pendulumLength_

double dynamicgraph::tutorial::InvertedPendulum::pendulumLength_
private

Length of the pendulum.

Definition at line 151 of file inverted-pendulum.hh.

◆ pendulumMass_

double dynamicgraph::tutorial::InvertedPendulum::pendulumMass_
private

Mass of the pendulum.

Definition at line 149 of file inverted-pendulum.hh.

◆ stateSOUT

Signal< ::dynamicgraph::Vector, int> dynamicgraph::tutorial::InvertedPendulum::stateSOUT
private

State of the inverted pendulum.

Definition at line 144 of file inverted-pendulum.hh.

◆ viscosity_

double dynamicgraph::tutorial::InvertedPendulum::viscosity_
private

Viscosity coefficient.

Definition at line 153 of file inverted-pendulum.hh.


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


dynamic-graph-tutorial
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Sun Jun 25 2023 02:37:04