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"
84 void usage(
const char *name,
const char *badparam);
85 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display);
95 void usage(
const char *name,
const char *badparam)
98 Tests a control law with the following characteristics:\n\
99 - eye-in-hand control\n\
100 - articular velocity are computed\n\
101 - servo on 4 points,\n\
102 - internal and external camera view displays.\n\
105 %s [-c] [-d] [-h]\n", name);
110 Disable the mouse click. Useful to automaze the \n\
111 execution of this program without humain intervention.\n\
114 Turn off the display.\n\
120 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
134 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display)
141 case 'c': click_allowed =
false;
break;
142 case 'd': display =
false;
break;
143 case 'h': usage(argv[0], NULL);
return false;
break;
146 usage(argv[0], optarg_);
151 if ((c == 1) || (c == -1)) {
153 usage(argv[0], NULL);
154 std::cerr <<
"ERROR: " << std::endl;
155 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
163 main(
int argc,
const char ** argv)
166 bool opt_click_allowed =
true;
167 bool opt_display =
true;
170 if (getOptions(argc, argv, opt_click_allowed, opt_display) ==
false) {
176 #if defined VISP_HAVE_X11
179 #elif defined VISP_HAVE_GTK
182 #elif defined VISP_HAVE_GDI
193 displayInt.
init(Iint,0,0,
"Internal view") ;
194 displayExt.
init(Iext,330,000,
"External view") ;
199 double px, py ; px = py = 500 ;
200 double u0, v0 ; u0 = 150, v0 = 160 ;
208 std::cout << std::endl ;
209 std::cout <<
"----------------------------------------------" << std::endl ;
210 std::cout <<
" Test program for vpServo " <<std::endl ;
211 std::cout <<
" Eye-in-hand task control, articular velocity are computed"
213 std::cout <<
" Simulation " << std::endl ;
214 std::cout <<
" task : servo 4 points " << std::endl ;
215 std::cout <<
"----------------------------------------------" << std::endl ;
216 std::cout << std::endl ;
237 for (i = 0 ; i < 4 ; i++)
238 externalview.
insert(point[i]) ;
241 for (i = 0 ; i < 4 ; i++)
242 point[i].track(cMo) ;
246 for (i = 0 ; i < 4 ; i++)
274 for (i = 0 ; i < 4 ; i++)
283 unsigned int iter=0 ;
287 std::cout <<
"---------------------------------------------" << iter <<std::endl ;
301 for (i = 0 ; i < 4 ; i++)
303 point[i].
track(cMo) ;
328 std::cout <<
"|| s - s* || = " << ( task.
getError() ).sumSquare() <<std::endl ;
335 std::cout <<
"Final robot position with respect to the object frame:\n";
338 if (opt_display && opt_click_allowed) {
340 std::cout <<
"\n\nClick in the internal view window to end..." << std::endl;
346 std::cout <<
"Catch a ViSP exception: " << e << std::endl;
355 std::cout <<
"You do not have X11, GTK or GDI display functionalities..." << std::endl;
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)
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 init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
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...