81 #include <visp3/core/vpConfig.h>
82 #include <visp3/core/vpHomogeneousMatrix.h>
83 #include <visp3/core/vpIoTools.h>
84 #include <visp3/core/vpMath.h>
85 #include <visp3/io/vpParseArgv.h>
86 #include <visp3/robot/vpSimulatorCamera.h>
87 #include <visp3/visual_features/vpFeatureThetaU.h>
88 #include <visp3/visual_features/vpFeatureTranslation.h>
89 #include <visp3/vs/vpServo.h>
92 #define GETOPTARGS "h"
94 #ifdef ENABLE_VISP_NAMESPACE
98 void usage(
const char *name,
const char *badparam);
99 bool getOptions(
int argc,
const char **argv);
109 void usage(
const char *name,
const char *badparam)
112 Simulation of a 3D visual servoing:\n\
113 - eye-in-hand control law,\n\
114 - velocity computed in the camera frame,\n\
115 - without display.\n\
128 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
140 bool getOptions(
int argc,
const char **argv)
148 usage(argv[0],
nullptr);
152 usage(argv[0], optarg_);
157 if ((c == 1) || (c == -1)) {
159 usage(argv[0],
nullptr);
160 std::cerr <<
"ERROR: " << std::endl;
161 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
168 int main(
int argc,
const char **argv)
172 if (getOptions(argc, argv) ==
false) {
180 std::string username;
185 std::string logdirname;
187 logdirname =
"C:/temp/" + username;
189 logdirname =
"/tmp/" + username;
198 std::cerr << std::endl <<
"ERROR:" << std::endl;
199 std::cerr <<
" Cannot create " << logdirname << std::endl;
203 std::string logfilename;
204 logfilename = logdirname +
"/log.dat";
207 std::ofstream flog(logfilename.c_str());
211 std::cout << std::endl;
212 std::cout <<
"-------------------------------------------------------" << std::endl;
213 std::cout <<
" Test program for vpServo " << std::endl;
214 std::cout <<
" Eye-in-hand task control, velocity computed in the camera frame" << std::endl;
215 std::cout <<
" Simulation " << std::endl;
216 std::cout <<
" task : 3D visual servoing " << std::endl;
217 std::cout <<
"-------------------------------------------------------" << std::endl;
218 std::cout << std::endl;
231 robot.getPosition(wMc);
249 unsigned int iter = 0;
251 while (iter++ < 200) {
252 std::cout <<
"------------------------------------" << iter << std::endl;
255 robot.getPosition(wMc);
278 w = lambda * tu_cRcd;
282 for (
unsigned int i = 0; i < 3; i++) {
284 velocity[i + 3] = w[i];
291 std::cout <<
"|| s - s* || = " << ctcd.
t() <<
" " << tu_cRcd.
t() << std::endl;
294 flog << velocity.
t() <<
" " << ctcd.
t() <<
" " << tu_cRcd.
t() << std::endl;
302 std::cout <<
"Catch a ViSP exception: " << e << std::endl;
Implementation of column vector and the associated operations.
static vpMatrix skew(const vpColVector &v)
error that can be emitted by ViSP classes.
Implementation of an homogeneous matrix and operations on such kind of matrices.
vpHomogeneousMatrix inverse() const
void extract(vpRotationMatrix &R) const
static double rad(double deg)
Implementation of a matrix and operations on matrices.
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
Implementation of a pose vector and operations on poses.
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel) VP_OVERRIDE
Implementation of a rotation matrix and operations on such kind of matrices.
Class that defines the simplest robot: a free flying camera.
Implementation of a rotation vector as axis-angle minimal representation.
Class that consider the case of a translation vector.