Visual Servoing Platform  version 3.4.0
vpMomentAreaNormalized Class Reference

#include <vpMomentAreaNormalized.h>

+ Inheritance diagram for vpMomentAreaNormalized:

Public Member Functions

 vpMomentAreaNormalized (double a_star, double Z_star)
 
virtual ~vpMomentAreaNormalized ()
 
void compute ()
 
double getDesiredArea () const
 
double getDesiredDepth () const
 
vp_deprecated double getDesiredSurface () const
 
void setDesiredDepth (double Z_star)
 
void setDesiredArea (double a_star)
 
const char * name () const
 
void printDependencies (std::ostream &os) const
 
Inherited functionalities from vpMoment
const vpMomentObjectgetObject () const
 
const std::vector< double > & get () const
 
void linkTo (vpMomentDatabase &moments)
 
void update (vpMomentObject &object)
 

Protected Member Functions

vpMomentDatabasegetMoments () const
 

Protected Attributes

std::vector< double > values
 

Friends

VISP_EXPORT std::ostream & operator<< (std::ostream &os, const vpMomentAreaNormalized &v)
 

Detailed Description

Class handling the normalized surface moment that is invariant in scale and used to estimate depth.

This moment depends on vpMomentCentered.

The idea behind vpMomentAreaNormalized is described in [41].

During a visual servoing process, a vpMomentAreaNormalized will converge towards the desired depth when the current surface will converge to the destination surface. It is defined as follows: $ a_n=Z^* \sqrt{\frac{a^*}{a}} $ where a is the current surface and a* the destination surface. Consequently, the vpMomentAreaNormalized needs to have information about the desired depth Z* and the desired surface a*.

Warning
About the order of the object. The surface (refered to as a in the above paragraph) depends of the nature of the object.

Therefore, a vpMomentObject has to be of minimum order 2 in order to compute a vpMomentAreaNormalized moment in the discrete case and of minimum order 0 in continous cases.

This example shows a computation in the discrete case.

#include <visp3/core/vpMomentObject.h>
#include <visp3/core/vpPoint.h>
#include <visp3/core/vpMomentGravityCenter.h>
#include <visp3/core/vpMomentDatabase.h>
#include <visp3/core/vpMomentCentered.h>
#include <visp3/core/vpMomentAreaNormalized.h>
int main()
{
std::vector<vpPoint> vec_p; // vector that contains object points
p.set_x(1); p.set_y(1); // coordinates in meters in the image plane of point 1
vec_p.push_back(p);
p.set_x(2); p.set_y(2); // coordinates in meters in the image plane of point 2
vec_p.push_back(p);
vpMomentObject obj(2); // Object where all the moment defined with
// i+j <= 2 will be computed below. Order is
// 2 because in discrete mode, the surface
// computation is a=mu02+mu02
obj.setType(vpMomentObject::DISCRETE); // Discrete mode for object
obj.fromVector(vec_p); // initialize the object with the points coordinates
vpMomentDatabase db; //reference database
vpMomentGravityCenter g; // declaration of gravity center
vpMomentCentered mc; // centered moments
vpMomentAreaNormalized an(2,1); //declare normalized surface with
//destination depth of 1 meter and
//destination surface of 2 m2
g.linkTo(db); //add gravity center to database
mc.linkTo(db); //add centered moments
an.linkTo(db); //add alpha depending on centered moments
db.updateAll(obj); // All of the moments must be updated, not just an
g.compute(); // compute the moment
mc.compute(); //compute centered moments AFTER gravity center
an.compute(); //compute alpha AFTER centered moments.
std::cout << an << std::endl;
return 0;
}

This code produces the following output:

An:1.41421
Examples:
mbot-apriltag-ibvs.cpp, and servoBebop2.cpp.

Definition at line 138 of file vpMomentAreaNormalized.h.

Constructor & Destructor Documentation

vpMomentAreaNormalized::vpMomentAreaNormalized ( double  a_star,
double  Z_star 
)

Default constructor.

Parameters
a_star: desired area a* when the visual servoing converges.
Z_star: desired depth Z* when the visual servoing converges.

Definition at line 78 of file vpMomentAreaNormalized.cpp.

References vpMoment::values.

virtual vpMomentAreaNormalized::~vpMomentAreaNormalized ( )
inlinevirtual

Definition at line 146 of file vpMomentAreaNormalized.h.

References vpMoment::compute().

Member Function Documentation

void vpMomentAreaNormalized::compute ( )
virtual
double vpMomentAreaNormalized::getDesiredArea ( ) const
inline

Retrieves the desired surface a* as specified in the constructor.

Definition at line 151 of file vpMomentAreaNormalized.h.

double vpMomentAreaNormalized::getDesiredDepth ( ) const
inline

Retrieves the desired depth Z* as specified in the constructor.

Definition at line 155 of file vpMomentAreaNormalized.h.

vp_deprecated double vpMomentAreaNormalized::getDesiredSurface ( ) const
inline
Deprecated:
Use rather getDesiredArea() Retrieves the desired surface a* as specified in the constructor.

Definition at line 160 of file vpMomentAreaNormalized.h.

void vpMoment::linkTo ( vpMomentDatabase data_base)
inherited

Links the moment to a database of moment primitives. If the moment depends on other moments, these moments must be linked to the same database.

Attention
Two moments of the same class cannot be stored in the same database
#include <visp3/core/vpMomentCentered.h>
#include <visp3/core/vpMomentDatabase.h>
#include <visp3/core/vpMomentGravityCenter.h>
#include <visp3/core/vpMomentObject.h>
#include <visp3/core/vpPoint.h>
int main()
{
std::vector<vpPoint> vec_p;
p.set_x(1); p.set_y(1); // coordinates in meters in the image plane (vertex 1)
vec_p.push_back(p); p.set_x(2); p.set_y(2); // coordinates in meters in the image plane (vertex 2)
obj.setType(vpMomentObject::DISCRETE); // Discrete mode.
obj.fromVector(vec_p); // Init the dense object with the polygon
vpMomentGravityCenter G; // declaration of gravity center
vpMomentCentered mc; // mc containts centered moments
G.linkTo(db); //add gravity center to database
mc.linkTo(db); //centered moments depend on gravity, add them to the
//database to grant access
G.update(obj); // specify the object for gravity center
mc.update(obj); // and for centered moments
G.compute(); // compute the moment
mc.compute(); //compute centered moments AFTER gravity center
return 0;
}
Parameters
data_base: database of moment primitives.
Examples:
mbot-apriltag-ibvs.cpp, servoBebop2.cpp, and testMomentAlpha.cpp.

Definition at line 98 of file vpMoment.cpp.

References vpException::memoryAllocationError, and vpMoment::name().

Referenced by vpMomentCommon::getAlpha(), vpMomentCommon::getMu3(), vpMomentCommon::getSurface(), and vpMomentCommon::vpMomentCommon().

const char* vpMomentAreaNormalized::name ( ) const
inlinevirtual

Moment name.

Implements vpMoment.

Definition at line 175 of file vpMomentAreaNormalized.h.

References vpMoment::operator<<, and vpMoment::printDependencies().

void vpMomentAreaNormalized::printDependencies ( std::ostream &  os) const
virtual

Prints dependencies namely,

  1. Depth at desired pose Z*
  2. Area moment at desired pose m00* if DENSE moment object, (mu20* + mu02*) if DISCRETE moment object
  3. Area moment at current pose m00 if DENSE moment object, (mu20 + mu02) if DISCRETE moment object

Reimplemented from vpMoment.

Definition at line 102 of file vpMomentAreaNormalized.cpp.

References vpMomentObject::DISCRETE, vpMomentCentered::get(), vpMomentDatabase::get(), vpMomentObject::get(), vpMoment::getMoments(), vpMoment::getObject(), and vpException::notInitialized.

void vpMomentAreaNormalized::setDesiredArea ( double  a_star)
inline

Set the desired area a* to a new value than the one specified in the constructor. This value has to be set before calling compute().

Examples:
mbot-apriltag-ibvs.cpp, and servoBebop2.cpp.

Definition at line 170 of file vpMomentAreaNormalized.h.

void vpMomentAreaNormalized::setDesiredDepth ( double  Z_star)
inline

Set the desired depth Z* to a new value than the one specified in the constructor. This value has to be set before calling compute().

Definition at line 165 of file vpMomentAreaNormalized.h.

void vpMoment::update ( vpMomentObject moment_object)
inherited

Updates the moment with the current object. This does not compute any values.

Parameters
moment_object: object descriptor of the current camera vision.

Definition at line 115 of file vpMoment.cpp.

Friends And Related Function Documentation

VISP_EXPORT std::ostream& operator<< ( std::ostream &  os,
const vpMomentAreaNormalized v 
)
friend

Outputs the moment's values to a stream.

Definition at line 87 of file vpMomentAreaNormalized.cpp.

Member Data Documentation