81 #include <visp3/core/vpHomogeneousMatrix.h>
82 #include <visp3/core/vpIoTools.h>
83 #include <visp3/core/vpMath.h>
84 #include <visp3/io/vpParseArgv.h>
85 #include <visp3/robot/vpSimulatorCamera.h>
86 #include <visp3/visual_features/vpFeatureThetaU.h>
87 #include <visp3/visual_features/vpFeatureTranslation.h>
88 #include <visp3/vs/vpServo.h>
91 #define GETOPTARGS "h"
93 void usage(
const char *name,
const char *badparam);
94 bool getOptions(
int argc,
const char **argv);
104 void usage(
const char *name,
const char *badparam)
107 Simulation of a 3D visual servoing:\n\
108 - eye-in-hand control law,\n\
109 - velocity computed in the camera frame,\n\
110 - without display.\n\
123 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
135 bool getOptions(
int argc,
const char **argv)
143 usage(argv[0],
nullptr);
147 usage(argv[0], optarg_);
152 if ((c == 1) || (c == -1)) {
154 usage(argv[0],
nullptr);
155 std::cerr <<
"ERROR: " << std::endl;
156 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
163 int main(
int argc,
const char **argv)
167 if (getOptions(argc, argv) ==
false) {
175 std::string username;
180 std::string logdirname;
182 logdirname =
"C:/temp/" + username;
184 logdirname =
"/tmp/" + username;
193 std::cerr << std::endl <<
"ERROR:" << std::endl;
194 std::cerr <<
" Cannot create " << logdirname << std::endl;
198 std::string logfilename;
199 logfilename = logdirname +
"/log.dat";
202 std::ofstream flog(logfilename.c_str());
206 std::cout << std::endl;
207 std::cout <<
"-------------------------------------------------------" << std::endl;
208 std::cout <<
" Test program for vpServo " << std::endl;
209 std::cout <<
" Eye-in-hand task control, velocity computed in the camera frame" << std::endl;
210 std::cout <<
" Simulation " << std::endl;
211 std::cout <<
" task : 3D visual servoing " << std::endl;
212 std::cout <<
"-------------------------------------------------------" << std::endl;
213 std::cout << std::endl;
226 robot.getPosition(wMc);
244 unsigned int iter = 0;
246 while (iter++ < 200) {
247 std::cout <<
"------------------------------------" << iter << std::endl;
250 robot.getPosition(wMc);
273 w = lambda * tu_cRcd;
277 for (
unsigned int i = 0; i < 3; i++) {
279 velocity[i + 3] = w[i];
286 std::cout <<
"|| s - s* || = " << ctcd.
t() <<
" " << tu_cRcd.
t() << std::endl;
289 flog << velocity.
t() <<
" " << ctcd.
t() <<
" " << tu_cRcd.
t() << std::endl;
297 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.