Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpFeatureMomentArea.cpp
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  * Implementation of vpFeatureMomentArea associated to vpMomentArea
32  *
33  * Authors:
34  * Manikandan Bakthavatchalam
35  *
36  *****************************************************************************/
37 #include <visp3/core/vpConfig.h>
38 #include <vector>
39 #include <limits>
40 #include <cassert>
41 #include <limits> // numeric_limits
42 
43 #include <visp3/visual_features/vpFeatureMomentArea.h>
44 #include <visp3/core/vpMomentObject.h>
45 #include <visp3/core/vpMomentGravityCenter.h>
46 #include <visp3/core/vpMomentArea.h>
47 #include <visp3/visual_features/vpFeatureMomentDatabase.h>
48 
57 
58  interaction_matrices.resize(1);
59  interaction_matrices[0].resize(1,6);
60 
61  // Retreive the moment object associated with this feature
63  if (mobj.getType()==vpMomentObject::DISCRETE) {
64  /*
65  * The interaction matrix for the discrete case is zero
66  * since the feature m00 is constant.
67  * Refer thesis of Omar Tahri 2005 [Section 3.4.22]
68  */
69  interaction_matrices[0][0][0] = 0.;
70  interaction_matrices[0][0][1] = 0.;
71  interaction_matrices[0][0][2] = 0.;
72  interaction_matrices[0][0][3] = 0.;
73  interaction_matrices[0][0][4] = 0.;
74  interaction_matrices[0][0][5] = 0.;
75  }
76  else {
77  // Get Xg and Yg
78  bool found_xgyg;
79  const vpMomentGravityCenter& momentGravity = static_cast<const vpMomentGravityCenter&>(moments.get("vpMomentGravityCenter",found_xgyg));
80  if (!found_xgyg) throw vpException(vpException::notInitialized,"vpMomentGravityCenter not found");
81 
82  bool found_m00;
83  const vpMomentArea& areamoment = static_cast<const vpMomentArea&>(moments.get("vpMomentArea", found_m00));
84  if (!found_m00) throw vpException(vpException::notInitialized,"vpMomentArea not found");
85 
86  double Xg = momentGravity.getXg();
87  double Yg = momentGravity.getYg();
88 
89  double a = areamoment.get()[0]; // Area scalar
90 
91  assert(std::fabs(a-mobj.get(0,0)) < a*std::numeric_limits<double>::epsilon());
92 
93  interaction_matrices[0][0][0] = -a*A;
94  interaction_matrices[0][0][1] = -a*B;
95  interaction_matrices[0][0][2] = (3*a)*(A*Xg+B*Yg)+(2*C*a);
96  interaction_matrices[0][0][3] = 3*a*Yg;
97  interaction_matrices[0][0][4] = -3*a*Xg;
98  interaction_matrices[0][0][5] = 0.;
99  }
100 }
const std::vector< double > & get() const
Definition: vpMoment.h:150
const vpMoment * moment
error that can be emited by ViSP classes.
Definition: vpException.h:73
Class for generic objects.
const std::vector< double > & get() const
std::vector< vpMatrix > interaction_matrices
Class handling the surface moment.
Definition: vpMomentArea.h:53
const vpMoment & get(const char *type, bool &found) const
vpMomentDatabase & moments
Class describing 2D gravity center moment.
vpObjectType getType() const
const vpMomentObject & getObject() const
Definition: vpMoment.h:145