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:
169  const MatrixHomogeneous &freeFlyerPose() const;
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 */
dynamicgraph::sot::Device::pseudoTorqueSOUT
dynamicgraph::Signal< dynamicgraph::Vector, int > pseudoTorqueSOUT
Definition: device.hh:144
dynamicgraph::sot::Device::FORCE_SIGNAL_LLEG
@ FORCE_SIGNAL_LLEG
Definition: device.hh:54
dynamicgraph::sot::Device::getClassName
virtual const std::string & getClassName(void) const
Definition: device.hh:50
dynamicgraph::sot::Device::robotState_
dynamicgraph::Signal< dynamicgraph::Vector, int > robotState_
Definition: device.hh:137
dynamicgraph::sot::MatrixHomogeneous
Eigen::Transform< double, 3, Eigen::Affine > SOT_CORE_EXPORT MatrixHomogeneous
Definition: matrix-geometry.hh:75
SOT_CORE_EXPORT
#define SOT_CORE_EXPORT
Definition: api.hh:20
dynamicgraph::sot::Device
Definition: device.hh:47
dynamicgraph::sot::ControlInput
ControlInput
Define the type of input expected by the robot.
Definition: device.hh:34
dynamicgraph::sot::Device::ZMPPreviousControllerSOUT
dynamicgraph::Signal< dynamicgraph::Vector, int > ZMPPreviousControllerSOUT
The ZMP reference send by the previous controller.
Definition: device.hh:128
dynamicgraph
Definition: abstract-sot-external-interface.hh:17
dynamicgraph::sot::Device::vel_control_
dynamicgraph::Vector vel_control_
Definition: device.hh:63
dynamicgraph::sot::Device::periodicCallBefore
PeriodicCall & periodicCallBefore()
Definition: device.hh:102
dynamicgraph::sot::Device::state_
dynamicgraph::Vector state_
Definition: device.hh:60
dynamicgraph::sot::Device::robotVelocity_
dynamicgraph::Signal< dynamicgraph::Vector, int > robotVelocity_
Motor velocities.
Definition: device.hh:139
dynamicgraph::sot::Device::controlSIN
dynamicgraph::SignalPtr< dynamicgraph::Vector, int > controlSIN
Definition: device.hh:115
dynamicgraph::sot::ControlInput_s
const std::string ControlInput_s[]
Definition: device.hh:41
dynamicgraph::sot::Device::periodicCallAfter_
PeriodicCall periodicCallAfter_
Definition: device.hh:67
dynamicgraph::sot::Device::upperVelocity_
Vector upperVelocity_
Definition: device.hh:73
dynamicgraph::sot::CONTROL_INPUT_SIZE
@ CONTROL_INPUT_SIZE
Definition: device.hh:38
dynamicgraph::sot::Device::FORCE_SIGNAL_RLEG
@ FORCE_SIGNAL_RLEG
Definition: device.hh:53
dynamicgraph::sot::Device::upperTorque_
Vector upperTorque_
Definition: device.hh:74
dynamicgraph::sot::CONTROL_INPUT_NO_INTEGRATION
@ CONTROL_INPUT_NO_INTEGRATION
Definition: device.hh:35
dynamicgraph::sot::Device::periodicCallBefore_
PeriodicCall periodicCallBefore_
Definition: device.hh:66
dynamicgraph::sot::Device::periodicCallAfter
PeriodicCall & periodicCallAfter()
Definition: device.hh:103
dynamicgraph::sot::Device::lowerTorque_
Vector lowerTorque_
Definition: device.hh:77
dynamicgraph::sot::Device::lowerPosition_
Vector lowerPosition_
Definition: device.hh:75
dynamicgraph::sot::Device::FORCE_SIGNAL_RARM
@ FORCE_SIGNAL_RARM
Definition: device.hh:55
api.hh
dynamicgraph::sot::Device::ForceSignalSource
ForceSignalSource
Definition: device.hh:52
dynamicgraph::sot::Device::motorcontrolSOUT
dynamicgraph::Signal< dynamicgraph::Vector, int > motorcontrolSOUT
The current state of the robot from the command viewpoint.
Definition: device.hh:125
dynamicgraph::sot::Device::upperPosition_
Vector upperPosition_
Definition: device.hh:72
periodic-call.hh
dynamicgraph::sot::Device::display
virtual void display(std::ostream &os) const
dynamicgraph::sot::Device::previousControlSOUT
dynamicgraph::Signal< dynamicgraph::Vector, int > previousControlSOUT
Definition: device.hh:126
dynamicgraph::sot::Device::sanityCheck_
bool sanityCheck_
Definition: device.hh:62
dynamicgraph::sot::Device::timestep_
double timestep_
Definition: device.hh:68
dynamicgraph::sot::Device::velocity_
dynamicgraph::Vector velocity_
Definition: device.hh:61
matrix-geometry.hh
dynamicgraph::sot::Device::controlInputType_
ControlInput controlInputType_
Definition: device.hh:64
dynamicgraph::sot::Device::attitudeSOUT
dynamicgraph::Signal< MatrixRotation, int > attitudeSOUT
Definition: device.hh:123
dynamicgraph::sot::Device::ffPose_
MatrixHomogeneous ffPose_
Store Position of free flyer joint.
Definition: device.hh:152
dynamicgraph::sot::Device::zmpSIN
dynamicgraph::SignalPtr< dynamicgraph::Vector, int > zmpSIN
Definition: device.hh:117
dynamicgraph::sot::PeriodicCall
Definition: periodic-call.hh:37
dynamicgraph::sot::Device::lowerVelocity_
Vector lowerVelocity_
Definition: device.hh:76
dynamicgraph::sot::Device::stateSOUT
dynamicgraph::Signal< dynamicgraph::Vector, int > stateSOUT
Definition: device.hh:121
dynamicgraph::sot::Device::CLASS_NAME
static const std::string CLASS_NAME
Definition: device.hh:49
dynamicgraph::sot::Device::attitudeSIN
dynamicgraph::SignalPtr< dynamicgraph::Vector, int > attitudeSIN
Definition: device.hh:116
dynamicgraph::sot::CONTROL_INPUT_ONE_INTEGRATION
@ CONTROL_INPUT_ONE_INTEGRATION
Definition: device.hh:36
dynamicgraph::sot::CONTROL_INPUT_TWO_INTEGRATION
@ CONTROL_INPUT_TWO_INTEGRATION
Definition: device.hh:37
dynamicgraph::sot::Device::velocitySOUT
dynamicgraph::Signal< dynamicgraph::Vector, int > velocitySOUT
Definition: device.hh:122
dynamicgraph::sot::Device::operator<<
SOT_CORE_EXPORT friend std::ostream & operator<<(std::ostream &os, const Device &r)
Definition: device.hh:108