MomentAreaNormalized

class MomentAreaNormalized(self, a_star: float, Z_star: float)

Bases: Moment

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 [40] .

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 (referred to as a in the above paragraph) depends of the nature of the object.

  • In case of a continuous object (when vpMomentObject::getType() is vpMomentObject::DENSE_FULL_OBJECT or vpMomentObject::DENSE_POLYGON ) \(a=m_{00}\) .

  • In case of a discrete object (when vpMomentObject::getType() is vpMomentObject::DISCRETE ) \(a=\mu_{20}+\mu_{02}\) .

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 continuous cases.

This example shows a computation in the discrete case.

#include <visp3/core/vpMomentAreaNormalized.h>
#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()
{
  vpPoint p;
  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);

  //////////////////////////////REFERENCE VALUES////////////////////////////////
  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

Default constructor.

Parameters:
a_star: float

desired area a* when the visual servoing converges.

Z_star: float

desired depth Z* when the visual servoing converges.

Methods

__init__

Default constructor.

compute

Computes the normalized area \(a_n=Z^* \sqrt{\frac{a^*}{a}}\) .

getDesiredArea

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

getDesiredDepth

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

name

Moment name.

printDependencies

Overloaded function.

setDesiredArea

Set the desired area a* to a new value than the one specified in the constructor.

setDesiredDepth

Set the desired depth Z* to a new value than the one specified in the constructor.

Inherited Methods

linkTo

Links the moment to a database of moment primitives.

get

return:

vector of values

getObject

update

Updates the moment with the current object.

Operators

__doc__

__init__

Default constructor.

__module__

__repr__

Attributes

__annotations__

__init__(self, a_star: float, Z_star: float)

Default constructor.

Parameters:
a_star: float

desired area a* when the visual servoing converges.

Z_star: float

desired depth Z* when the visual servoing converges.

compute(self) None

Computes the normalized area \(a_n=Z^* \sqrt{\frac{a^*}{a}}\) . Depends on vpMomentCentered .

get(self) list[float]
Returns:

vector of values

getDesiredArea(self) float

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

getDesiredDepth(self) float

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

getObject(self) visp._visp.core.MomentObject
linkTo(self, moments: visp._visp.core.MomentDatabase) None

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.

Warning

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()
{
  vpPoint p;
  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)
  vec_p.push_back(p);

  vpMomentObject obj(2);
  obj.setType(vpMomentObject::DISCRETE); // Discrete mode.
  obj.fromVector(vec_p); // Init the dense object with the polygon

  vpMomentDatabase db;
  vpMomentGravityCenter G; // declaration of gravity center
  vpMomentCentered mc;     // mc contains 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;
}
name(self) str

Moment name.

printDependencies(*args, **kwargs)

Overloaded function.

  1. printDependencies(self: visp._visp.core.MomentAreaNormalized, os: std::ostream) -> None

<unparsed orderedlist <doxmlparser.compound.docListType object at 0x7ff69e7fb310>>

  1. printDependencies(self: visp._visp.core.Moment, os: std::ostream) -> None

Prints values of all dependent moments required to calculate a specific vpMoment . Not made pure to maintain compatibility Recommended : Types inheriting from vpMoment should implement this function

setDesiredArea(self, a_star: float) None

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() .

setDesiredDepth(self, Z_star: float) None

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() .

update(self, object: visp._visp.core.MomentObject) None

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