Shows how to build a task with a segment visual feature.
#include <fstream>
#include <iostream>
#include <numeric>
#include <vector>
#include <visp3/core/vpConfig.h>
#if defined(VISP_HAVE_MODULE_ROBOT) && \
(defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
#include <visp3/core/vpCameraParameters.h>
#include <visp3/core/vpDisplay.h>
#include <visp3/core/vpHomogeneousMatrix.h>
#include <visp3/core/vpImage.h>
#include <visp3/core/vpMath.h>
#include <visp3/core/vpPoint.h>
#include <visp3/gui/vpDisplayGDI.h>
#include <visp3/gui/vpDisplayX.h>
#include <visp3/gui/vpPlot.h>
#include <visp3/io/vpParseArgv.h>
#include <visp3/robot/vpSimulatorCamera.h>
#include <visp3/visual_features/vpFeatureBuilder.h>
#include <visp3/visual_features/vpFeatureSegment.h>
#include <visp3/vs/vpServo.h>
int main(int argc, const char **argv)
{
#ifdef ENABLE_VISP_NAMESPACE
#endif
try {
#if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
int opt_no_display = 0;
int opt_curves = 1;
#endif
int opt_normalized = 1;
vpParseArgv::vpArgvInfo argTable[] = {
#if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
#endif
"1 to use normalized features, 0 for non normalized."},
};
return (false);
}
std::cout << "Used options: " << std::endl;
#if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
opt_curves = (opt_no_display == 0) ? 1 : 0;
std::cout << " - no display: " << opt_no_display << std::endl;
std::cout << " - curves : " << opt_curves << std::endl;
#endif
std::cout << " - normalized: " << opt_normalized << std::endl;
#if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI)
if (!opt_no_display) {
#if defined(VISP_HAVE_X11)
display = new vpDisplayX;
#elif defined(VISP_HAVE_GDI)
#endif
}
#endif
#if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
if (!opt_no_display)
display->init(I);
#endif
for (int i = 0; i < 4; i++) {
Pd[i] = P[i];
}
for (int i = 0; i < 4; i++) {
Pc[i] = P[i];
}
for (int i = 0; i < 2; i++) {
if (opt_normalized) {
}
else {
}
}
for (int i = 0; i < 2; i++)
#if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
if (!opt_no_display) {
for (int i = 0; i < 2; i++) {
}
}
#endif
#if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
if (opt_curves) {
graph =
new vpPlot(2, 500, 500, 700, 10,
"Curves...");
}
#endif
float sampling_time = 0.02f;
robot.setSamplingTime(sampling_time);
int iter = 0;
do {
wMc = robot.
getPosition();
for (int i = 0; i < 4; i++)
Pc[i].project(cMo);
for (int i = 0; i < 2; i++)
#if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
if (!opt_no_display) {
for (int i = 0; i < 2; i++) {
}
}
#endif
#if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
if (opt_curves) {
}
#endif
iter++;
}
while ((task.
getError()).sumSquare() > 0.0005);
#if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
if (graph != nullptr)
delete graph;
#endif
#if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI))
if (!opt_no_display && display != nullptr)
delete display;
#endif
std::cout <<
"final error=" << (task.
getError()).sumSquare() << std::endl;
return EXIT_SUCCESS;
}
std::cout << "Catch an exception: " << e << std::endl;
return EXIT_FAILURE;
}
}
#elif !(defined(VISP_HAVE_LAPACK) || defined(VISP_HAVE_EIGEN3) || defined(VISP_HAVE_OPENCV))
int main()
{
std::cout << "Cannot run this example: install Lapack, Eigen3 or OpenCV" << std::endl;
return EXIT_SUCCESS;
}
#else
int main()
{
std::cout << "Test empty since visp_robot module is not available.\n" << std::endl;
return EXIT_SUCCESS;
}
#endif
Generic class defining intrinsic camera parameters.
Implementation of column vector and the associated operations.
static const vpColor green
Display for windows using GDI (available on any windows 32 platform).
Class that defines generic functionalities for display.
static void display(const vpImage< unsigned char > &I)
static void flush(const vpImage< unsigned char > &I)
error that can be emitted by ViSP classes.
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpImagePoint &t)
Class that defines a 2D segment visual features. This class allow to consider two sets of visual feat...
void display(const vpCameraParameters &cam, const vpImage< unsigned char > &I, const vpColor &color=vpColor::green, unsigned int thickness=1) const VP_OVERRIDE
void print(unsigned int select=FEATURE_ALL) const VP_OVERRIDE
void setNormalized(bool normalized)
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpHomogeneousMatrix inverse() const
static double rad(double deg)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
@ ARGV_NO_DEFAULTS
No default options like -help.
@ ARGV_NO_LEFTOVERS
Print an error message if an option is not in the argument list.
@ ARGV_INT
Argument is associated to an int.
@ ARGV_CONSTANT_INT
Stand alone argument associated to an int var that is set to 1.
@ ARGV_END
End of the argument list.
@ ARGV_HELP
Argument is for help displaying.
This class enables real time drawing of 2D or 3D graphics. An instance of the class open a window whi...
void initGraph(unsigned int graphNum, unsigned int curveNbr)
void plot(unsigned int graphNum, unsigned int curveNum, double x, double y)
Class that defines a 3D point in the object frame and allows forward projection of a 3D point in the ...
void setWorldCoordinates(double oX, double oY, double oZ)
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel) VP_OVERRIDE
void setMaxRotationVelocity(double maxVr)
void setMaxTranslationVelocity(double maxVt)
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)
vpColVector getError() const
vpColVector computeControlLaw()
Class that defines the simplest robot: a free flying camera.
VISP_EXPORT int wait(double t0, double t)
VISP_EXPORT double measureTimeMs()