59 #include <visp/vpConfig.h>
61 #if (defined (VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV))
66 #include <visp/vpCameraParameters.h>
67 #include <visp/vpDisplayX.h>
68 #include <visp/vpDisplayGTK.h>
69 #include <visp/vpDisplayGDI.h>
70 #include <visp/vpDisplayOpenCV.h>
71 #include <visp/vpFeatureBuilder.h>
72 #include <visp/vpFeaturePoint.h>
73 #include <visp/vpHomogeneousMatrix.h>
74 #include <visp/vpImage.h>
75 #include <visp/vpMath.h>
76 #include <visp/vpParseArgv.h>
77 #include <visp/vpProjectionDisplay.h>
78 #include <visp/vpServo.h>
79 #include <visp/vpServoDisplay.h>
80 #include <visp/vpSimulatorCamera.h>
83 #define GETOPTARGS "cdh"
85 void usage(
const char *name,
const char *badparam);
86 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display);
96 void usage(
const char *name,
const char *badparam)
99 Tests a control law with the following characteristics:\n\
100 - eye-in-hand control\n\
101 - articular velocity are computed\n\
102 - servo on 4 points,\n\
103 - internal and external camera view displays.\n\
106 %s [-c] [-d] [-h]\n", name);
111 Disable the mouse click. Useful to automaze the \n\
112 execution of this program without humain intervention.\n\
115 Turn off the display.\n\
121 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
135 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display)
142 case 'c': click_allowed =
false;
break;
143 case 'd': display =
false;
break;
144 case 'h': usage(argv[0], NULL);
return false;
break;
147 usage(argv[0], optarg_);
152 if ((c == 1) || (c == -1)) {
154 usage(argv[0], NULL);
155 std::cerr <<
"ERROR: " << std::endl;
156 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
164 main(
int argc,
const char ** argv)
167 bool opt_click_allowed =
true;
168 bool opt_display =
true;
171 if (getOptions(argc, argv, opt_click_allowed, opt_display) ==
false) {
177 #if defined VISP_HAVE_X11
180 #elif defined VISP_HAVE_GTK
183 #elif defined VISP_HAVE_GDI
186 #elif defined VISP_HAVE_OPENCV
197 displayInt.
init(Iint,0,0,
"Internal view") ;
198 displayExt.
init(Iext,330,000,
"External view") ;
203 double px, py ; px = py = 500 ;
204 double u0, v0 ; u0 = 150, v0 = 160 ;
212 std::cout << std::endl ;
213 std::cout <<
"----------------------------------------------" << std::endl ;
214 std::cout <<
" Test program for vpServo " <<std::endl ;
215 std::cout <<
" Eye-in-hand task control, articular velocity are computed"
217 std::cout <<
" Simulation " << std::endl ;
218 std::cout <<
" task : servo 4 points " << std::endl ;
219 std::cout <<
"----------------------------------------------" << std::endl ;
220 std::cout << std::endl ;
241 for (i = 0 ; i < 4 ; i++)
242 externalview.
insert(point[i]) ;
245 for (i = 0 ; i < 4 ; i++)
246 point[i].track(cMo) ;
250 for (i = 0 ; i < 4 ; i++)
278 for (i = 0 ; i < 4 ; i++)
287 unsigned int iter=0 ;
291 std::cout <<
"---------------------------------------------" << iter <<std::endl ;
305 for (i = 0 ; i < 4 ; i++)
307 point[i].
track(cMo) ;
332 std::cout <<
"|| s - s* || = " << ( task.
getError() ).sumSquare() <<std::endl ;
339 std::cout <<
"Final robot position with respect to the object frame:\n";
342 if (opt_display && opt_click_allowed) {
344 std::cout <<
"\n\nClick in the internal view window to end..." << std::endl;
350 std::cout <<
"Catch a ViSP exception: " << e << std::endl;
359 std::cout <<
"You do not have X11, GTK, GDI or OpenCV display functionalities..." << std::endl;
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
Definition of the vpMatrix class.
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
void display(vpImage< unsigned char > &I, const vpHomogeneousMatrix &cextMo, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, const vpColor &color, const bool &displayTraj=false, const unsigned int thickness=1)
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
Class that defines the simplest robot: a free flying camera.
Display for windows using GDI (available on any windows 32 platform).
void set_eJe(const vpMatrix &eJe_)
Define the X11 console to display images.
void addFeature(vpBasicFeature &s, vpBasicFeature &s_star, const unsigned int select=vpBasicFeature::FEATURE_ALL)
error that can be emited by ViSP classes.
void track(const vpHomogeneousMatrix &cMo)
Class that defines a 2D point visual feature which is composed by two parameters that are the cartes...
static const vpColor green
static void flush(const vpImage< unsigned char > &I)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
Class that defines what is a point.
vpColVector getError() const
vpColVector computeControlLaw()
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the opencv library.
Generic class defining intrinsic camera parameters.
void getPosition(vpHomogeneousMatrix &wMc) const
The vpDisplayGTK allows to display image using the GTK+ library version 1.2.
void insert(vpForwardProjection &fp)
Class that consider the particular case of twist transformation matrix that allows to transform a vel...
void setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType, const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE)
static double rad(double deg)
void buildFrom(const double x, const double y, const double Z)
Class that provides a data structure for the column vectors as well as a set of operations on these v...
void set_cVe(const vpVelocityTwistMatrix &cVe_)
vpHomogeneousMatrix inverse() const
void print(const vpServo::vpServoPrintType display_level=ALL, std::ostream &os=std::cout)
virtual bool getClick(bool blocking=true)=0
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
void get_eJe(vpMatrix &eJe)
interface with the image for feature display
void setServo(const vpServoType &servo_type)
static void display(const vpServo &s, const vpCameraParameters &cam, const vpImage< unsigned char > &I, vpColor currentColor=vpColor::green, vpColor desiredColor=vpColor::red, unsigned int thickness=1)
void setWorldCoordinates(const double ox, const double oy, const double oz)
Set the point world coordinates. We mean here the coordinates of the point in the object frame...