derivator.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_DERIVATOR_H__
11 #define __SOT_DERIVATOR_H__
12 
13 /* --------------------------------------------------------------------- */
14 /* --- INCLUDE --------------------------------------------------------- */
15 /* --------------------------------------------------------------------- */
16 
17 /* Matrix */
19 
20 /* SOT */
22 #include <dynamic-graph/entity.h>
23 
24 #include <sot/core/flags.hh>
26 #include <sot/core/pool.hh>
27 
28 /* STD */
29 #include <string>
30 
31 namespace dynamicgraph {
32 namespace sot {
33 
34 /* --------------------------------------------------------------------- */
35 /* --- CLASS ----------------------------------------------------------- */
36 /* --------------------------------------------------------------------- */
37 
38 template <class T>
41 
42  protected:
45  double timestep;
46  static const double TIMESTEP_DEFAULT; //= 1.;
47 
48  public: /* --- CONSTRUCTION --- */
49  static std::string getTypeName(void) { return "Unknown"; }
50 
51  Derivator(const std::string &name)
53  memory(),
54  initialized(false),
56  SIN(NULL, "sotDerivator<" + getTypeName() + ">(" + name + ")::input(" +
57  getTypeName() + ")::sin"),
58  SOUT(boost::bind(&Derivator<T>::computeDerivation, this, _1, _2), SIN,
59  "sotDerivator<" + getTypeName() + ">(" + name + ")::output(" +
60  getTypeName() + ")::sout"),
61  timestepSIN("sotDerivator<" + getTypeName() + ">(" + name +
62  ")::input(double)::dt") {
66  }
67 
68  virtual ~Derivator(void){};
69 
70  public: /* --- SIGNAL --- */
74 
75  protected:
76  T &computeDerivation(T &res, sigtime_t time) {
77  if (initialized) {
78  res = memory;
79  res *= -1;
80  memory = SIN(time);
81  res += memory;
82  if (timestep != 1.) res *= (1. / timestep);
83  } else {
84  initialized = true;
85  memory = SIN(time);
86  res = memory;
87  res *= 0;
88  }
89  return res;
90  }
91 };
92 // TODO Derivation of unit quaternion?
93 template <>
95  VectorQuaternion &res, sigtime_t time) {
96  if (initialized) {
97  res = memory;
98  res.coeffs() *= -1;
99  memory = SIN(time);
100  res.coeffs() += memory.coeffs();
101  if (timestep != 1.) res.coeffs() *= (1. / timestep);
102  } else {
103  initialized = true;
104  memory = SIN(time);
105  res = memory;
106  res.coeffs() *= 0;
107  }
108  return res;
109 }
110 
111 } /* namespace sot */
112 } /* namespace dynamicgraph */
113 
114 #endif // #ifndef __SOT_DERIVATOR_H__
dynamicgraph::Signal< double, sigtime_t >
dynamicgraph::sot::VectorQuaternion
Eigen::Quaternion< double > SOT_CORE_EXPORT VectorQuaternion
Definition: matrix-geometry.hh:78
dynamicgraph::sot::Derivator::timestep
double timestep
Definition: derivator.hh:45
T
int T
dynamicgraph::SignalPtr< T, sigtime_t >
dynamicgraph
dynamicgraph::Entity
dynamicgraph::sot::Derivator::memory
T memory
Definition: derivator.hh:43
boost
dynamicgraph::Entity::name
std::string name
dynamicgraph::sot::Derivator::SIN
dynamicgraph::SignalPtr< T, sigtime_t > SIN
Definition: derivator.hh:68
dynamicgraph::sot::Derivator::computeDerivation
T & computeDerivation(T &res, sigtime_t time)
Definition: derivator.hh:76
dynamicgraph::sot::Derivator::~Derivator
virtual ~Derivator(void)
Definition: derivator.hh:68
dynamicgraph::sot::Derivator::timestepSIN
dynamicgraph::Signal< double, sigtime_t > timestepSIN
Definition: derivator.hh:73
res
res
dynamicgraph::sigtime_t
int64_t sigtime_t
dynamicgraph::sot::Derivator::getTypeName
static std::string getTypeName(void)
Definition: derivator.hh:49
dynamicgraph::sot::Derivator::SOUT
dynamicgraph::SignalTimeDependent< T, sigtime_t > SOUT
Definition: derivator.hh:72
dynamicgraph::sot::Derivator::Derivator
Derivator(const std::string &name)
Definition: derivator.hh:51
all-signals.h
dynamicgraph::sot::Derivator::initialized
bool initialized
Definition: derivator.hh:44
flags.hh
linear-algebra.h
dynamicgraph::sot::Derivator
Definition: derivator.hh:39
pool.hh
dynamicgraph::sot::Derivator::TIMESTEP_DEFAULT
static const double TIMESTEP_DEFAULT
Definition: derivator.hh:46
matrix-geometry.hh
dynamicgraph::SignalTimeDependent< T, sigtime_t >
dynamicgraph::Signal::setReferenceNonConstant
virtual void setReferenceNonConstant(T *t, Mutex *mutexref=NULL)
dynamicgraph::Entity::signalRegistration
void signalRegistration(const SignalArray< sigtime_t > &signals)
dynamicgraph::sot::Derivator::DYNAMIC_GRAPH_ENTITY_DECL
DYNAMIC_GRAPH_ENTITY_DECL()
dynamicgraph::Signal::setKeepReference
void setKeepReference(const bool &b)


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