59 #include <visp/vpConfig.h>
61 #if (defined (VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI))
66 #include <visp/vpCameraParameters.h>
67 #include <visp/vpDisplayX.h>
68 #include <visp/vpDisplayGTK.h>
69 #include <visp/vpDisplayGDI.h>
70 #include <visp/vpFeatureBuilder.h>
71 #include <visp/vpFeaturePoint.h>
72 #include <visp/vpHomogeneousMatrix.h>
73 #include <visp/vpImage.h>
74 #include <visp/vpMath.h>
75 #include <visp/vpParseArgv.h>
76 #include <visp/vpProjectionDisplay.h>
77 #include <visp/vpServo.h>
78 #include <visp/vpServoDisplay.h>
79 #include <visp/vpSimulatorCamera.h>
82 #define GETOPTARGS "cdh"
92 void usage(
const char *name,
const char *badparam)
95 Tests a control law with the following characteristics:\n\
96 - eye-in-hand control\n\
97 - articular velocity are computed\n\
98 - servo on 4 points,\n\
99 - internal and external camera view displays.\n\
102 %s [-c] [-d] [-h]\n", name);
107 Disable the mouse click. Useful to automaze the \n\
108 execution of this program without humain intervention.\n\
111 Turn off the display.\n\
117 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
131 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display)
138 case 'c': click_allowed =
false;
break;
139 case 'd': display =
false;
break;
140 case 'h': usage(argv[0], NULL);
return false;
break;
143 usage(argv[0], optarg);
148 if ((c == 1) || (c == -1)) {
150 usage(argv[0], NULL);
151 std::cerr <<
"ERROR: " << std::endl;
152 std::cerr <<
" Bad argument " << optarg << std::endl << std::endl;
160 main(
int argc,
const char ** argv)
163 bool opt_click_allowed =
true;
164 bool opt_display =
true;
167 if (getOptions(argc, argv, opt_click_allowed, opt_display) ==
false) {
173 #if defined VISP_HAVE_X11
176 #elif defined VISP_HAVE_GTK
179 #elif defined VISP_HAVE_GDI
190 displayInt.
init(Iint,0,0,
"Internal view") ;
191 displayExt.
init(Iext,330,000,
"External view") ;
196 double px, py ; px = py = 500 ;
197 double u0, v0 ; u0 = 150, v0 = 160 ;
205 std::cout << std::endl ;
206 std::cout <<
"----------------------------------------------" << std::endl ;
207 std::cout <<
" Test program for vpServo " <<std::endl ;
208 std::cout <<
" Eye-in-hand task control, articular velocity are computed"
210 std::cout <<
" Simulation " << std::endl ;
211 std::cout <<
" task : servo 4 points " << std::endl ;
212 std::cout <<
"----------------------------------------------" << std::endl ;
213 std::cout << std::endl ;
234 for (i = 0 ; i < 4 ; i++)
235 externalview.
insert(point[i]) ;
238 for (i = 0 ; i < 4 ; i++)
239 point[i].track(cMo) ;
243 for (i = 0 ; i < 4 ; i++)
271 for (i = 0 ; i < 4 ; i++)
280 unsigned int iter=0 ;
284 std::cout <<
"---------------------------------------------" << iter <<std::endl ;
298 for (i = 0 ; i < 4 ; i++)
300 point[i].
track(cMo) ;
325 std::cout <<
"|| s - s* || = " << ( task.
getError() ).sumSquare() <<std::endl ;
332 std::cout <<
"Final robot position with respect to the object frame:\n";
335 if (opt_display && opt_click_allowed) {
337 std::cout <<
"\n\nClick in the internal view window to end..." << std::endl;
346 std::cout <<
"You do not have X11, GTK or GDI display functionalities..." << std::endl;