 |
Visual Servoing Platform
version 3.3.0
|
56 #include <visp3/core/vpConfig.h>
57 #include <visp3/core/vpDebug.h>
59 #if ((defined(_WIN32) && !defined(WINRT_8_0)) || defined(VISP_HAVE_PTHREAD)) && \
60 (defined(VISP_HAVE_X11) || defined(VISP_HAVE_OPENCV) || defined(VISP_HAVE_GDI))
69 #include <visp3/core/vpCameraParameters.h>
70 #include <visp3/core/vpHomogeneousMatrix.h>
71 #include <visp3/core/vpImage.h>
72 #include <visp3/core/vpImagePoint.h>
73 #include <visp3/core/vpIoTools.h>
74 #include <visp3/core/vpMath.h>
75 #include <visp3/core/vpMeterPixelConversion.h>
76 #include <visp3/gui/vpDisplayGDI.h>
77 #include <visp3/gui/vpDisplayGTK.h>
78 #include <visp3/gui/vpDisplayX.h>
79 #include <visp3/io/vpParseArgv.h>
80 #include <visp3/robot/vpSimulatorAfma6.h>
81 #include <visp3/visual_features/vpFeatureBuilder.h>
82 #include <visp3/visual_features/vpFeaturePoint.h>
83 #include <visp3/vs/vpServo.h>
86 #define GETOPTARGS "cdh"
88 void usage(
const char *name,
const char *badparam);
89 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display);
99 void usage(
const char *name,
const char *badparam)
102 Tests a control law with the following characteristics:\n\
103 - eye-in-hand control\n\
104 - articular velocity are computed\n\
105 - servo on 4 points,\n\
106 - internal and external camera view displays.\n\
109 %s [-c] [-d] [-h]\n", name);
114 Disable the mouse click. Useful to automaze the \n\
115 execution of this program without humain intervention.\n\
118 Turn off the display.\n\
124 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
138 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display)
146 click_allowed =
false;
152 usage(argv[0], NULL);
157 usage(argv[0], optarg_);
163 if ((c == 1) || (c == -1)) {
165 usage(argv[0], NULL);
166 std::cerr <<
"ERROR: " << std::endl;
167 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
174 int main(
int argc,
const char **argv)
177 bool opt_click_allowed =
true;
178 bool opt_display =
true;
181 if (getOptions(argc, argv, opt_click_allowed, opt_display) ==
false) {
187 #if defined VISP_HAVE_X11
189 #elif defined VISP_HAVE_GDI
191 #elif defined VISP_HAVE_OPENCV
199 displayInt.
init(Iint, 700, 0,
"Internal view");
204 std::cout << std::endl;
205 std::cout <<
"----------------------------------------------" << std::endl;
206 std::cout <<
" Test program for vpServo " << std::endl;
207 std::cout <<
" Eye-in-hand task control, articular velocity are computed" << std::endl;
208 std::cout <<
" Simulation " << std::endl;
209 std::cout <<
" task : servo 4 points " << std::endl;
210 std::cout <<
"----------------------------------------------" << std::endl;
211 std::cout << std::endl;
225 for (
unsigned int i = 0; i < 4; i++)
230 for (
unsigned int i = 0; i < 4; i++)
240 for (
unsigned int i = 0; i < 4; i++)
241 point[i].track(cdMo);
243 for (
unsigned int i = 0; i < 4; i++)
253 for (
unsigned int i = 0; i < 4; i++)
271 robot.initialiseObjectRelativeToCamera(cMo);
274 robot.setDesiredCameraPosition(cdMo);
278 robot.getCameraParameters(cam, Iint);
283 robot.getInternalView(Iint);
290 unsigned int iter = 0;
292 while (iter++ < 500) {
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++) {
317 robot.getInternalView(Iint);
321 if (opt_display && opt_click_allowed && iter == 1) {
323 std::cout <<
"Click in the internal view window to continue..." << std::endl;
333 std::cout <<
"|| s - s* || " << (task.
getError()).sumSquare() << std::endl;
343 std::cout <<
"Final robot position with respect to the object frame:\n";
346 if (opt_display && opt_click_allowed) {
348 std::cout <<
"Click in the internal view window to end..." << std::endl;
354 std::cout <<
"Catch a ViSP exception: " << e << std::endl;
362 #if (!(defined(VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI)))
363 std::cout <<
"You do not have X11, or GTK, or GDI (Graphical Device Interface) functionalities to display images..." << std::endl;
364 std::cout <<
"Tip if you are on a unix-like system:" << std::endl;
365 std::cout <<
"- Install X11, configure again ViSP using cmake and build again this example" << std::endl;
366 std::cout <<
"Tip if you are on a windows-like system:" << std::endl;
367 std::cout <<
"- Install GDI, configure again ViSP using cmake and build again this example" << std::endl;
369 std::cout <<
"You do not have threading capabilities" << std::endl;
370 std::cout <<
"Tip:" << std::endl;
371 std::cout <<
"- Install pthread, configure again ViSP using cmake and build again this example" << std::endl;
Initialize the velocity controller.
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
VISP_EXPORT int wait(double t0, double t)
static double rad(double deg)
Generic class defining intrinsic camera parameters.
void print() const
Print the matrix as a pose vector .
Display for windows using GDI (available on any windows 32 platform).
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
Implementation of column vector and the associated operations.
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
void setServo(const vpServoType &servo_type)
VISP_EXPORT double measureTimeMs()
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
void print(const vpServo::vpServoPrintType display_level=ALL, std::ostream &os=std::cout)
Simulator of Irisa's gantry robot named Afma6.
static void display(const vpImage< unsigned char > &I)
void setWorldCoordinates(double oX, double oY, double oZ)
vpColVector getError() const
void addFeature(vpBasicFeature &s, vpBasicFeature &s_star, unsigned int select=vpBasicFeature::FEATURE_ALL)
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
Class that defines a 2D point visual feature which is composed by two parameters that are the cartes...
void setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType, const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE)
vpColVector computeControlLaw()
static void flush(const vpImage< unsigned char > &I)
Class that defines what is a point.
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
Implementation of an homogeneous matrix and operations on such kind of matrices.
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
error that can be emited by ViSP classes.
void track(const vpHomogeneousMatrix &cMo)