65 #include <visp/vpFeatureThetaU.h>
66 #include <visp/vpFeatureTranslation.h>
67 #include <visp/vpHomogeneousMatrix.h>
68 #include <visp/vpIoTools.h>
69 #include <visp/vpMath.h>
70 #include <visp/vpParseArgv.h>
71 #include <visp/vpServo.h>
72 #include <visp/vpSimulatorCamera.h>
75 #define GETOPTARGS "h"
77 void usage(
const char *name,
const char *badparam);
78 bool getOptions(
int argc,
const char **argv);
88 void usage(
const char *name,
const char *badparam)
91 Simulation of a 3D visual servoing:\n\
92 - eye-in-hand control law,\n\
93 - velocity computed in the camera frame,\n\
106 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
118 bool getOptions(
int argc,
const char **argv)
125 case 'h': usage(argv[0], NULL);
return false;
break;
128 usage(argv[0], optarg_);
133 if ((c == 1) || (c == -1)) {
135 usage(argv[0], NULL);
136 std::cerr <<
"ERROR: " << std::endl;
137 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
145 main(
int argc,
const char ** argv)
149 if (getOptions(argc, argv) ==
false) {
157 std::string username;
162 std::string logdirname;
164 logdirname =
"C:/temp/" + username;
166 logdirname =
"/tmp/" + username;
175 std::cerr << std::endl
176 <<
"ERROR:" << std::endl;
177 std::cerr <<
" Cannot create " << logdirname << std::endl;
181 std::string logfilename;
182 logfilename = logdirname +
"/log.dat";
185 std::ofstream flog(logfilename.c_str());
190 std::cout << std::endl ;
191 std::cout <<
"-------------------------------------------------------" << std::endl ;
192 std::cout <<
" Test program for vpServo " <<std::endl ;
193 std::cout <<
" Eye-in-hand task control, velocity computed in the camera frame" << std::endl ;
194 std::cout <<
" Simulation " << std::endl ;
195 std::cout <<
" task : 3D visual servoing " << std::endl ;
196 std::cout <<
"-------------------------------------------------------" << std::endl ;
197 std::cout << std::endl ;
246 task.addFeature(t,td) ;
247 task.addFeature(tu,tud) ;
255 unsigned int iter=0 ;
257 while(iter++ < 200) {
258 std::cout <<
"-----------------------------------" << iter <<std::endl ;
274 v = task.computeControlLaw() ;
277 if (iter==1) task.
print() ;
283 std::cout <<
"|| s - s* || = " << ( task.getError() ).sumSquare() <<std::endl ;
286 flog << v.
t() <<
" " << ( task.getError() ).t() << std::endl;
299 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...