#include <visp3/core/vpDebug.h>
#include <visp3/core/vpHomogeneousMatrix.h>
#include <visp3/core/vpMomentCommon.h>
#include <visp3/core/vpMomentDatabase.h>
#include <visp3/core/vpMomentObject.h>
#include <visp3/core/vpPlane.h>
#include <visp3/visual_features/vpFeatureMomentCommon.h>
#include <visp3/vs/vpServo.h>
#include <iostream>
#include <limits>
#ifdef ENABLE_VISP_NAMESPACE
#endif
void planeToABC(
const vpPlane &pl,
double &A,
double &B,
double &C);
int test(double x, double y, double z, double alpha);
int main()
{
#if (defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
try {
int sum = 0;
for (double i = -0.2; i < 0.2; i += 0.1) {
for (double j = -0.2; j < 0.2; j += 0.1) {
for (double l = 0.5; l < 1.5; l += 0.1) {
sum += test(i, j, l, k);
}
}
}
}
if (sum < 0)
return EXIT_FAILURE;
else
return EXIT_SUCCESS;
}
std::cout << "Catch an exception: " << e << std::endl;
return EXIT_FAILURE;
}
#else
std::cout << "Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
return EXIT_SUCCESS;
#endif
}
int test(double x, double y, double z, double alpha)
{
initScene(cMo, cdMo, src, dst);
vpMatrix mat = execute(cMo, cdMo, src, dst);
if (fabs(mat[0][0] - (-1)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[0][1] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[0][2] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[1][0] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[1][1] - (-1)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[1][2] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[2][0] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[2][1] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[2][2] - (-1)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[2][5] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[3][0] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[3][1] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[3][2] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[3][5] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[4][0] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[4][1] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[4][2] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[4][5] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[5][0] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[5][1] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[5][2] - (0)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
if (fabs(mat[5][5] - (-1)) > std::numeric_limits<double>::epsilon() * 1e10)
return -1;
return 0;
}
{
std::vector<vpPoint> src_pts;
std::vector<vpPoint> dst_pts;
double x[5] = { 0.2, 0.2, -0.2, -0.2, 0.2 };
double y[5] = { -0.1, 0.1, 0.1, -0.1, -0.1 };
int nbpoints = 4;
for (int i = 0; i < nbpoints; i++) {
p.track(cMo);
src_pts.push_back(p);
}
for (int i = 0; i < nbpoints; i++) {
p.track(cdMo);
dst_pts.push_back(p);
}
}
{
double A;
double B;
double C;
double Ad;
double Bd;
double Cd;
planeToABC(pl, A, B, C);
planeToABC(pl, Ad, Bd, Cd);
vec[2]);
vec[2]);
moments.updateAll(src);
momentsDes.updateAll(dst);
featureMoments.updateAll(A, B, C);
featureMomentsDes.updateAll(Ad, Bd, Cd);
task.
addFeature(featureMoments.getFeatureGravityNormalized(), featureMomentsDes.getFeatureGravityNormalized());
task.
addFeature(featureMoments.getFeatureAn(), featureMomentsDes.getFeatureAn());
task.
addFeature(featureMoments.getFeatureCInvariant(), featureMomentsDes.getFeatureCInvariant(),
(1 << 10) | (1 << 11));
task.
addFeature(featureMoments.getFeatureAlpha(), featureMomentsDes.getFeatureAlpha());
return mat;
}
void planeToABC(
const vpPlane &pl,
double &A,
double &B,
double &C)
{
}
error that can be emitted by ViSP classes.
This class allows to access common vpFeatureMoments in a pre-filled database.
Implementation of an homogeneous matrix and operations on such kind of matrices.
void extract(vpRotationMatrix &R) const
static double rad(double deg)
Implementation of a matrix and operations on matrices.
This class initializes and allows access to commonly used moments.
static std::vector< double > getMu3(vpMomentObject &object)
static double getAlpha(vpMomentObject &object)
static double getSurface(vpMomentObject &object)
Class for generic objects.
void setType(vpObjectType input_type)
void fromVector(std::vector< vpPoint > &points)
This class defines the container for a plane geometrical structure.
void changeFrame(const vpHomogeneousMatrix &cMo)
void setABCD(double a, double b, double c, double d)
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
void setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType, const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE)
void addFeature(vpBasicFeature &s_cur, vpBasicFeature &s_star, unsigned int select=vpBasicFeature::FEATURE_ALL)
void setServo(const vpServoType &servo_type)
vpMatrix computeInteractionMatrix()
vpColVector computeControlLaw()
vpServoIteractionMatrixType
Class that consider the case of a translation vector.