46 #include <visp3/core/vpCameraParameters.h> 47 #include <visp3/gui/vpDisplayOpenCV.h> 48 #include <visp3/gui/vpDisplayX.h> 49 #include <visp3/gui/vpDisplayGTK.h> 50 #include <visp3/gui/vpDisplayGDI.h> 51 #include <visp3/gui/vpDisplayD3D.h> 52 #include <visp3/visual_features/vpFeatureBuilder.h> 53 #include <visp3/visual_features/vpFeaturePoint.h> 54 #include <visp3/core/vpHomogeneousMatrix.h> 55 #include <visp3/core/vpImage.h> 56 #include <visp3/io/vpImageIo.h> 57 #include <visp3/core/vpIoTools.h> 58 #include <visp3/core/vpMath.h> 59 #include <visp3/io/vpParseArgv.h> 60 #include <visp3/vs/vpServo.h> 61 #include <visp3/robot/vpSimulatorCamera.h> 62 #include <visp3/core/vpTime.h> 63 #include <visp3/core/vpVelocityTwistMatrix.h> 64 #include <visp3/robot/vpWireFrameSimulator.h> 66 #define GETOPTARGS "dh" 68 #ifdef VISP_HAVE_DISPLAY 70 void usage(
const char *name, std::string ipath,
const char *badparam);
71 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &display);
82 void usage(
const char *name, std::string ipath,
const char *badparam)
85 Demonstration of the wireframe simulator with a simple visual servoing.\n\ 87 The visual servoing consists in bringing the camera at a desired \n\ 88 position from the object.\n\ 90 The visual features used to compute the pose of the camera and \n\ 91 thus the control law are four points.\n\ 93 This demonstration explains also how to move the object around a world\n\ 94 reference frame. Here, the movement 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);
103 -i <input image path> %s\n\ 104 Set mire.pgm image input path.\n\ 105 From this path read \"ViSP-images/mire/mire.pgm\" video.\n\ 106 Setting the VISP_INPUT_IMAGE_PATH environment variable \n\ 107 produces the same behaviour than using this option.\n\ 110 Turn off the display.\n\ 113 Print the help.\n", ipath.c_str());
116 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
132 bool getOptions(
int argc,
const char **argv, std::string &ipath,
bool &display)
139 case 'i': ipath = optarg_;
break;
140 case 'd': display =
false;
break;
141 case 'h': usage(argv[0],ipath, NULL);
return false;
break;
144 usage(argv[0],ipath, optarg_);
149 if ((c == 1) || (c == -1)) {
151 usage(argv[0], ipath, NULL);
152 std::cerr <<
"ERROR: " << std::endl;
153 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
162 main(
int argc,
const char ** argv)
165 bool opt_display =
true;
166 std::string opt_ipath;
167 std::string env_ipath;
169 std::string filename;
172 if (getOptions(argc, argv, opt_ipath, opt_display) ==
false) {
180 #if defined VISP_HAVE_X11 182 #elif defined VISP_HAVE_OPENCV 184 #elif defined VISP_HAVE_GDI 186 #elif defined VISP_HAVE_D3D9 188 #elif defined VISP_HAVE_GTK 195 display[0].
init(Iint, 100, 100,
"The internal view") ;
196 display[1].
init(Iext1, 100, 100,
"The first external view") ;
197 display[2].
init(Iext2, 100, 100,
"The second external view") ;
211 float sampling_time = 0.040f;
236 for (
int i = 0 ; i < 4 ; i++)
241 for (
int i = 0 ; i < 4 ; i++)
245 for (
int i = 0 ; i < 4 ; i++)
246 point[i].track(cdMo);
249 for (
int i = 0 ; i < 4 ; i++)
263 for (
int i = 0 ; i < 4 ; i++)
268 std::list<vpImageSimulator> list;
272 for (
int i = 0; i < 4; i++) X[i].resize(3);
292 if (! env_ipath.empty())
295 if (!opt_ipath.empty())
300 imsim.
init(filename.c_str(), X);
302 list.push_back(imsim);
355 std::cout <<
"Click on a display" << std::endl;
382 for (
int i = 0 ; i < 4 ; i++)
384 point[i].
track(cMo) ;
433 std::cout <<
"|| s - s* || = " << ( task.
getError() ).sumSquare() <<std::endl ;
442 std::cout <<
"Catch an exception: " << e << std::endl;
450 vpERROR_TRACE(
"You do not have X11, OpenCV, GDI, D3D9 or GTK display functionalities...");
void setPosition(const vpHomogeneousMatrix &wMc)
The object displayed at the desired position is the same than the scene object defined in vpSceneObje...
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 setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
void setMaxTranslationVelocity(const double maxVt)
Implementation of an homogeneous matrix and operations on such kind of matrices.
Class that defines the simplest robot: a free flying camera.
A 40cm by 40cm plate with 4 points at coordinates (-0.1,-0.1,0), (0.1,-0.1,0), (0.1,0.1,0), (0.1,0.1,0). Each point is represented by a circle with 2cm radius.
void set_fMo(const vpHomogeneousMatrix &fMo_)
Display for windows using GDI (available on any windows 32 platform).
void set_eJe(const vpMatrix &eJe_)
Define the X11 console to display images.
void addFeature(vpBasicFeature &s, vpBasicFeature &s_star, const unsigned int select=vpBasicFeature::FEATURE_ALL)
static const vpColor none
error that can be emited by ViSP classes.
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 setExternalCameraPosition(const vpHomogeneousMatrix &cam_Mf)
void setDesiredCameraPosition(const vpHomogeneousMatrix &cdMo_)
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.
virtual void setSamplingTime(const double &delta_t)
Display for windows using Direct3D.
vpColVector getError() const
vpHomogeneousMatrix get_fMo() const
vpColVector computeControlLaw()
virtual void setWindowPosition(int winx, int winy)=0
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the opencv library.
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+ library version 1.2.
vpHomogeneousMatrix getPosition() const
Implementation of a velocity twist matrix and operations on such kind of matrices.
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 setCameraPositionRelObj(const vpHomogeneousMatrix &cMo_)
VISP_EXPORT double measureTimeMs()
void setMaxRotationVelocity(const double maxVr)
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, vpImagePoint offset=vpImagePoint(0, 0))
void getInternalImage(vpImage< unsigned char > &I)
void setWorldCoordinates(const double oX, const double oY, const double oZ)
Implementation of column vector and the associated operations.
void set_cVe(const vpVelocityTwistMatrix &cVe_)
vpHomogeneousMatrix inverse() const
void setInternalCameraParameters(const vpCameraParameters &cam)
void print(const vpServo::vpServoPrintType display_level=ALL, std::ostream &os=std::cout)
virtual bool getClick(bool blocking=true)=0
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