Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpAdaptiveGain.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See http://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Adaptive gain.
32  *
33  * Authors:
34  * Nicolas Mansard
35  *
36  *****************************************************************************/
42 #ifndef __VP_ADAPTIVE_GAIN_H
43 #define __VP_ADAPTIVE_GAIN_H
44 
45 #include <visp3/core/vpConfig.h>
46 #include <iostream>
47 
48 class vpColVector;
73 class VISP_EXPORT vpAdaptiveGain
74 {
75 
76 public: /* constantes */
77 
78  static const double DEFAULT_LAMBDA_ZERO;
79  static const double DEFAULT_LAMBDA_INFINITY;
80  static const double DEFAULT_LAMBDA_SLOPE;
81 
82 
83 private: /* Attributs*/
84  /* Coefficient de la fonction de calcul de lambda.
85  * lambda (x) = a * exp (-b*x) + c. */
86  double coeff_a;
87  double coeff_b;
88  double coeff_c;
89 
90  /* Derniere valeur calculee. */
91  mutable double lambda;
92 
93 
94 
95 public: /* Methodes*/
96 
97  /* --- CONSTRUCTOR -------------------------------------------------------- */
98 
99  vpAdaptiveGain ();
100  vpAdaptiveGain (double c);
101  vpAdaptiveGain (double gain_at_zero,
102  double gain_at_infinity,
103  double slope_at_zero);
104 
105 
106  /* --- INIT --------------------------------------------------------------- */
107  void initFromConstant (double c);
108  void initFromVoid (void);
109  void initStandard (double gain_at_zero,
110  double gain_at_infinity,
111  double slope_at_zero);
112 
113 
114  /* --- MODIFIORS ---------------------------------------------------------- */
115  double setConstant (void);
116 
117 
118  /* --- COMPUTE ------------------------------------------------------------ */
119  /* \brief Calcule la valeur de lambda au point courrant.
120  *
121  * Determine la valeur du lambda adaptatif en fonction de la valeur
122  * de la norme de la fonction de tache e par extrapolation exponentielle.
123  * La fonction est : (en_infini - en_zero) * exp (-pente * ||e|| ) + en_infini.
124  * On a bien :
125  * - lambda(10^5) = en_infini ;
126  * - lambda(0) = en_zero ;
127  * - lambda(x ~ 0) ~ - pente * x + en_zero.
128  * \param val_e: valeur de la norme de l'erreur.
129  * \return: valeur de gain au point courrant.
130  */
131  double value_const (double x) const;
132 
133  /* \brief Calcule la valeur de lambda au point courrant et stockage du
134  * resultat.
135  *
136  * La fonction calcule la valeur de lambda d'apres la valeur de la norme
137  * de l'erreur, comme le fait la fonction valeur_const.
138  * La fonction non constante stocke de plus le resultat dans this ->lambda.
139  * \param val_e: valeur de la norme de l'erreur.
140  * \return: valeur de gain au point courrant.
141  */
142  double value (double x) const;
143 
144  double limitValue_const (void) const;
145 
146  double limitValue (void) const;
147 
148  /* --- ACCESSORS ---------------------------------------------------------- */
149 
155  inline double getLastValue (void) const {return this ->lambda;}
156 
157  double operator() (double x) const;
158 
159  /* \brief Lance la fonction valeur avec la norme INFINIE du vecteur. */
160  double operator() (const vpColVector & x) const;
161 
162  /* \brief Idem function limitValue. */
163  double operator() (void) const;
164 
165 
166  /* --- IOSTREAM ----------------------------------------------------------- */
167 
168  friend VISP_EXPORT std::ostream& operator<< (std::ostream &os, const vpAdaptiveGain& lambda);
169 };
170 
171 #endif /* __VP_ADAPTIVE_GAIN_H */
double getLastValue(void) const
Adaptive gain computation.
static const double DEFAULT_LAMBDA_ZERO
static const double DEFAULT_LAMBDA_INFINITY
static const double DEFAULT_LAMBDA_SLOPE
Implementation of column vector and the associated operations.
Definition: vpColVector.h:72