sot-core  4.10.1
Hierarchical task solver plug-in for dynamic-graph.
integrator-abstract.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2010,
3  * François Bleibel,
4  * Olivier Stasse,
5  *
6  * CNRS/AIST
7  *
8  */
9 
10 #ifndef __SOT_INTEGRATOR_ABSTRACT_H__
11 #define __SOT_INTEGRATOR_ABSTRACT_H__
12 
13 /* --------------------------------------------------------------------- */
14 /* --- INCLUDE --------------------------------------------------------- */
15 /* --------------------------------------------------------------------- */
16 
17 /* Matrix */
18 #include <dynamic-graph/linear-algebra.h>
19 
20 /* SOT */
21 #include <dynamic-graph/all-signals.h>
22 #include <dynamic-graph/command-bind.h>
23 #include <dynamic-graph/entity.h>
24 #include <dynamic-graph/pool.h>
25 #include <sot/core/debug.hh>
26 #include <sot/core/flags.hh>
27 
28 /* STD */
29 #include <string>
30 
31 /* --------------------------------------------------------------------- */
32 /* --- CLASS ----------------------------------------------------------- */
33 /* --------------------------------------------------------------------- */
34 
35 namespace dynamicgraph {
36 namespace sot {
37 
44 template <class sigT, class coefT>
45 class IntegratorAbstract : public dynamicgraph::Entity {
46 public:
47  IntegratorAbstract(const std::string &name)
48  : dynamicgraph::Entity(name),
49  SIN(NULL, "sotIntegratorAbstract(" + name + ")::input(vector)::sin"),
50  SOUT(boost::bind(&IntegratorAbstract<sigT, coefT>::integrate, this, _1,
51  _2),
52  SIN, "sotIntegratorAbstract(" + name + ")::output(vector)::sout") {
53  signalRegistration(SIN << SOUT);
54 
55  using namespace dynamicgraph::command;
56 
57  const std::string typeName =
58  Value::typeName(dynamicgraph::command::ValueHelper<coefT>::TypeID);
59 
60  addCommand(
61  "pushNumCoef",
62  makeCommandVoid1(
64  docCommandVoid1("Push a new numerator coefficient", typeName)));
65  addCommand(
66  "pushDenomCoef",
67  makeCommandVoid1(
69  docCommandVoid1("Push a new denomicator coefficient", typeName)));
70 
71  addCommand(
72  "popNumCoef",
73  makeCommandVoid0(*this, &IntegratorAbstract::popNumCoef,
74  docCommandVoid0("Pop a new numerator coefficient")));
75  addCommand(
76  "popDenomCoef",
77  makeCommandVoid0(*this, &IntegratorAbstract::popDenomCoef,
78  docCommandVoid0("Pop a new denomicator coefficient")));
79  }
80 
81  virtual ~IntegratorAbstract() {}
82 
83  virtual sigT &integrate(sigT &res, int time) = 0;
84 
85 public:
86  void pushNumCoef(const coefT &numCoef) { numerator.push_back(numCoef); }
87  void pushDenomCoef(const coefT &denomCoef) {
88  denominator.push_back(denomCoef);
89  }
90  void popNumCoef() { numerator.pop_back(); }
91  void popDenomCoef() { denominator.pop_back(); }
92 
93 public:
94  dynamicgraph::SignalPtr<sigT, int> SIN;
95 
96  dynamicgraph::SignalTimeDependent<sigT, int> SOUT;
97 
98 protected:
99  std::vector<coefT> numerator;
100  std::vector<coefT> denominator;
101 };
102 
103 } /* namespace sot */
104 } /* namespace dynamicgraph */
105 
106 #endif
dynamicgraph::SignalPtr< sigT, int > SIN
Definition: integrator-abstract.hh:94
void popDenomCoef()
Definition: integrator-abstract.hh:91
std::vector< coefT > numerator
Definition: integrator-abstract.hh:99
void pushDenomCoef(const coefT &denomCoef)
Definition: integrator-abstract.hh:87
std::vector< coefT > denominator
Definition: integrator-abstract.hh:100
integrates an ODE. If Y is the output and X the input, the following equation is integrated: a_p * d(...
Definition: integrator-abstract.hh:45
virtual sigT & integrate(sigT &res, int time)=0
virtual ~IntegratorAbstract()
Definition: integrator-abstract.hh:81
dynamicgraph::SignalTimeDependent< sigT, int > SOUT
Definition: integrator-abstract.hh:96
void popNumCoef()
Definition: integrator-abstract.hh:90
IntegratorAbstract(const std::string &name)
Definition: integrator-abstract.hh:47
Definition: abstract-sot-external-interface.hh:17
void pushNumCoef(const coefT &numCoef)
Definition: integrator-abstract.hh:86