gain-hyperbolic.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_HYPERBOLIC_HH__
11 #define __SOT_GAIN_HYPERBOLIC_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_hyperbolic_EXPORTS)
31 #define SOTGAINHYPERBOLIC_EXPORT __declspec(dllexport)
32 #else
33 #define SOTGAINHYPERBOLIC_EXPORT __declspec(dllimport)
34 #endif
35 #else
36 #define SOTGAINHYPERBOLIC_EXPORT
37 #endif
38 
39 /* --------------------------------------------------------------------- */
40 /* --- CLASS ----------------------------------------------------------- */
41 /* --------------------------------------------------------------------- */
42 
43 namespace dynamicgraph {
44 namespace sot {
45 namespace dg = dynamicgraph;
46 
55 class SOTGAINHYPERBOLIC_EXPORT GainHyperbolic : 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 hyperbolic-gain function:
70  * lambda (x) = a * exp (-b*x) + c. */
71  double coeff_a;
72  double coeff_b;
73  double coeff_c;
74  double coeff_d;
75 
76 public: /* --- CONSTRUCTORS ---- */
77  GainHyperbolic(const std::string &name);
78  GainHyperbolic(const std::string &name, const double &lambda);
79  GainHyperbolic(const std::string &name, const double &valueAt0,
80  const double &valueAtInfty, const double &tanAt0,
81  const double &decal0);
82 
83 public: /* --- INIT --- */
84  inline void init(void) { init(ZERO_DEFAULT, INFTY_DEFAULT, TAN_DEFAULT, 0); }
85  inline void init(const double &lambda) { init(lambda, lambda, 1., 0); }
92  void init(const double &valueAt0, const double &valueAtInfty,
93  const double &tanAt0, const double &decal0);
94  void forceConstant(void);
95 
96 public: /* --- SIGNALS --- */
97  dg::SignalPtr<dg::Vector, int> errorSIN;
98  dg::SignalTimeDependent<double, int> gainSOUT;
99 
100 protected:
101  double &computeGain(double &res, int t);
102 };
103 
104 } /* namespace sot */
105 } /* namespace dynamicgraph */
106 
107 #endif // #ifndef __SOT_GAIN_HYPERBOLIC_HH__
dynamicgraph
Definition: abstract-sot-external-interface.hh:17
dynamicgraph::sot::GainHyperbolic::CLASS_NAME
static const std::string CLASS_NAME
Definition: gain-hyperbolic.hh:64
dynamicgraph::sot::GainHyperbolic::init
void init(void)
Definition: gain-hyperbolic.hh:84
dynamicgraph::sot::GainHyperbolic::coeff_d
double coeff_d
Definition: gain-hyperbolic.hh:74
dynamicgraph::sot::GainHyperbolic::init
void init(const double &lambda)
Definition: gain-hyperbolic.hh:85
dynamicgraph::sot::GainHyperbolic::coeff_a
double coeff_a
Definition: gain-hyperbolic.hh:71
dynamicgraph::sot::GainHyperbolic::getClassName
virtual const std::string & getClassName(void) const
Definition: gain-hyperbolic.hh:66
dynamicgraph::sot::GainHyperbolic::TAN_DEFAULT
static const double TAN_DEFAULT
Definition: gain-hyperbolic.hh:61
dynamicgraph::sot::GainHyperbolic::coeff_c
double coeff_c
Definition: gain-hyperbolic.hh:73
SOTGAINHYPERBOLIC_EXPORT
#define SOTGAINHYPERBOLIC_EXPORT
Definition: gain-hyperbolic.hh:36
dynamicgraph::sot::GainHyperbolic::coeff_b
double coeff_b
Definition: gain-hyperbolic.hh:72
dynamicgraph::sot::GainHyperbolic::INFTY_DEFAULT
static const double INFTY_DEFAULT
Definition: gain-hyperbolic.hh:60
dynamicgraph::sot::GainHyperbolic::ZERO_DEFAULT
static const double ZERO_DEFAULT
Definition: gain-hyperbolic.hh:59
dynamicgraph::sot::GainHyperbolic::errorSIN
dg::SignalPtr< dg::Vector, int > errorSIN
Definition: gain-hyperbolic.hh:97
dynamicgraph::sot::GainHyperbolic::gainSOUT
dg::SignalTimeDependent< double, int > gainSOUT
Definition: gain-hyperbolic.hh:98
dynamicgraph::sot::GainHyperbolic
Hyperbolic gain. It follows the law.
Definition: gain-hyperbolic.hh:55