84 #include <visp3/core/vpMath.h>
85 #include <visp3/visual_features/vpFeatureThetaU.h>
86 #include <visp3/visual_features/vpFeatureTranslation.h>
87 #include <visp3/core/vpHomogeneousMatrix.h>
88 #include <visp3/core/vpIoTools.h>
89 #include <visp3/io/vpParseArgv.h>
90 #include <visp3/vs/vpServo.h>
91 #include <visp3/robot/vpSimulatorCamera.h>
94 #define GETOPTARGS "h"
96 void usage(
const char *name,
const char *badparam);
97 bool getOptions(
int argc,
const char **argv);
107 void usage(
const char *name,
const char *badparam)
110 Simulation of a 3D visual servoing:\n\
111 - eye-in-hand control law,\n\
112 - velocity computed in the camera frame,\n\
113 - without display.\n\
125 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
137 bool getOptions(
int argc,
const char **argv)
144 case 'h': usage(argv[0], NULL);
return false;
break;
147 usage(argv[0], optarg_);
152 if ((c == 1) || (c == -1)) {
154 usage(argv[0], NULL);
155 std::cerr <<
"ERROR: " << std::endl;
156 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
164 main(
int argc,
const char ** argv)
168 if (getOptions(argc, argv) ==
false) {
176 std::string username;
181 std::string logdirname;
183 logdirname =
"C:/temp/" + username;
185 logdirname =
"/tmp/" + username;
194 std::cerr << std::endl
195 <<
"ERROR:" << std::endl;
196 std::cerr <<
" Cannot create " << logdirname << std::endl;
200 std::string logfilename;
201 logfilename = logdirname +
"/log.dat";
204 std::ofstream flog(logfilename.c_str());
208 std::cout << std::endl ;
209 std::cout <<
"-------------------------------------------------------" << std::endl ;
210 std::cout <<
" Test program for vpServo " <<std::endl ;
211 std::cout <<
" Eye-in-hand task control, velocity computed in the camera frame" << std::endl ;
212 std::cout <<
" Simulation " << std::endl ;
213 std::cout <<
" task : 3D visual servoing " << std::endl ;
214 std::cout <<
"-------------------------------------------------------" << std::endl ;
215 std::cout << std::endl ;
228 robot.getPosition(wMc) ;
246 unsigned int iter=0 ;
248 while(iter++ < 200) {
249 std::cout <<
"------------------------------------" << iter <<std::endl ;
252 robot.getPosition(wMc) ;
275 w = lambda * tu_cRcd;
279 for (
unsigned int i=0; i<3; i++) {
281 velocity[i+3] = w[i];
288 std::cout <<
"|| s - s* || = " << ctcd.
t() <<
" " << tu_cRcd.
t() << std::endl;
291 flog << velocity.
t() <<
" " << ctcd.
t() <<
" " << tu_cRcd.
t() << std::endl;
299 std::cout <<
"Catch a ViSP exception: " << e << std::endl;
Implementation of a matrix and operations on matrices.
Implementation of an homogeneous matrix and operations on such kind of matrices.
Class that defines the simplest robot: a free flying camera.
error that can be emited by ViSP classes.
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
Implementation of a rotation matrix and operations on such kind of matrices.
void extract(vpRotationMatrix &R) const
static double rad(double deg)
Implementation of column vector and the associated operations.
Implementation of a pose vector and operations on poses.
vpHomogeneousMatrix inverse() const
static vpMatrix skew(const vpColVector &v)
Class that consider the case of a translation vector.
Implementation of a rotation vector as axis-angle minimal representation.