60 #include <visp/vpDebug.h>
61 #include <visp/vpConfig.h>
63 #if (defined(_WIN32) || defined(VISP_HAVE_PTHREAD)) && (defined (VISP_HAVE_X11) || defined(VISP_HAVE_OPENCV) || defined(VISP_HAVE_GDI))
72 #include <visp/vpCameraParameters.h>
73 #include <visp/vpDisplayX.h>
74 #include <visp/vpDisplayGTK.h>
75 #include <visp/vpDisplayGDI.h>
76 #include <visp/vpFeatureBuilder.h>
77 #include <visp/vpFeaturePoint.h>
78 #include <visp/vpHomogeneousMatrix.h>
79 #include <visp/vpImage.h>
80 #include <visp/vpImagePoint.h>
81 #include <visp/vpIoTools.h>
82 #include <visp/vpMath.h>
83 #include <visp/vpMeterPixelConversion.h>
84 #include <visp/vpParseArgv.h>
85 #include <visp/vpServo.h>
86 #include <visp/vpSimulatorViper850.h>
89 #define GETOPTARGS "cdh"
91 void usage(
const char *name,
const char *badparam);
92 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display);
102 void usage(
const char *name,
const char *badparam)
105 Tests a control law with the following characteristics:\n\
106 - eye-in-hand control\n\
107 - articular velocity are computed\n\
108 - servo on 4 points,\n\
109 - internal and external camera view displays.\n\
112 %s [-c] [-d] [-h]\n", name);
117 Disable the mouse click. Useful to automaze the \n\
118 execution of this program without humain intervention.\n\
121 Turn off the display.\n\
127 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
141 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display)
148 case 'c': click_allowed =
false;
break;
149 case 'd': display =
false;
break;
150 case 'h': usage(argv[0], NULL);
return false;
break;
153 usage(argv[0], optarg_);
158 if ((c == 1) || (c == -1)) {
160 usage(argv[0], NULL);
161 std::cerr <<
"ERROR: " << std::endl;
162 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
170 main(
int argc,
const char ** argv)
173 bool opt_click_allowed =
true;
174 bool opt_display =
true;
177 if (getOptions(argc, argv, opt_click_allowed, opt_display) ==
false) {
183 #if defined VISP_HAVE_X11
185 #elif defined VISP_HAVE_GDI
187 #elif defined VISP_HAVE_OPENCV
196 displayInt.
init(Iint,700,0,
"Internal view") ;
201 std::cout << std::endl ;
202 std::cout <<
"----------------------------------------------" << std::endl ;
203 std::cout <<
" Test program for vpServo " <<std::endl ;
204 std::cout <<
" Eye-in-hand task control, articular velocity are computed"
206 std::cout <<
" Simulation " << std::endl ;
207 std::cout <<
" task : servo 4 points " << std::endl ;
208 std::cout <<
"----------------------------------------------" << std::endl ;
209 std::cout << std::endl ;
224 for (
unsigned int i = 0 ; i < 4 ; i++)
225 point[i].track(cMo) ;
229 for (
unsigned int i = 0 ; i < 4 ; i++)
239 for (
unsigned int i = 0 ; i < 4 ; i++)
240 point[i].track(cdMo);
242 for (
unsigned int i = 0 ; i < 4 ; i++)
252 for (
unsigned int i = 0 ; i < 4 ; i++)
269 robot.initialiseObjectRelativeToCamera(cMo);
272 robot.setDesiredCameraPosition(cdMo);
276 robot.getCameraParameters(cam,Iint);
282 robot.getInternalView(Iint);
289 unsigned int iter=0 ;
293 std::cout <<
"---------------------------------------------" << iter <<std::endl ;
300 cMo = robot.get_cMo();
303 std::cout <<
"Initial robot position with respect to the object frame:\n";
308 for (
unsigned int i = 0 ; i < 4 ; i++)
310 point[i].
track(cMo) ;
319 robot.getInternalView(Iint);
323 if (opt_display && opt_click_allowed && iter == 1)
326 std::cout <<
"Click in the internal view window to continue..." << std::endl;
336 std::cout <<
"|| s - s* || " << ( task.
getError() ).sumSquare() <<std::endl ;
346 std::cout <<
"Final robot position with respect to the object frame:\n";
349 if (opt_display && opt_click_allowed)
352 std::cout <<
"Click in the internal view window to end..." << std::endl;
358 std::cout <<
"Catch a ViSP exception: " << e << std::endl;
366 vpERROR_TRACE(
"You do not have X11, OpenCV or GDI display functionalities or threading capabilities...");
The object displayed at the desired position is the same than the scene object defined in vpSceneObje...
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
Perspective projection without distortion model.
void print()
Print the matrix as a vector [T thetaU].
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
A 40cm by 40cm plate with 4 points at coordinates (-0.1,-0.1,0), (0.1,-0.1,0), (0.1,0.1,0), (0.1,0.1,0). Each point is represented by a circle with 2cm radius.
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)
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 double measureTimeMs()
static int wait(double t0, double t)
static void flush(const vpImage< unsigned char > &I)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
Class that defines what is a point.
Initialize the velocity controller.
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 setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType, const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE)
static double rad(double deg)
Simulator of Irisa's Viper S850 robot named Viper850.
Class that provides a data structure for the column vectors as well as a set of operations on these v...
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 setServo(const vpServoType &servo_type)
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &v)
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...