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)
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, sigtime_t 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
dynamicgraph::sot::IntegratorAbstract::popDenomCoef
void popDenomCoef()
Definition: integrator-abstract.hh:92
dynamicgraph::sot::IntegratorAbstract::numCoeffs
void numCoeffs(const std::vector< coefT > &coeffs)
Definition: integrator-abstract.hh:95
dynamicgraph::sot::IntegratorAbstract::integrate
virtual sigT & integrate(sigT &res, sigtime_t time)=0
dynamicgraph::sot::IntegratorAbstract::SOUT
dynamicgraph::SignalTimeDependent< sigT, sigtime_t > SOUT
Definition: integrator-abstract.hh:103
dynamicgraph::sot::IntegratorAbstract::denominator
std::vector< coefT > denominator
Definition: integrator-abstract.hh:121
dynamicgraph::command::ValueHelper
dynamicgraph::sot::IntegratorAbstract::SIN
dynamicgraph::SignalPtr< sigT, sigtime_t > SIN
Definition: integrator-abstract.hh:101
dynamicgraph::SignalPtr< sigT, sigtime_t >
dynamicgraph
dynamicgraph::command
i
int i
dynamicgraph::Entity
dynamicgraph::sot::IntegratorAbstract::numCoeffs
const std::vector< coefT > & numCoeffs() const
Definition: integrator-abstract.hh:94
dynamicgraph::sot::IntegratorAbstract::pushNumCoef
void pushNumCoef(const coefT &numCoef)
Definition: integrator-abstract.hh:87
boost
docCommandVoid0
std::string docCommandVoid0(const std::string &doc)
dynamicgraph::Entity::name
std::string name
dynamicgraph::sot::IntegratorAbstract::denomCoeffs
void denomCoeffs(const std::vector< coefT > &coeffs)
Definition: integrator-abstract.hh:98
dynamicgraph::Entity::getName
const std::string & getName() const
makeCommandVoid0
CommandVoid0< E > * makeCommandVoid0(E &entity, boost::function< void(E *)> function, const std::string &docString)
debug.hh
command-bind.h
dynamicgraph::sot::IntegratorAbstract::denomCoeffs
const std::vector< coefT > & denomCoeffs() const
Definition: integrator-abstract.hh:97
docCommandVoid1
std::string docCommandVoid1(const std::string &doc, const std::string &type)
dynamicgraph::sigtime_t
int64_t sigtime_t
dynamicgraph::sot::IntegratorAbstract::numerator
std::vector< coefT > numerator
Definition: integrator-abstract.hh:120
dynamicgraph::sot::IntegratorAbstract
integrates an ODE. If Y is the output and X the input, the following equation is integrated: a_p * d(...
Definition: integrator-abstract.hh:46
dynamicgraph::Entity::getClassName
virtual const std::string & getClassName() const
all-signals.h
flags.hh
dynamicgraph::sot::IntegratorAbstract::pushDenomCoef
void pushDenomCoef(const coefT &denomCoef)
Definition: integrator-abstract.hh:88
linear-algebra.h
dynamicgraph::sot::IntegratorAbstract::~IntegratorAbstract
virtual ~IntegratorAbstract()
Definition: integrator-abstract.hh:82
dynamicgraph::SignalTimeDependent< sigT, sigtime_t >
dynamicgraph::Entity::addCommand
void addCommand(const std::string &name, command::Command *command)
dynamicgraph::command::Value::typeName
static std::string typeName(Type type)
dynamicgraph::sot::IntegratorAbstract::popNumCoef
void popNumCoef()
Definition: integrator-abstract.hh:91
dynamicgraph::Entity::signalRegistration
void signalRegistration(const SignalArray< sigtime_t > &signals)
makeCommandVoid1
CommandVoid1< E, T > * makeCommandVoid1(E &entity, boost::function< void(const T &)> function, const std::string &docString)
dynamicgraph::sot::IntegratorAbstract::IntegratorAbstract
IntegratorAbstract(const std::string &name)
Definition: integrator-abstract.hh:48
dynamicgraph::sot::IntegratorAbstract::display
virtual void display(std::ostream &os) const
Definition: integrator-abstract.hh:105


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:31