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 */
19 
20 /* SOT */
23 #include <dynamic-graph/entity.h>
24 #include <dynamic-graph/pool.h>
25 
26 #include <sot/core/debug.hh>
27 #include <sot/core/flags.hh>
28 
29 /* STD */
30 #include <string>
31 
32 /* --------------------------------------------------------------------- */
33 /* --- CLASS ----------------------------------------------------------- */
34 /* --------------------------------------------------------------------- */
35 
36 namespace dynamicgraph {
37 namespace sot {
38 
45 template <class sigT, class coefT>
47  public:
48  IntegratorAbstract(const std::string &name)
49  : dynamicgraph::Entity(name),
50  SIN(NULL, "sotIntegratorAbstract(" + name + ")::input(vector)::sin"),
51  SOUT(boost::bind(&IntegratorAbstract<sigT, coefT>::integrate, this, _1,
52  _2),
53  SIN, "sotIntegratorAbstract(" + name + ")::output(vector)::sout") {
55 
56  using namespace dynamicgraph::command;
57 
58  const std::string typeName =
60 
61  addCommand(
62  "pushNumCoef",
65  docCommandVoid1("Push a new numerator coefficient", typeName)));
66  addCommand(
67  "pushDenomCoef",
70  docCommandVoid1("Push a new denominator coefficient", typeName)));
71 
72  addCommand(
73  "popNumCoef",
75  docCommandVoid0("Pop a new numerator coefficient")));
76  addCommand(
77  "popDenomCoef",
79  docCommandVoid0("Pop a new denominator coefficient")));
80  }
81 
82  virtual ~IntegratorAbstract() {}
83 
84  virtual sigT &integrate(sigT &res, int time) = 0;
85 
86  public:
87  void pushNumCoef(const coefT &numCoef) { numerator.push_back(numCoef); }
88  void pushDenomCoef(const coefT &denomCoef) {
89  denominator.push_back(denomCoef);
90  }
91  void popNumCoef() { numerator.pop_back(); }
92  void popDenomCoef() { denominator.pop_back(); }
93 
94  const std::vector<coefT> &numCoeffs() const { return numerator; }
95  void numCoeffs(const std::vector<coefT> &coeffs) { numerator = coeffs; }
96 
97  const std::vector<coefT> &denomCoeffs() const { return denominator; }
98  void denomCoeffs(const std::vector<coefT> &coeffs) { denominator = coeffs; }
99 
100  public:
102 
104 
105  virtual void display(std::ostream &os) const {
106  os << this->getClassName() << ": " << getName() << '\n' << " ";
107  if (numerator.empty() || denominator.empty()) {
108  os << "ill-formed.";
109  return;
110  }
111  os << numerator[0];
112  for (std::size_t i = 1; i < numerator.size(); ++i)
113  os << " + " << numerator[i] << " s^" << i;
114  os << "\n " << denominator[0];
115  for (std::size_t i = 1; i < denominator.size(); ++i)
116  os << " + " << denominator[i] << " s^" << i;
117  }
118 
119  protected:
120  std::vector<coefT> numerator;
121  std::vector<coefT> denominator;
122 };
123 
124 } /* namespace sot */
125 } /* namespace dynamicgraph */
126 
127 #endif
CommandVoid0< E > * makeCommandVoid0(E &entity, boost::function< void(void)> function, const std::string &docString)
const std::vector< coefT > & denomCoeffs() const
int i
void signalRegistration(const SignalArray< int > &signals)
const std::vector< coefT > & numCoeffs() const
dynamicgraph::SignalPtr< sigT, int > SIN
CommandVoid1< E, T > * makeCommandVoid1(E &entity, boost::function< void(const T &)> function, const std::string &docString)
void pushDenomCoef(const coefT &denomCoef)
std::string docCommandVoid1(const std::string &doc, const std::string &type)
std::string docCommandVoid0(const std::string &doc)
void denomCoeffs(const std::vector< coefT > &coeffs)
virtual const std::string & getClassName() const
integrates an ODE. If Y is the output and X the input, the following equation is integrated: a_p * d(...
virtual sigT & integrate(sigT &res, int time)=0
void numCoeffs(const std::vector< coefT > &coeffs)
res
const std::string & getName() const
dynamicgraph::SignalTimeDependent< sigT, int > SOUT
void addCommand(const std::string &name, command::Command *command)
IntegratorAbstract(const std::string &name)
virtual void display(std::ostream &os) const
void pushNumCoef(const coefT &numCoef)
static std::string typeName(Type type)


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Wed Jun 21 2023 02:51:26