47 #include <visp3/core/vpCameraParameters.h> 48 #include <visp3/core/vpHomogeneousMatrix.h> 49 #include <visp3/core/vpImage.h> 50 #include <visp3/core/vpIoTools.h> 51 #include <visp3/core/vpMath.h> 52 #include <visp3/core/vpTime.h> 53 #include <visp3/core/vpVelocityTwistMatrix.h> 54 #include <visp3/gui/vpDisplayD3D.h> 55 #include <visp3/gui/vpDisplayGDI.h> 56 #include <visp3/gui/vpDisplayGTK.h> 57 #include <visp3/gui/vpDisplayOpenCV.h> 58 #include <visp3/gui/vpDisplayX.h> 59 #include <visp3/io/vpImageIo.h> 60 #include <visp3/io/vpParseArgv.h> 61 #include <visp3/robot/vpSimulatorCamera.h> 62 #include <visp3/robot/vpWireFrameSimulator.h> 63 #include <visp3/visual_features/vpFeatureBuilder.h> 64 #include <visp3/visual_features/vpFeaturePoint.h> 65 #include <visp3/vs/vpServo.h> 67 #define GETOPTARGS "dh" 69 #ifdef VISP_HAVE_DISPLAY 71 void usage(
const char *name, std::string ipath,
const char *badparam);
72 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &display);
83 void usage(
const char *name, std::string ipath,
const char *badparam)
86 Demonstration of the wireframe simulator with a simple visual servoing.\n\ 88 The visual servoing consists in bringing the camera at a desired \n\ 89 position from the object.\n\ 91 The visual features used to compute the pose of the camera and \n\ 92 thus the control law are four points.\n\ 94 This demonstration explains also how to move the object around a world\n\ 95 reference frame. Here, the movement is a rotation around the x and y axis\n\ 96 at a given distance from the world frame. In fact the object trajectory\n\ 97 is on a sphere whose center is the origin of the world frame.\n\ 100 %s [-d] [-h]\n", name);
104 -i <input image path> %s\n\ 105 Set mire.pgm image input path.\n\ 106 From this path read \"mire/mire.pgm\" image.\n\ 107 Setting the VISP_INPUT_IMAGE_PATH environment variable \n\ 108 produces the same behaviour than using this option.\n\ 111 Turn off the display.\n\ 114 Print the help.\n", ipath.c_str());
117 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
132 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &display)
146 usage(argv[0], ipath, NULL);
151 usage(argv[0], ipath, optarg_);
157 if ((c == 1) || (c == -1)) {
159 usage(argv[0], ipath, NULL);
160 std::cerr <<
"ERROR: " << std::endl;
161 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
168 int main(
int argc,
const char **argv)
171 bool opt_display =
true;
172 std::string opt_ipath;
173 std::string env_ipath;
175 std::string filename;
178 if (getOptions(argc, argv, opt_ipath, opt_display) ==
false) {
186 #if defined VISP_HAVE_X11 188 #elif defined VISP_HAVE_OPENCV 190 #elif defined VISP_HAVE_GDI 192 #elif defined VISP_HAVE_D3D9 194 #elif defined VISP_HAVE_GTK 200 display[0].
init(Iint, 100, 100,
"The internal view");
201 display[1].
init(Iext1, 100, 100,
"The first external view");
202 display[2].
init(Iext2, 100, 100,
"The second external view");
216 float sampling_time = 0.040f;
242 for (
int i = 0; i < 4; i++)
247 for (
int i = 0; i < 4; i++)
251 for (
int i = 0; i < 4; i++)
252 point[i].track(cdMo);
255 for (
int i = 0; i < 4; i++)
269 for (
int i = 0; i < 4; i++)
274 std::list<vpImageSimulator> list;
278 for (
int i = 0; i < 4; i++)
300 if (!env_ipath.empty())
303 if (!opt_ipath.empty())
308 imsim.
init(filename.c_str(), X);
310 list.push_back(imsim);
363 std::cout <<
"Click on a display" << std::endl;
376 while (iter++ < stop) {
390 for (
int i = 0; i < 4; i++) {
411 camoMf.buildFrom(0, 0.0, 1.5, 0,
vpMath::rad(150), 0);
442 std::cout <<
"|| s - s* || = " << (task.
getError()).sumSquare() << std::endl;
450 std::cout <<
"Catch an exception: " << e << std::endl;
457 std::cout <<
"You do not have X11, or GDI (Graphical Device Interface), or GTK functionalities to display images..." << std::endl;
458 std::cout <<
"Tip if you are on a unix-like system:" << std::endl;
459 std::cout <<
"- Install X11, configure again ViSP using cmake and build again this example" << std::endl;
460 std::cout <<
"Tip if you are on a windows-like system:" << std::endl;
461 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.
VISP_EXPORT int wait(double t0, double t)
void init(const vpImage< unsigned char > &I, vpColVector *X)
void setWorldCoordinates(double oX, double oY, double oZ)
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.
void track(const vpHomogeneousMatrix &cMo)
vpHomogeneousMatrix inverse() const
Class that defines a 2D point visual feature which is composed by two parameters that are the cartes...
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)
void setMaxRotationVelocity(double maxVr)
Class that defines what is a point.
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 which enables to project an image in the 3D space and get the view of a virtual camera...
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)
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)
void setMaxTranslationVelocity(double maxVt)
vpHomogeneousMatrix getExternalCameraPosition() const