64 #include <visp/vpFeatureThetaU.h>
65 #include <visp/vpFeatureTranslation.h>
66 #include <visp/vpHomogeneousMatrix.h>
67 #include <visp/vpIoTools.h>
68 #include <visp/vpMath.h>
69 #include <visp/vpParseArgv.h>
70 #include <visp/vpServo.h>
71 #include <visp/vpSimulatorCamera.h>
74 #define GETOPTARGS "h"
76 void usage(
const char *name,
const char *badparam);
77 bool getOptions(
int argc,
const char **argv);
87 void usage(
const char *name,
const char *badparam)
90 Simulation of a 3D visual servoing:\n\
91 - eye-in-hand control law,\n\
92 - velocity computed in the camera frame,\n\
105 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
117 bool getOptions(
int argc,
const char **argv)
124 case 'h': usage(argv[0], NULL);
return false;
break;
127 usage(argv[0], optarg_);
132 if ((c == 1) || (c == -1)) {
134 usage(argv[0], NULL);
135 std::cerr <<
"ERROR: " << std::endl;
136 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
144 main(
int argc,
const char ** argv)
148 if (getOptions(argc, argv) ==
false) {
156 std::string username;
161 std::string logdirname;
163 logdirname =
"C:/temp/" + username;
165 logdirname =
"/tmp/" + username;
174 std::cerr << std::endl
175 <<
"ERROR:" << std::endl;
176 std::cerr <<
" Cannot create " << logdirname << std::endl;
180 std::string logfilename;
181 logfilename = logdirname +
"/log.dat";
184 std::ofstream flog(logfilename.c_str());
189 std::cout << std::endl ;
190 std::cout <<
"-------------------------------------------------------" << std::endl ;
191 std::cout <<
" Test program for vpServo " <<std::endl ;
192 std::cout <<
" Eye-in-hand task control, velocity computed in the camera frame" << std::endl ;
193 std::cout <<
" Simulation " << std::endl ;
194 std::cout <<
" task : 3D visual servoing " << std::endl ;
195 std::cout <<
"-------------------------------------------------------" << std::endl ;
196 std::cout << std::endl ;
247 task.addFeature(t,td) ;
248 task.addFeature(tu,tud) ;
256 unsigned int iter=0 ;
258 while(iter++ < 200) {
259 std::cout <<
"------------------------------------" << iter <<std::endl ;
275 v = task.computeControlLaw() ;
278 if (iter==1) task.
print() ;
284 std::cout <<
"|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ;
287 flog << v.
t() <<
" " << ( task.getError() ).t() << std::endl;
300 std::cout <<
"Catch a ViSP exception: " << e << std::endl;
Class that defines the translation visual feature .
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
Class that defines the simplest robot: a free flying camera.
error that can be emited by ViSP classes.
int print(std::ostream &s, unsigned int length, char const *intro=0)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
vpRowVector t() const
transpose of Vector
void getPosition(vpHomogeneousMatrix &wMc) const
void buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
Construction from translation vector and rotation matrix.
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
Class that defines a 3D visual feature from a axis/angle parametrization that represent the rotatio...