55 #include <visp/vpImage.h>
56 #include <visp/vpImageIo.h>
57 #include <visp/vpDisplayOpenCV.h>
58 #include <visp/vpDisplayX.h>
59 #include <visp/vpDisplayGTK.h>
60 #include <visp/vpDisplayGDI.h>
61 #include <visp/vpDisplayD3D.h>
62 #include <visp/vpCameraParameters.h>
63 #include <visp/vpTime.h>
65 #include <visp/vpMath.h>
66 #include <visp/vpHomogeneousMatrix.h>
67 #include <visp/vpFeaturePoint.h>
68 #include <visp/vpServo.h>
69 #include <visp/vpRobotCamera.h>
70 #include <visp/vpFeatureBuilder.h>
71 #include <visp/vpParseArgv.h>
72 #include <visp/vpIoTools.h>
73 #include <visp/vpVelocityTwistMatrix.h>
74 #include <visp/vpWireFrameSimulator.h>
76 #define GETOPTARGS "dh"
78 #if (defined (VISP_HAVE_X11) || defined(VISP_HAVE_OPENCV) || defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) || defined(VISP_HAVE_GTK))
89 void usage(
const char *name, std::string ipath,
const char *badparam)
92 Demonstration of the wireframe simulator with a simple visual servoing.\n\
94 The visual servoing consists in bringing the camera at a desired \n\
95 position from the object.\n\
97 The visual features used to compute the pose of the camera and \n\
98 thus the control law are four points.\n\
100 This demonstration explains also how to move the object around a world\n\
101 reference frame. Here, the movement is a rotation around the x and y axis\n\
102 at a given distance from the world frame. In fact the object trajectory\n\
103 is on a sphere whose center is the origin of the world frame.\n\
106 %s [-d] [-h]\n", name);
110 -i <input image path> %s\n\
111 Set mire.pgm image input path.\n\
112 From this path read \"ViSP-images/mire/mire.pgm\" video.\n\
113 Setting the VISP_INPUT_IMAGE_PATH environment variable \n\
114 produces the same behaviour than using this option.\n\
117 Turn off the display.\n\
120 Print the help.\n", ipath.c_str());
123 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
139 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &display)
146 case 'i': ipath = optarg;
break;
147 case 'd': display =
false;
break;
148 case 'h': usage(argv[0],ipath, NULL);
return false;
break;
151 usage(argv[0],ipath, optarg);
156 if ((c == 1) || (c == -1)) {
158 usage(argv[0], ipath, NULL);
159 std::cerr <<
"ERROR: " << std::endl;
160 std::cerr <<
" Bad argument " << optarg << std::endl << std::endl;
169 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
203 display[0].
init(Iint, 100, 100,
"The internal view") ;
204 display[1].
init(Iext1, 100, 100,
"The first external view") ;
205 display[2].
init(Iext2, 100, 100,
"The second external view") ;
225 float sampling_time = 0.040f;
241 for (
int i = 0 ; i < 4 ; i++)
246 for (
int i = 0 ; i < 4 ; i++)
253 for (
int i = 0 ; i < 4 ; i++)
254 point[i].track(cdMo);
257 for (
int i = 0 ; i < 4 ; i++)
271 for (
int i = 0 ; i < 4 ; i++)
276 std::list<vpImageSimulator> list;
280 for (
int i = 0; i < 4; i++) X[i].resize(3);
297 char *ptenv = getenv(
"VISP_INPUT_IMAGE_PATH");
301 if (! env_ipath.empty())
304 if (!opt_ipath.empty())
311 imsim.
init(filename.c_str(), X);
315 vpTRACE(
"You need the ViSP data ");
320 list.push_back(imsim);
380 std::cout <<
"Click on a display" << std::endl;
406 for (
int i = 0 ; i < 4 ; i++)
408 point[i].
track(cMo) ;
481 vpERROR_TRACE(
"You do not have X11, OpenCV, GDI, D3D9 or GTK display functionalities...");
Definition of the vpMatrix class.
void setSamplingTime(const double &delta_t)
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
Display for windows using GDI (available on any windows 32 platform).
Define the X11 console to display images.
void addFeature(vpBasicFeature &s, vpBasicFeature &s_star, const unsigned int select=vpBasicFeature::FEATURE_ALL)
create a new ste of two visual features
static const vpColor none
void setLambda(double _lambda)
set the gain lambda
void setCameraPositionRelObj(const vpHomogeneousMatrix cMo)
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
void track(const vpHomogeneousMatrix &cMo)
Class that defines a 2D point visual feature which is composed by two parameters that are the cartes...
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
static double measureTimeMs()
static int wait(double t0, double t)
void set_cVe(vpVelocityTwistMatrix &_cVe)
static void flush(const vpImage< unsigned char > &I)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
Class that defines what is a point.
The vpRotationMatrix considers the particular case of a rotation matrix.
Display for windows using Direct3D.
void setExternalCameraPosition(const vpHomogeneousMatrix camMf)
void kill()
destruction (memory deallocation if required)
vpHomogeneousMatrix get_fMo() const
vpColVector computeControlLaw()
compute the desired control law
virtual void setWindowPosition(int winx, int winy)=0
Class that defines the simplest robot: a free flying camera.
void getInternalImage(vpImage< vpRGBa > &I)
static void display(const vpImage< unsigned char > &I)
void set_eJe(vpMatrix &_eJe)
The vpDisplayOpenCV allows to display image using the opencv library.
Generic class defining intrinsic camera parameters.
void init(const vpImage< unsigned char > &I, vpColVector *_X)
Class which enables to project an image in the 3D space and get the view of a virtual camera...
The vpDisplayGTK allows to display image using the GTK+ library version 1.2.
void setDesiredCameraPosition(const vpHomogeneousMatrix cdMo)
void getPosition(vpColVector &q)
Class that consider the particular case of twist transformation matrix that allows to transform a vel...
void setPosition(const vpRobot::vpControlFrameType, const vpColVector &)
Set a displacement (frame has to be specified) in position control.
Implementation of a wire frame simulator. Compared to the vpSimulator class, it does not require thir...
static void displayFrame(const vpImage< unsigned char > &I, const vpHomogeneousMatrix &cMo, const vpCameraParameters &cam, double size, const vpColor &color, unsigned int thickness=1)
void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
Construction from translation vector and rotation matrix.
void setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType, const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE)
Set the type of the interaction matrix (current, mean, desired, user).
static double rad(double deg)
Class that provides a data structure for the column vectors as well as a set of operations on these v...
The pose is a complete representation of every rigid motion in the euclidian space.
vpHomogeneousMatrix inverse() const
vpHomogeneousMatrix get_cMo() const
void initScene(vpSceneObject obj, vpSceneDesiredObject desiredObject)
void get_eJe(vpMatrix &_eJe)
void print(const vpServo::vpServoPrintType display_level=ALL, std::ostream &os=std::cout)
void setInternalCameraParameters(const vpCameraParameters cam)
virtual bool getClick(bool blocking=true)=0
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
Class required to compute the visual servoing control law.
void getExternalImage(vpImage< vpRGBa > &I)
void setExternalCameraParameters(const vpCameraParameters cam)
Class that consider the case of a translation vector.
void setServo(vpServoType _servo_type)
Choice of the visual servoing control law.
void set_fMo(const vpHomogeneousMatrix &fMo)
vpHomogeneousMatrix getExternalCameraPosition() const
void setWorldCoordinates(const double ox, const double oy, const double oz)
Set the point world coordinates. We mean here the coordinates of the point in the object frame...