inverted-pendulum.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2010,
3  * Florent Lamiraux
4  *
5  * CNRS
6  *
7  */
8 
9 #ifndef DG_TUTORIAL_INVERTED_PENDULUM_HH
10 #define DG_TUTORIAL_INVERTED_PENDULUM_HH
11 
12 #include <dynamic-graph/entity.h>
13 #include <dynamic-graph/signal-ptr.h>
14 #include <dynamic-graph/linear-algebra.h>
15 
16 namespace dynamicgraph {
17 namespace tutorial {
18 
72 class InvertedPendulum : public Entity {
73  public:
77  InvertedPendulum(const std::string& inName);
78 
80 
82  virtual const std::string& getClassName(void) const { return CLASS_NAME; }
83 
85  virtual std::string getDocString() const { return "Classical inverted pendulum dynamic model\n"; }
86 
88  void incr(double inTimeStep);
89 
97  void setCartMass(const double& inMass) { cartMass_ = inMass; }
98 
102  double getCartMass() const { return cartMass_; }
103 
107  void setPendulumMass(const double& inMass) { pendulumMass_ = inMass; }
108 
112  double getPendulumMass() const { return pendulumMass_; }
113 
117  void setPendulumLength(const double& inLength) { pendulumLength_ = inLength; }
118 
122  double getPendulumLength() const { return pendulumLength_; }
123 
128  protected:
129  /*
130  \brief Class name
131  */
132  static const std::string CLASS_NAME;
133 
134  private:
138  SignalPtr<double, int> forceSIN;
142  Signal< ::dynamicgraph::Vector, int> stateSOUT;
143 
145  double cartMass_;
147  double pendulumMass_;
149  double pendulumLength_;
151  double viscosity_;
152 
156  ::dynamicgraph::Vector computeDynamics(const ::dynamicgraph::Vector& inState, const double& inControl,
157  double inTimeStep);
158 };
159 } // namespace tutorial
160 } // namespace dynamicgraph
161 #endif
void incr(double inTimeStep)
Integrate equation of motion over time step given as input.
virtual std::string getDocString() const
Header documentation of the python class.
Definition: inverted-pendulum.hh:85
void setCartMass(const double &inMass)
Set the mass of the cart.
Definition: inverted-pendulum.hh:97
double getCartMass() const
Get the mass of the cart.
Definition: inverted-pendulum.hh:102
static const std::string CLASS_NAME
Definition: inverted-pendulum.hh:132
void setPendulumLength(const double &inLength)
Set the length of the cart.
Definition: inverted-pendulum.hh:117
InvertedPendulum(const std::string &inName)
Constructor by name.
void setPendulumMass(const double &inMass)
Set the mass of the cart.
Definition: inverted-pendulum.hh:107
Inverted Pendulum on a cart.
Definition: inverted-pendulum.hh:72
double getPendulumLength() const
Get the length of the pendulum.
Definition: inverted-pendulum.hh:122
virtual const std::string & getClassName(void) const
Each entity should provide the name of the class it belongs to.
Definition: inverted-pendulum.hh:82
Definition: feedback-controller.hh:15
double getPendulumMass() const
Get the mass of the pendulum.
Definition: inverted-pendulum.hh:112