74 #include <visp3/core/vpConfig.h>
75 #include <visp3/core/vpHomogeneousMatrix.h>
76 #include <visp3/core/vpIoTools.h>
77 #include <visp3/core/vpMath.h>
78 #include <visp3/core/vpThetaUVector.h>
79 #include <visp3/core/vpTranslationVector.h>
80 #include <visp3/io/vpParseArgv.h>
81 #include <visp3/robot/vpSimulatorCamera.h>
84 #define GETOPTARGS "h"
86 #ifdef ENABLE_VISP_NAMESPACE
90 void usage(
const char *name,
const char *badparam);
91 bool getOptions(
int argc,
const char **argv);
101 void usage(
const char *name,
const char *badparam)
104 Simulation of a 3D visual servoing:\n\
105 - eye-in-hand control law,\n\
106 - velocity computed in the camera frame,\n\
107 - without display.\n\
120 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
132 bool getOptions(
int argc,
const char **argv)
140 usage(argv[0],
nullptr);
144 usage(argv[0], optarg_);
149 if ((c == 1) || (c == -1)) {
151 usage(argv[0],
nullptr);
152 std::cerr <<
"ERROR: " << std::endl;
153 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
160 int main(
int argc,
const char **argv)
164 if (getOptions(argc, argv) ==
false) {
171 std::string username;
176 std::string logdirname;
178 logdirname =
"C:/temp/" + username;
180 logdirname =
"/tmp/" + username;
190 std::cerr << std::endl <<
"ERROR:" << std::endl;
191 std::cerr <<
" Cannot create " << logdirname << std::endl;
195 std::string logfilename;
196 logfilename = logdirname +
"/log.dat";
199 std::ofstream flog(logfilename.c_str());
203 std::cout << std::endl;
204 std::cout <<
"-------------------------------------------------------" << std::endl;
205 std::cout <<
" Test program without vpServo and vpFeature classes " << std::endl;
206 std::cout <<
" Eye-in-hand task control, velocity computed in the camera frame" << std::endl;
207 std::cout <<
" Simulation " << std::endl;
208 std::cout <<
" task : 3D visual servoing " << std::endl;
209 std::cout <<
"-------------------------------------------------------" << std::endl;
210 std::cout << std::endl;
223 robot.getPosition(wMc);
241 unsigned int iter = 0;
243 while (iter++ < 200) {
244 std::cout <<
"-----------------------------------" << iter << std::endl;
247 robot.getPosition(wMc);
266 v = -lambda * cRcd * cdtc;
269 w = -lambda * tu_cdRc;
273 for (
unsigned int i = 0; i < 3; i++) {
275 velocity[i + 3] = w[i];
282 std::cout <<
"|| s - s* || = " << cdtc.t() <<
" " << tu_cdRc.t() << std::endl;
285 flog << velocity.t() <<
" " << cdtc.t() <<
" " << tu_cdRc.t() << std::endl;
292 std::cout <<
"Catch a ViSP exception: " << e << std::endl;
Implementation of column vector and the associated operations.
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)
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.
vpRotationMatrix inverse() const
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.