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;
Definition of the vpMatrix class.
static void display(vpServo &s, const vpCameraParameters &cam, vpImage< unsigned char > &I, vpColor currentColor=vpColor::green, vpColor desiredColor=vpColor::red, unsigned int thickness=1)
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).
Define the X11 console to display images.
void addFeature(vpBasicFeature &s, vpBasicFeature &s_star, const unsigned int select=vpBasicFeature::FEATURE_ALL)
create a new ste of two visual features
void setLambda(double _lambda)
set the gain lambda
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
void set_cVe(vpVelocityTwistMatrix &_cVe)
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.
void kill()
destruction (memory deallocation if required)
vpColVector getError() const
vpColVector computeControlLaw()
compute the desired control law
static void display(const vpImage< unsigned char > &I)
void set_eJe(vpMatrix &_eJe)
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)
Set the type of the interaction matrix (current, mean, desired, user).
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...
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)
Class required to compute the visual servoing control law descbribed in and .
void get_eJe(vpMatrix &eJe)
interface with the image for feature display
void setServo(vpServoType _servo_type)
Choice of the visual servoing control law.
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...