ViSP  2.6.2
vpServo.h
1 /****************************************************************************
2  *
3  * $Id: vpServo.h 3663 2012-04-02 08:27:31Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2012 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Visual servoing control law.
36  *
37  * Authors:
38  * Eric Marchand
39  * Nicolas Mansard
40  * Fabien Spindler
41  *
42  *****************************************************************************/
43 
44 
45 #ifndef vpServo_H
46 #define vpServo_H
47 
53 #include <visp/vpMatrix.h>
54 #include <visp/vpVelocityTwistMatrix.h>
55 #include <visp/vpBasicFeature.h>
56 #include <visp/vpServoException.h>
57 
58 #include <visp/vpList.h>
59 #include <visp/vpAdaptiveGain.h>
60 
61 
150 class VISP_EXPORT vpServo
151 {
152  /*
153  Choice of the visual servoing control law
154  */
155 public:
156  typedef enum
157  {
163  EYETOHAND_L_cVf_fJe
164  } vpServoType;
165 
166  typedef enum
167  {
171  USER_DEFINED
172  } vpServoIteractionMatrixType;
173 
174  typedef enum
175  {
177  PSEUDO_INVERSE
178  } vpServoInversionType;
179 
180  typedef enum
181  {
182  ALL,
189  MINIMUM
190  } vpServoPrintType;
191 
192 public:
193  // default constructor
194  vpServo();
196  vpServo(vpServoType _servoType) ;
198  virtual ~vpServo() ;
199 
203  vpVelocityTwistMatrix get_cVe() const { return cVe; }
207  vpVelocityTwistMatrix get_cVf() const { return cVf; }
211  vpVelocityTwistMatrix set_fVe() const { return fVe; }
215  vpMatrix get_eJe() const { return eJe; }
219  vpMatrix get_fJe() const { return fJe; }
220 
222  void kill() ;
223 
225  void setServo(vpServoType _servo_type) ;
226 
227  void set_cVe(vpVelocityTwistMatrix &_cVe) { cVe = _cVe ; init_cVe = true ; }
228  void set_cVf(vpVelocityTwistMatrix &_cVf) { cVf = _cVf ; init_cVf = true ; }
229  void set_fVe(vpVelocityTwistMatrix &_fVe) { fVe = _fVe ; init_fVe = true ; }
230 
231  void set_cVe(vpHomogeneousMatrix &cMe) { cVe.buildFrom(cMe); init_cVe=true ;}
232  void set_cVf(vpHomogeneousMatrix &cMf) { cVf.buildFrom(cMf); init_cVf=true ;}
233  void set_fVe(vpHomogeneousMatrix &fMe) { fVe.buildFrom(fMe); init_fVe=true ;}
234 
235  void set_eJe(vpMatrix &_eJe) { eJe = _eJe ; init_eJe = true ; }
236  void set_fJe(vpMatrix &_fJe) { fJe = _fJe ; init_fJe = true ; }
237 
238 
240  void setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType,
241  const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE) ;
242 
247  void setForceInteractionMatrixComputation(bool forceInteractionMatrixComputation) {this->forceInteractionMatrixComputation = forceInteractionMatrixComputation;}
248 
250  void setLambda(double _lambda) { lambda .initFromConstant (_lambda) ; }
251  void setLambda(const double at_zero,
252  const double at_infinity,
253  const double deriv_at_zero)
254  { lambda .initStandard (at_zero, at_infinity, deriv_at_zero) ; }
255  void setLambda(const vpAdaptiveGain& _l){lambda=_l;}
256 
258  void addFeature(vpBasicFeature& s, vpBasicFeature& s_star,
259  const unsigned int select=vpBasicFeature::FEATURE_ALL) ;
261  void addFeature(vpBasicFeature& s,
262  const unsigned int select=vpBasicFeature::FEATURE_ALL) ;
263 
265  vpMatrix computeInteractionMatrix() ;
266  // compute the error between the current set of visual features and
267  // the desired set of visual features
268  vpColVector computeError() ;
270  vpColVector computeControlLaw() ;
273  bool testInitialization() ;
276  bool testUpdated() ;
277 
278 
280  vpColVector secondaryTask(vpColVector &de2dt) ;
282  vpColVector secondaryTask(vpColVector &e2, vpColVector &de2dt) ;
283 
285  unsigned int getDimension() ;
286 
298  inline vpColVector getError() const
299  {
300  return error ;
301  }
302  /*
303  Return the interaction matrix \f$L\f$ used to compute the task jacobian \f$J_1\f$.
304  The interaction matrix is updated after a call to computeInteractionMatrix() or computeControlLaw().
305 
306 \code
307  vpServo task;
308  ...
309  vpColVector v = task.computeControlLaw(); // Compute the velocity corresponding to the visual servoing
310  vpMatrix L = task.getInteractionMatrix(); // Get the interaction matrix used to compute v
311 \endcode
312  \sa getTaskJacobian()
313  */
315  {
316  return L;
317  }
318 
331  inline vpMatrix getI_WpW() const
332  {
333  return I_WpW;
334  }
338  inline vpServoType getServoType() const
339  {
340  return servoType;
341  }
354  inline vpMatrix getTaskJacobian() const
355  {
356  return J1;
357  }
373  {
374  return J1p;
375  }
386  inline double getTaskRank() const
387  {
388  return rankJ1;
389  }
402  inline vpMatrix getWpW() const
403  {
404  return WpW;
405  }
406 
407 
408  void print(const vpServo::vpServoPrintType display_level=ALL,
409  std::ostream &os = std::cout) ;
410 protected:
412  void init() ;
413 
414 public:
425 
432 
437 
438 
443 
446 
448  unsigned int rankJ1 ;
449 
457 
460 
469 
470 protected:
471  /*
472  Twist transformation matrix
473  */
474 
477  bool init_cVe ;
480  bool init_cVf ;
483  bool init_fVe ;
484 
485  /*
486  Jacobians
487  */
488 
491  bool init_eJe ;
494  bool init_fJe ;
495 
496  /*
497  Task building
498  */
499 
505  unsigned int dim_task ;
506  bool taskWasKilled; // flag to indicate if the task was killed
509 
514 } ;
515 
516 
517 #endif
518 
519 /*
520  * Local variables:
521  * c-basic-offset: 2
522  * End:
523  */
Definition of the vpMatrix class.
Definition: vpMatrix.h:96
Adaptive gain computation.
vpServoType servoType
Chosen visual servoing control law.
Definition: vpServo.h:445
vpList< vpBasicFeature * > desiredFeatureList
List of desired visual features (produce )
Definition: vpServo.h:453
static const unsigned int FEATURE_ALL
bool interactionMatrixComputed
true if the interaction matrix has been computed
Definition: vpServo.h:503
bool taskWasKilled
Definition: vpServo.h:506
vpMatrix getTaskJacobian() const
Definition: vpServo.h:354
unsigned int rankJ1
Rank of the task Jacobian.
Definition: vpServo.h:448
vpVelocityTwistMatrix cVf
Twist transformation matrix between Rf and Rc.
Definition: vpServo.h:479
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
vpList< unsigned int > featureSelectionList
Definition: vpServo.h:456
bool init_cVf
Definition: vpServo.h:480
vpVelocityTwistMatrix fVe
Twist transformation matrix between Re and Rf.
Definition: vpServo.h:482
vpServoType
Definition: vpServo.h:156
vpColVector e1
Primary task .
Definition: vpServo.h:434
bool init_cVe
Definition: vpServo.h:477
void setLambda(double _lambda)
set the gain lambda
Definition: vpServo.h:250
vpVelocityTwistMatrix get_cVe() const
Definition: vpServo.h:203
vpServoInversionType
Definition: vpServo.h:174
void setForceInteractionMatrixComputation(bool forceInteractionMatrixComputation)
Definition: vpServo.h:247
vpMatrix fJe
Jacobian expressed in the robot reference frame.
Definition: vpServo.h:493
void set_fVe(vpVelocityTwistMatrix &_fVe)
Definition: vpServo.h:229
void set_cVe(vpHomogeneousMatrix &cMe)
Definition: vpServo.h:231
vpColVector q_dot
Articular velocity.
Definition: vpServo.h:440
vpMatrix getI_WpW() const
Definition: vpServo.h:331
unsigned int dim_task
dimension of the task
Definition: vpServo.h:505
void set_cVe(vpVelocityTwistMatrix &_cVe)
Definition: vpServo.h:227
vpServoInversionType inversionType
Definition: vpServo.h:468
void set_fVe(vpHomogeneousMatrix &fMe)
Definition: vpServo.h:233
class that defines what is a visual feature
void setLambda(const double at_zero, const double at_infinity, const double deriv_at_zero)
Definition: vpServo.h:251
vpList< vpBasicFeature * > featureList
List of visual features (produce )
Definition: vpServo.h:451
vpColVector getError() const
Definition: vpServo.h:298
int signInteractionMatrix
Definition: vpServo.h:463
vpMatrix J1
Task Jacobian .
Definition: vpServo.h:422
vpMatrix L
Interaction matrix.
Definition: vpServo.h:416
vpVelocityTwistMatrix set_fVe() const
Definition: vpServo.h:211
void set_eJe(vpMatrix &_eJe)
Definition: vpServo.h:235
vpMatrix get_fJe() const
Definition: vpServo.h:219
bool init_fVe
Definition: vpServo.h:483
void set_cVf(vpHomogeneousMatrix &cMf)
Definition: vpServo.h:232
bool forceInteractionMatrixComputation
Force the interaction matrix computation even if it is already done.
Definition: vpServo.h:508
vpVelocityTwistMatrix get_cVf() const
Definition: vpServo.h:207
vpAdaptiveGain lambda
Gain.
Definition: vpServo.h:459
vpVelocityTwistMatrix cVe
Twist transformation matrix between Re and Rc.
Definition: vpServo.h:476
Class that consider the particular case of twist transformation matrix that allows to transform a vel...
vpServoType getServoType() const
Definition: vpServo.h:338
vpColVector s
Definition: vpServo.h:428
vpServoIteractionMatrixType
Definition: vpServo.h:166
void setLambda(const vpAdaptiveGain &_l)
Definition: vpServo.h:255
vpColVector e
Task .
Definition: vpServo.h:436
vpMatrix getInteractionMatrix()
Definition: vpServo.h:314
vpMatrix getTaskJacobianPseudoInverse() const
Definition: vpServo.h:372
vpMatrix get_eJe() const
Definition: vpServo.h:215
Class that provides a data structure for the column vectors as well as a set of operations on these v...
Definition: vpColVector.h:72
bool init_fJe
Definition: vpServo.h:494
double getTaskRank() const
Definition: vpServo.h:386
vpMatrix I_WpW
projection operators I-WpW
Definition: vpServo.h:513
vpColVector sStar
Definition: vpServo.h:431
vpColVector v
Camera velocity.
Definition: vpServo.h:442
bool errorComputed
true if the error has been computed
Definition: vpServo.h:501
vpMatrix WpW
projection operators WpW
Definition: vpServo.h:511
bool init_eJe
Definition: vpServo.h:491
vpMatrix J1p
Pseudo inverse of the task Jacobian.
Definition: vpServo.h:424
vpMatrix getWpW() const
Definition: vpServo.h:402
Class required to compute the visual servoing control law.
Definition: vpServo.h:150
void set_cVf(vpVelocityTwistMatrix &_cVf)
Definition: vpServo.h:228
vpServoPrintType
Definition: vpServo.h:180
vpColVector error
Definition: vpServo.h:420
void set_fJe(vpMatrix &_fJe)
Definition: vpServo.h:236
vpServoIteractionMatrixType interactionMatrixType
Type of the interaction matrox (current, mean, desired, user)
Definition: vpServo.h:465
vpMatrix eJe
Jacobian expressed in the end-effector frame.
Definition: vpServo.h:490