Visual Servoing Platform  version 3.3.0 under development (2020-02-17)
vpAdaptiveGain.h
1 /****************************************************************************
2  *
3  * ViSP, open source Visual Servoing Platform software.
4  * Copyright (C) 2005 - 2019 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  * See the file LICENSE.txt at the root directory of this source
11  * distribution for additional information about the GNU GPL.
12  *
13  * For using ViSP with software that can not be combined with the GNU
14  * GPL, please contact Inria about acquiring a ViSP Professional
15  * Edition License.
16  *
17  * See http://visp.inria.fr for more information.
18  *
19  * This software was developed at:
20  * Inria Rennes - Bretagne Atlantique
21  * Campus Universitaire de Beaulieu
22  * 35042 Rennes Cedex
23  * France
24  *
25  * If you have questions regarding the use of this file, please contact
26  * Inria at visp@inria.fr
27  *
28  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
29  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
30  *
31  * Description:
32  * Adaptive gain.
33  *
34  * Authors:
35  * Nicolas Mansard
36  *
37  *****************************************************************************/
43 #ifndef _vpAdaptiveGain_h_
44 #define _vpAdaptiveGain_h_
45 
46 #include <iostream>
47 #include <visp3/core/vpConfig.h>
48 
49 class vpColVector;
121 class VISP_EXPORT vpAdaptiveGain
122 {
123 public:
124  static const double DEFAULT_LAMBDA_ZERO;
125  static const double DEFAULT_LAMBDA_INFINITY;
126  static const double DEFAULT_LAMBDA_SLOPE;
127 
128 private:
129  // Coefficient such as lambda (x) = a * exp (-b*x) + c
130  double coeff_a; // \f$ a = \lambda(0) - \lambda(\infty) \f$
131  double coeff_b; // \f$ b = {\dot \lambda}(0) / a \f$
132  double coeff_c; // \f$ c = \lambda(\infty) \f$
133 
134  // Last computed value
135  mutable double lambda;
136 
137 public:
138  /* --- CONSTRUCTOR --------------------------------------------------------
139  */
140 
141  vpAdaptiveGain();
142  explicit vpAdaptiveGain(double c);
143  vpAdaptiveGain(double gain_at_zero, double gain_at_infinity, double slope_at_zero);
144 
145  /* --- INIT ---------------------------------------------------------------
146  */
147  void initFromConstant(double c);
148  void initFromVoid(void);
149  void initStandard(double gain_at_zero, double gain_at_infinity, double slope_at_zero);
150 
151  /* --- MODIFIORS ----------------------------------------------------------
152  */
153  double setConstant(void);
154 
155  /* --- COMPUTE ------------------------------------------------------------
156  */
157  /* \brief Calcule la valeur de lambda au point courrant.
158  *
159  * Determine la valeur du lambda adaptatif en fonction de la valeur
160  * de la norme de la fonction de tache e par extrapolation exponentielle.
161  * La fonction est : (en_infini - en_zero) * exp (-pente * ||e|| ) +
162  * en_infini. On a bien :
163  * - lambda(10^5) = en_infini ;
164  * - lambda(0) = en_zero ;
165  * - lambda(x ~ 0) ~ - pente * x + en_zero.
166  * \param val_e: valeur de la norme de l'erreur.
167  * \return: valeur de gain au point courrant.
168  */
169  double value_const(double x) const;
170 
171  /* \brief Calcule la valeur de lambda au point courrant et stockage du
172  * resultat.
173  *
174  * La fonction calcule la valeur de lambda d'apres la valeur de la norme
175  * de l'erreur, comme le fait la fonction valeur_const.
176  * La fonction non constante stocke de plus le resultat dans this ->lambda.
177  * \param val_e: valeur de la norme de l'erreur.
178  * \return: valeur de gain au point courrant.
179  */
180  double value(double x) const;
181 
182  double limitValue_const(void) const;
183 
184  double limitValue(void) const;
185 
186  /* --- ACCESSORS ----------------------------------------------------------
187  */
188 
195  inline double getLastValue(void) const { return this->lambda; }
196 
197  double operator()(double x) const;
198 
199  /* \brief Lance la fonction valeur avec la norme INFINIE du vecteur. */
200  double operator()(const vpColVector &x) const;
201 
202  /* \brief Idem function limitValue. */
203  double operator()(void) const;
204 
205  /* --- IOSTREAM -----------------------------------------------------------
206  */
207  friend VISP_EXPORT std::ostream &operator<<(std::ostream &os, const vpAdaptiveGain &lambda);
208 };
209 
210 #endif
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:130