 |
Visual Servoing Platform
version 3.3.0
|
53 #include <visp3/core/vpHomogeneousMatrix.h>
54 #include <visp3/core/vpMath.h>
55 #include <visp3/core/vpSphere.h>
56 #include <visp3/gui/vpDisplayGDI.h>
57 #include <visp3/gui/vpDisplayGTK.h>
58 #include <visp3/gui/vpDisplayOpenCV.h>
59 #include <visp3/gui/vpDisplayX.h>
60 #include <visp3/io/vpParseArgv.h>
61 #include <visp3/robot/vpSimulatorCamera.h>
62 #include <visp3/visual_features/vpFeatureBuilder.h>
63 #include <visp3/visual_features/vpFeatureEllipse.h>
64 #include <visp3/vs/vpServo.h>
65 #include <visp3/vs/vpServoDisplay.h>
68 #define GETOPTARGS "cdh"
70 void usage(
const char *name,
const char *badparam);
71 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display);
81 void usage(
const char *name,
const char *badparam)
84 Simulation of a 2D visual servoing on a sphere:\n\
85 - eye-in-hand control law,\n\
86 - velocity computed in the camera frame,\n\
87 - display the camera view,\n\
88 - a secondary task is the added.\n\
91 %s [-c] [-d] [-h]\n", name);
97 Disable the mouse click. Useful to automaze the \n\
98 execution of this program without humain intervention.\n\
101 Turn off the display.\n\
107 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
122 bool getOptions(
int argc,
const char **argv,
bool &click_allowed,
bool &display)
130 click_allowed =
false;
136 usage(argv[0], NULL);
141 usage(argv[0], optarg_);
147 if ((c == 1) || (c == -1)) {
149 usage(argv[0], NULL);
150 std::cerr <<
"ERROR: " << std::endl;
151 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
158 int main(
int argc,
const char **argv)
161 bool opt_display =
true;
162 bool opt_click_allowed =
true;
165 if (getOptions(argc, argv, opt_click_allowed, opt_display) ==
false) {
166 return(EXIT_FAILURE);
172 #if defined VISP_HAVE_X11
174 #elif defined VISP_HAVE_GTK
176 #elif defined VISP_HAVE_GDI
178 #elif defined VISP_HAVE_OPENCV
183 #if defined(VISP_HAVE_X11) || defined(VISP_HAVE_GTK) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_OPENCV)
185 display.init(I, 100, 100,
"Camera view...");
196 double px = 600, py = 600;
240 std::cout << std::endl;
249 unsigned int iter = 0;
251 while (iter++ < 200) {
252 std::cout <<
"---------------------------------------------" << iter << std::endl;
278 std::cout <<
"de2dt :" << de2dt.
t() << std::endl;
281 std::cout <<
"(I-WpW)de2dt :" << sec.
t() << std::endl;
289 std::cout <<
"|| s - s* || = " << (task.
getError()).sumSquare() << std::endl;
297 std::cout <<
"Catch a ViSP exception: " << e << std::endl;
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Class that defines 2D ellipse visual feature.
Generic class defining intrinsic camera parameters.
Display for windows using GDI (available on any windows 32 platform).
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
Class that defines the simplest robot: a free flying camera.
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)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
vpHomogeneousMatrix getPosition() const
void print(const vpServo::vpServoPrintType display_level=ALL, std::ostream &os=std::cout)
static void display(const vpImage< unsigned char > &I)
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
void setWorldCoordinates(const vpColVector &oP)
unsigned int getHeight() const
vpColVector secondaryTask(const vpColVector &de2dt, const bool &useLargeProjectionOperator=false)
vpColVector getError() const
Class that defines what is a sphere.
void addFeature(vpBasicFeature &s, vpBasicFeature &s_star, unsigned int select=vpBasicFeature::FEATURE_ALL)
vpColVector computeControlLaw()
static void flush(const vpImage< unsigned char > &I)
vpHomogeneousMatrix inverse() const
Implementation of an homogeneous matrix and operations on such kind of matrices.
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
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)
error that can be emited by ViSP classes.
void track(const vpHomogeneousMatrix &cMo)
unsigned int getWidth() const