sot-core  4.11.8
Hierarchical task solver plug-in for dynamic-graph.
device.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2010,
3  * Florent Lamiraux
4  *
5  * CNRS
6  *
7  */
8 
9 #ifndef SOT_DEVICE_HH
10 #define SOT_DEVICE_HH
11 
12 /* --------------------------------------------------------------------- */
13 /* --- INCLUDE --------------------------------------------------------- */
14 /* --------------------------------------------------------------------- */
15 
16 #include <pinocchio/fwd.hpp>
17 
18 /* -- MaaL --- */
19 #include <dynamic-graph/linear-algebra.h>
20 
21 /* SOT */
22 #include <dynamic-graph/all-signals.h>
23 #include <dynamic-graph/entity.h>
24 
26 
27 #include "sot/core/api.hh"
29 
30 namespace dynamicgraph {
31 namespace sot {
32 
39 };
40 
41 const std::string ControlInput_s[] = {"noInteg", "oneInteg", "twoInteg"};
42 
43 /* --------------------------------------------------------------------- */
44 /* --- CLASS ----------------------------------------------------------- */
45 /* --------------------------------------------------------------------- */
46 
47 class SOT_CORE_EXPORT Device : public Entity {
48  public:
49  static const std::string CLASS_NAME;
50  virtual const std::string &getClassName(void) const { return CLASS_NAME; }
51 
56  FORCE_SIGNAL_LARM
57  };
58 
59  protected:
60  dynamicgraph::Vector state_;
61  dynamicgraph::Vector velocity_;
63  dynamicgraph::Vector vel_control_;
65  bool withForceSignals[4];
68  double timestep_;
69 
74  Vector upperTorque_;
77  Vector lowerTorque_;
79  public:
80  /* --- CONSTRUCTION --- */
81  Device(const std::string &name);
82  /* --- DESTRUCTION --- */
83  virtual ~Device();
84 
85  virtual void setStateSize(const unsigned int &size);
86  virtual void setState(const dynamicgraph::Vector &st);
87  void setVelocitySize(const unsigned int &size);
88  virtual void setVelocity(const dynamicgraph::Vector &vel);
89  virtual void setSecondOrderIntegration();
90  virtual void setNoIntegration();
91  virtual void setControlInputType(const std::string &cit);
92  virtual void increment(const double &dt = 5e-2);
93 
96  void setSanityCheck(const bool &enableCheck);
97  void setPositionBounds(const Vector &lower, const Vector &upper);
98  void setVelocityBounds(const Vector &lower, const Vector &upper);
99  void setTorqueBounds(const Vector &lower, const Vector &upper);
101 
102  PeriodicCall &periodicCallBefore() { return periodicCallBefore_; }
103  PeriodicCall &periodicCallAfter() { return periodicCallAfter_; }
104 
105  public: /* --- DISPLAY --- */
106  virtual void display(std::ostream &os) const;
107  virtual void cmdDisplay();
108  SOT_CORE_EXPORT friend std::ostream &operator<<(std::ostream &os,
109  const Device &r) {
110  r.display(os);
111  return os;
112  }
113 
114  public: /* --- SIGNALS --- */
115  dynamicgraph::SignalPtr<dynamicgraph::Vector, int> controlSIN;
116  dynamicgraph::SignalPtr<dynamicgraph::Vector, int> attitudeSIN;
117  dynamicgraph::SignalPtr<dynamicgraph::Vector, int> zmpSIN;
118 
121  dynamicgraph::Signal<dynamicgraph::Vector, int> stateSOUT;
122  dynamicgraph::Signal<dynamicgraph::Vector, int> velocitySOUT;
123  dynamicgraph::Signal<MatrixRotation, int> attitudeSOUT;
125  dynamicgraph::Signal<dynamicgraph::Vector, int> motorcontrolSOUT;
126  dynamicgraph::Signal<dynamicgraph::Vector, int> previousControlSOUT;
128  dynamicgraph::Signal<dynamicgraph::Vector, int> ZMPPreviousControllerSOUT;
130 
137  dynamicgraph::Signal<dynamicgraph::Vector, int> robotState_;
139  dynamicgraph::Signal<dynamicgraph::Vector, int> robotVelocity_;
141  dynamicgraph::Signal<dynamicgraph::Vector, int> *forcesSOUT[4];
144  dynamicgraph::Signal<dynamicgraph::Vector, int> pseudoTorqueSOUT;
146 
147  protected:
149  void integrateRollPitchYaw(dynamicgraph::Vector &state,
150  const dynamicgraph::Vector &control, double dt);
165  virtual void integrate(const double &dt);
166 
167  protected:
170 
171  public:
172  virtual void setRoot(const dynamicgraph::Matrix &root);
173 
174  virtual void setRoot(const MatrixHomogeneous &worldMwaist);
175 
176  private:
177  // Intermediate variable to avoid dynamic allocation
178  dynamicgraph::Vector forceZero6;
179 };
180 } // namespace sot
181 } // namespace dynamicgraph
182 
183 #endif /* #ifndef SOT_DEVICE_HH */
#define SOT_CORE_EXPORT
Definition: api.hh:20
Definition: device.hh:47
virtual void integrate(const double &dt)
dynamicgraph::Vector vel_control_
Definition: device.hh:63
PeriodicCall & periodicCallBefore()
Definition: device.hh:102
virtual void setNoIntegration()
virtual void increment(const double &dt=5e-2)
dynamicgraph::Signal< dynamicgraph::Vector, int > pseudoTorqueSOUT
Definition: device.hh:144
dynamicgraph::SignalPtr< dynamicgraph::Vector, int > zmpSIN
Definition: device.hh:117
dynamicgraph::Signal< dynamicgraph::Vector, int > motorcontrolSOUT
The current state of the robot from the command viewpoint.
Definition: device.hh:125
virtual void cmdDisplay()
virtual void setSecondOrderIntegration()
virtual void display(std::ostream &os) const
Vector upperPosition_
Definition: device.hh:72
Vector upperTorque_
Definition: device.hh:74
const MatrixHomogeneous & freeFlyerPose() const
Get freeflyer pose.
Device(const std::string &name)
ControlInput controlInputType_
Definition: device.hh:64
virtual void setRoot(const dynamicgraph::Matrix &root)
dynamicgraph::Signal< dynamicgraph::Vector, int > robotState_
Definition: device.hh:137
static const std::string CLASS_NAME
Definition: device.hh:49
MatrixHomogeneous ffPose_
Store Position of free flyer joint.
Definition: device.hh:152
void integrateRollPitchYaw(dynamicgraph::Vector &state, const dynamicgraph::Vector &control, double dt)
Compute roll pitch yaw angles of freeflyer joint.
virtual void setStateSize(const unsigned int &size)
void setSanityCheck(const bool &enableCheck)
virtual void setVelocity(const dynamicgraph::Vector &vel)
PeriodicCall periodicCallAfter_
Definition: device.hh:67
Vector lowerPosition_
Definition: device.hh:75
bool sanityCheck_
Definition: device.hh:62
void setVelocityBounds(const Vector &lower, const Vector &upper)
virtual void setState(const dynamicgraph::Vector &st)
virtual void setControlInputType(const std::string &cit)
dynamicgraph::Signal< dynamicgraph::Vector, int > robotVelocity_
Motor velocities.
Definition: device.hh:139
virtual void setRoot(const MatrixHomogeneous &worldMwaist)
void setTorqueBounds(const Vector &lower, const Vector &upper)
dynamicgraph::SignalPtr< dynamicgraph::Vector, int > attitudeSIN
Definition: device.hh:116
dynamicgraph::Signal< dynamicgraph::Vector, int > ZMPPreviousControllerSOUT
The ZMP reference send by the previous controller.
Definition: device.hh:128
dynamicgraph::Vector velocity_
Definition: device.hh:61
dynamicgraph::Signal< dynamicgraph::Vector, int > previousControlSOUT
Definition: device.hh:126
Vector upperVelocity_
Definition: device.hh:73
SOT_CORE_EXPORT friend std::ostream & operator<<(std::ostream &os, const Device &r)
Definition: device.hh:108
dynamicgraph::Signal< MatrixRotation, int > attitudeSOUT
Definition: device.hh:123
virtual const std::string & getClassName(void) const
Definition: device.hh:50
void setVelocitySize(const unsigned int &size)
dynamicgraph::SignalPtr< dynamicgraph::Vector, int > controlSIN
Definition: device.hh:115
dynamicgraph::Vector state_
Definition: device.hh:60
PeriodicCall periodicCallBefore_
Definition: device.hh:66
PeriodicCall & periodicCallAfter()
Definition: device.hh:103
dynamicgraph::Signal< dynamicgraph::Vector, int > stateSOUT
Definition: device.hh:121
double timestep_
Definition: device.hh:68
void setPositionBounds(const Vector &lower, const Vector &upper)
Vector lowerTorque_
Definition: device.hh:77
dynamicgraph::Signal< dynamicgraph::Vector, int > velocitySOUT
Definition: device.hh:122
ForceSignalSource
Definition: device.hh:52
@ FORCE_SIGNAL_RARM
Definition: device.hh:55
@ FORCE_SIGNAL_RLEG
Definition: device.hh:53
@ FORCE_SIGNAL_LLEG
Definition: device.hh:54
Vector lowerVelocity_
Definition: device.hh:76
Definition: periodic-call.hh:37
Eigen::Transform< double, 3, Eigen::Affine > SOT_CORE_EXPORT MatrixHomogeneous
Definition: matrix-geometry.hh:75
ControlInput
Define the type of input expected by the robot.
Definition: device.hh:34
@ CONTROL_INPUT_NO_INTEGRATION
Definition: device.hh:35
@ CONTROL_INPUT_ONE_INTEGRATION
Definition: device.hh:36
@ CONTROL_INPUT_TWO_INTEGRATION
Definition: device.hh:37
@ CONTROL_INPUT_SIZE
Definition: device.hh:38
const std::string ControlInput_s[]
Definition: device.hh:41
Definition: abstract-sot-external-interface.hh:17