Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpFeatureMomentArea.cpp
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4
*
5
* This software is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
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 https://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
#include <cassert>
37
#include <limits>
// numeric_limits
38
#include <vector>
39
#include <visp3/core/vpConfig.h>
40
41
#include <visp3/core/vpMomentArea.h>
42
#include <visp3/core/vpMomentGravityCenter.h>
43
#include <visp3/core/vpMomentObject.h>
44
#include <visp3/visual_features/vpFeatureMomentArea.h>
45
#include <visp3/visual_features/vpFeatureMomentCentered.h>
46
#include <visp3/visual_features/vpFeatureMomentDatabase.h>
47
48
BEGIN_VISP_NAMESPACE
59
void
vpFeatureMomentArea::compute_interaction
()
60
{
61
62
interaction_matrices
.resize(1);
63
interaction_matrices
[0].resize(1, 6);
64
65
// Retreive the moment object associated with this feature
66
vpMomentObject
mobj =
moment
->getObject();
67
if
(mobj.
getType
() ==
vpMomentObject::DISCRETE
) {
68
// Get centered moments
69
bool
found_centered;
70
const
vpFeatureMomentCentered
&momentCentered =
static_cast<
const
vpFeatureMomentCentered
&
>
(
71
featureMomentsDataBase
->get(
"vpFeatureMomentCentered"
, found_centered));
72
if
(!found_centered)
73
throw
vpException
(
vpException::notInitialized
,
"vpFeatureMomentCentered not found"
);
74
interaction_matrices
[0] = momentCentered.
interaction
(2, 0) + momentCentered.
interaction
(0, 2);
75
}
76
else
{
77
// Get Xg and Yg
78
bool
found_xgyg;
79
const
vpMomentGravityCenter
&momentGravity =
80
static_cast<
const
vpMomentGravityCenter
&
>
(
moments
.get(
"vpMomentGravityCenter"
, found_xgyg));
81
if
(!found_xgyg)
82
throw
vpException
(
vpException::notInitialized
,
"vpMomentGravityCenter not found"
);
83
84
bool
found_m00;
85
const
vpMomentArea
&areamoment =
static_cast<
const
vpMomentArea
&
>
(
moments
.get(
"vpMomentArea"
, found_m00));
86
if
(!found_m00)
87
throw
vpException
(
vpException::notInitialized
,
"vpMomentArea not found"
);
88
89
double
Xg = momentGravity.
getXg
();
90
double
Yg = momentGravity.
getYg
();
91
92
double
a = areamoment.
get
()[0];
// Area scalar
93
94
assert(std::fabs(a - mobj.
get
(0, 0)) < a * std::numeric_limits<double>::epsilon());
95
96
interaction_matrices
[0][0][0] = -a *
A
;
97
interaction_matrices
[0][0][1] = -a *
B
;
98
interaction_matrices
[0][0][2] = (3 * a) * (
A
* Xg +
B
* Yg) + (2 *
C
* a);
99
interaction_matrices
[0][0][3] = 3 * a * Yg;
100
interaction_matrices
[0][0][4] = -3 * a * Xg;
101
interaction_matrices
[0][0][5] = 0.;
102
}
103
}
104
END_VISP_NAMESPACE
vpException
error that can be emitted by ViSP classes.
Definition
vpException.h:60
vpException::notInitialized
@ notInitialized
Used to indicate that a parameter is not initialized.
Definition
vpException.h:74
vpFeatureMomentArea::compute_interaction
void compute_interaction() VP_OVERRIDE
Definition
vpFeatureMomentArea.cpp:59
vpFeatureMomentCentered
Functionality computation for centered moment feature. Computes the interaction matrix associated wit...
Definition
vpFeatureMomentCentered.h:78
vpFeatureMomentCentered::interaction
vpMatrix interaction(unsigned int select_one, unsigned int select_two) const
Definition
vpFeatureMomentCentered.cpp:67
vpFeatureMoment::C
double C
Definition
vpFeatureMoment.h:172
vpFeatureMoment::B
double B
Definition
vpFeatureMoment.h:171
vpFeatureMoment::interaction_matrices
std::vector< vpMatrix > interaction_matrices
Definition
vpFeatureMoment.h:168
vpFeatureMoment::featureMomentsDataBase
vpFeatureMomentDatabase * featureMomentsDataBase
Definition
vpFeatureMoment.h:167
vpFeatureMoment::moments
vpMomentDatabase & moments
Definition
vpFeatureMoment.h:166
vpFeatureMoment::A
double A
Definition
vpFeatureMoment.h:170
vpFeatureMoment::moment
const vpMoment * moment
Definition
vpFeatureMoment.h:164
vpMomentArea
Class handling the surface moment.
Definition
vpMomentArea.h:60
vpMomentGravityCenter
Class describing 2D gravity center moment.
Definition
vpMomentGravityCenter.h:117
vpMomentGravityCenter::getYg
double getYg() const
Definition
vpMomentGravityCenter.h:134
vpMomentGravityCenter::getXg
double getXg() const
Definition
vpMomentGravityCenter.h:129
vpMomentObject
Class for generic objects.
Definition
vpMomentObject.h:225
vpMomentObject::DISCRETE
@ DISCRETE
Definition
vpMomentObject.h:237
vpMomentObject::get
const std::vector< double > & get() const
Definition
vpMomentObject.cpp:538
vpMomentObject::getType
vpObjectType getType() const
Definition
vpMomentObject.h:282
vpMoment::get
const std::vector< double > & get() const
Definition
vpMoment.h:155
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
visual_features
src
visual-feature
vpFeatureMomentArea.cpp
Generated by
1.17.0