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;
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
unsigned int getWidth() const
Implementation of an homogeneous matrix and operations on such kind of matrices.
Class that defines the simplest robot: a free flying camera.
Display for windows using GDI (available on any windows 32 platform).
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
void addFeature(vpBasicFeature &s, vpBasicFeature &s_star, const unsigned int select=vpBasicFeature::FEATURE_ALL)
error that can be emited by ViSP classes.
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
void track(const vpHomogeneousMatrix &cMo)
Class that defines what is a sphere.
void setWorldCoordinates(const vpColVector &oP)
static void flush(const vpImage< unsigned char > &I)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
vpColVector secondaryTask(const vpColVector &de2dt, const bool &useLargeProjectionOperator=false)
vpColVector getError() const
vpColVector computeControlLaw()
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the OpenCV library. Thus to enable this class OpenC...
Generic class defining intrinsic camera parameters.
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
vpHomogeneousMatrix getPosition() const
Implementation of column vector and the associated operations.
vpHomogeneousMatrix inverse() const
void print(const vpServo::vpServoPrintType display_level=ALL, std::ostream &os=std::cout)
unsigned int getHeight() const
Class that defines 2D ellipse visual feature.
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
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)