47 #include <visp3/core/vpCameraParameters.h> 48 #include <visp3/core/vpCylinder.h> 49 #include <visp3/core/vpHomogeneousMatrix.h> 50 #include <visp3/core/vpImage.h> 51 #include <visp3/core/vpIoTools.h> 52 #include <visp3/core/vpMath.h> 53 #include <visp3/core/vpTime.h> 54 #include <visp3/core/vpVelocityTwistMatrix.h> 55 #include <visp3/gui/vpDisplayD3D.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/vpImageIo.h> 61 #include <visp3/io/vpParseArgv.h> 62 #include <visp3/robot/vpSimulatorCamera.h> 63 #include <visp3/robot/vpWireFrameSimulator.h> 64 #include <visp3/visual_features/vpFeatureBuilder.h> 65 #include <visp3/vs/vpServo.h> 67 #define GETOPTARGS "dh" 69 #ifdef VISP_HAVE_DISPLAY 70 void usage(
const char *name,
const char *badparam);
71 bool getOptions(
int argc,
const char **argv,
bool &display);
81 void usage(
const char *name,
const char *badparam)
84 Demonstration of the wireframe simulator with a simple visual servoing.\n\ 86 The visual servoing consists in bringing the camera at a desired position\n\ 89 The visual features used to compute the pose of the camera and \n\ 90 thus the control law are two lines. These features are computed thanks \n\ 91 to the equation of a cylinder.\n\ 93 This demonstration explains also how to move the object around a world \n\ 94 reference frame. Here, the movment is a rotation around the x and y axis \n\ 95 at a given distance from the world frame. In fact the object trajectory \n\ 96 is on a sphere whose center is the origin of the world frame.\n\ 99 %s [-d] [-h]\n", name);
104 Turn off the display.\n\ 110 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
124 bool getOptions(
int argc,
const char **argv,
bool &display)
135 usage(argv[0], NULL);
140 usage(argv[0], optarg_);
146 if ((c == 1) || (c == -1)) {
148 usage(argv[0], NULL);
149 std::cerr <<
"ERROR: " << std::endl;
150 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
157 int main(
int argc,
const char **argv)
160 bool opt_display =
true;
163 if (getOptions(argc, argv, opt_display) ==
false) {
170 #if defined VISP_HAVE_X11 172 #elif defined VISP_HAVE_OPENCV 174 #elif defined VISP_HAVE_GDI 176 #elif defined VISP_HAVE_D3D9 178 #elif defined VISP_HAVE_GTK 184 display[0].
init(Iint, 100, 100,
"The internal view");
185 display[1].
init(Iext, 100, 100,
"The first external view");
196 float sampling_time = 0.040f;
221 cylinder.track(cdMo);
238 for (
int i = 0; i < 2; i++)
284 std::cout <<
"Click on a display" << std::endl;
306 double vitesse = 0.3;
309 while (iter++ < stop) {
330 if (iter % tempo < 200 && iter % tempo >= 0) {
332 e1[0] = -fabs(vitesse);
334 rapport = -vitesse / proj_e1[0];
339 if (iter % tempo < 300 && iter % tempo >= 200) {
341 e2[1] = -fabs(vitesse);
343 rapport = -vitesse / proj_e2[1];
348 if (iter % tempo < 500 && iter % tempo >= 300) {
350 e1[0] = -fabs(vitesse);
352 rapport = vitesse / proj_e1[0];
357 if (iter % tempo < 600 && iter % tempo >= 500) {
359 e2[1] = -fabs(vitesse);
361 rapport = vitesse / proj_e2[1];
396 std::cout <<
"|| s - s* || = " << (task.
getError()).sumSquare() << std::endl;
404 std::cout <<
"Catch an exception: " << e << std::endl;
411 std::cout <<
"You do not have X11, or GDI (Graphical Device Interface), or GTK functionalities to display images..." << std::endl;
412 std::cout <<
"Tip if you are on a unix-like system:" << std::endl;
413 std::cout <<
"- Install X11, configure again ViSP using cmake and build again this example" << std::endl;
414 std::cout <<
"Tip if you are on a windows-like system:" << std::endl;
415 std::cout <<
"- Install GDI, configure again ViSP using cmake and build again this example" << std::endl;
void setPosition(const vpHomogeneousMatrix &wMc)
Implementation of a matrix and operations on matrices.
A cylinder of 80cm length and 10cm radius.
VISP_EXPORT int wait(double t0, double t)
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
Implementation of an homogeneous matrix and operations on such kind of matrices.
Class that defines the simplest robot: a free flying camera.
vpHomogeneousMatrix get_fMo() const
void addFeature(vpBasicFeature &s, vpBasicFeature &s_star, unsigned int select=vpBasicFeature::FEATURE_ALL)
void set_fMo(const vpHomogeneousMatrix &fMo_)
Display for windows using GDI (available on any windows 32 platform).
void set_eJe(const vpMatrix &eJe_)
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
static const vpColor none
error that can be emited by ViSP classes.
vpHomogeneousMatrix inverse() const
void setExternalCameraPosition(const vpHomogeneousMatrix &cam_Mf)
vpHomogeneousMatrix getPosition() const
void setDesiredCameraPosition(const vpHomogeneousMatrix &cdMo_)
static void flush(const vpImage< unsigned char > &I)
VISP_EXPORT double measureTimeMs()
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
vpColVector secondaryTask(const vpColVector &de2dt, const bool &useLargeProjectionOperator=false)
virtual void setSamplingTime(const double &delta_t)
Display for windows using Direct3D 3rd party. Thus to enable this class Direct3D should be installed...
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.
Class that defines a 2D line visual feature which is composed by two parameters that are and ...
void initScene(const vpSceneObject &obj, const vpSceneDesiredObject &desiredObject)
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
void getExternalImage(vpImage< unsigned char > &I)
Implementation of a wire frame simulator. Compared to the vpSimulator class, it does not require thir...
void setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType, const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE)
static double rad(double deg)
void setExternalCameraParameters(const vpCameraParameters &cam)
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
void setCameraPositionRelObj(const vpHomogeneousMatrix &cMo_)
void getInternalImage(vpImage< unsigned char > &I)
Class that defines what is a cylinder.
static void setWindowPosition(const vpImage< unsigned char > &I, int winx, int winy)
Implementation of column vector and the associated operations.
static void displayFrame(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double size, const vpColor &color=vpColor::none, unsigned int thickness=1, const vpImagePoint &offset=vpImagePoint(0, 0))
void set_cVe(const vpVelocityTwistMatrix &cVe_)
void setInternalCameraParameters(const vpCameraParameters &cam)
void print(const vpServo::vpServoPrintType display_level=ALL, std::ostream &os=std::cout)
vpColVector getError() const
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
void get_eJe(vpMatrix &eJe)
void setServo(const vpServoType &servo_type)
vpHomogeneousMatrix getExternalCameraPosition() const