gain-adaptive.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_GAIN_ADAPTATIVE_HH__
11 #define __SOT_GAIN_ADAPTATIVE_HH__
12 
13 /* --------------------------------------------------------------------- */
14 /* --- INCLUDE --------------------------------------------------------- */
15 /* --------------------------------------------------------------------- */
16 
17 /* Matrix */
18 #include <dynamic-graph/linear-algebra.h>
19 namespace dg = dynamicgraph;
20 
21 /* SOT */
22 #include <dynamic-graph/all-signals.h>
23 #include <dynamic-graph/entity.h>
24 
25 /* --------------------------------------------------------------------- */
26 /* --- API ------------------------------------------------------------- */
27 /* --------------------------------------------------------------------- */
28 
29 #if defined(WIN32)
30 #if defined(gain_adaptive_EXPORTS)
31 #define SOTGAINADAPTATIVE_EXPORT __declspec(dllexport)
32 #else
33 #define SOTGAINADAPTATIVE_EXPORT __declspec(dllimport)
34 #endif
35 #else
36 #define SOTGAINADAPTATIVE_EXPORT
37 #endif
38 
39 /* --------------------------------------------------------------------- */
40 /* --- CLASS ----------------------------------------------------------- */
41 /* --------------------------------------------------------------------- */
42 
43 namespace dynamicgraph {
44 namespace sot {
45 namespace dg = dynamicgraph;
46 
55 class SOTGAINADAPTATIVE_EXPORT GainAdaptive : public dg::Entity {
56 
57 public: /* --- CONSTANTS --- */
58  /* Default values. */
59  static const double ZERO_DEFAULT; // = 0.1
60  static const double INFTY_DEFAULT; // = 0.1
61  static const double TAN_DEFAULT; // = 1.
62 
63 public: /* --- ENTITY INHERITANCE --- */
64  static const std::string CLASS_NAME;
65  virtual void display(std::ostream &os) const;
66  virtual const std::string &getClassName(void) const { return CLASS_NAME; }
67 
68 protected:
69  /* Parameters of the adaptative-gain function:
70  * lambda (x) = a * exp (-b*x) + c. */
71  double coeff_a;
72  double coeff_b;
73  double coeff_c;
74 
75 public: /* --- CONSTRUCTORS ---- */
76  GainAdaptive(const std::string &name);
77  GainAdaptive(const std::string &name, const double &lambda);
78  GainAdaptive(const std::string &name, const double &valueAt0,
79  const double &valueAtInfty, const double &tanAt0);
80 
81 public: /* --- INIT --- */
82  inline void init(void) { init(ZERO_DEFAULT, INFTY_DEFAULT, TAN_DEFAULT); }
83  inline void init(const double &lambda) { init(lambda, lambda, 1.); }
84  void init(const double &valueAt0, const double &valueAtInfty,
85  const double &tanAt0);
113  void initFromPassingPoint(const double &valueAt0, const double &valueAtInfty,
114  const double &errorReference,
115  const double &percentage);
116  void forceConstant(void);
117 
118 public: /* --- SIGNALS --- */
119  dg::SignalPtr<dg::Vector, int> errorSIN;
120  dg::SignalTimeDependent<double, int> gainSOUT;
121 
122 protected:
123  double &computeGain(double &res, int t);
124 
125 private:
126  void addCommands();
127 };
128 
129 } /* namespace sot */
130 } /* namespace dynamicgraph */
131 
132 #endif // #ifndef __SOT_GAIN_ADAPTATIVE_HH__
dynamicgraph::sot::GainAdaptive::errorSIN
dg::SignalPtr< dg::Vector, int > errorSIN
Definition: gain-adaptive.hh:119
dynamicgraph::sot::GainAdaptive::init
void init(const double &lambda)
Definition: gain-adaptive.hh:83
dynamicgraph
Definition: abstract-sot-external-interface.hh:17
SOTGAINADAPTATIVE_EXPORT
#define SOTGAINADAPTATIVE_EXPORT
Definition: gain-adaptive.hh:36
dynamicgraph::sot::GainAdaptive::ZERO_DEFAULT
static const double ZERO_DEFAULT
Definition: gain-adaptive.hh:59
dynamicgraph::sot::GainAdaptive::TAN_DEFAULT
static const double TAN_DEFAULT
Definition: gain-adaptive.hh:61
dynamicgraph::sot::GainAdaptive::getClassName
virtual const std::string & getClassName(void) const
Definition: gain-adaptive.hh:66
dynamicgraph::sot::GainAdaptive::init
void init(void)
Definition: gain-adaptive.hh:82
dynamicgraph::sot::GainAdaptive::gainSOUT
dg::SignalTimeDependent< double, int > gainSOUT
Definition: gain-adaptive.hh:120
dynamicgraph::sot::GainAdaptive
Definition: gain-adaptive.hh:55
dynamicgraph::sot::GainAdaptive::coeff_a
double coeff_a
Definition: gain-adaptive.hh:71
dynamicgraph::sot::GainAdaptive::coeff_b
double coeff_b
Definition: gain-adaptive.hh:72
dynamicgraph::sot::GainAdaptive::INFTY_DEFAULT
static const double INFTY_DEFAULT
Definition: gain-adaptive.hh:60
dynamicgraph::sot::GainAdaptive::CLASS_NAME
static const std::string CLASS_NAME
Definition: gain-adaptive.hh:64
dynamicgraph::sot::GainAdaptive::coeff_c
double coeff_c
Definition: gain-adaptive.hh:73