79#include <visp3/core/vpConfig.h>
80#include <visp3/core/vpHomogeneousMatrix.h>
81#include <visp3/core/vpIoTools.h>
82#include <visp3/core/vpMath.h>
83#include <visp3/io/vpParseArgv.h>
84#include <visp3/robot/vpSimulatorCamera.h>
85#include <visp3/visual_features/vpFeatureThetaU.h>
86#include <visp3/visual_features/vpFeatureTranslation.h>
87#include <visp3/vs/vpServo.h>
92#ifdef ENABLE_VISP_NAMESPACE
96void usage(
const char *name,
const char *badparam);
97bool getOptions(
int argc,
const char **argv);
107void usage(
const char *name,
const char *badparam)
110Simulation of a 3D visual servoing:\n\
111- eye-in-hand control law,\n\
112- velocity computed in the camera frame,\n\
126 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
138bool getOptions(
int argc,
const char **argv)
146 usage(argv[0],
nullptr);
150 usage(argv[0], optarg_);
155 if ((c == 1) || (c == -1)) {
157 usage(argv[0],
nullptr);
158 std::cerr <<
"ERROR: " << std::endl;
159 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
166int main(
int argc,
const char **argv)
170 if (getOptions(argc, argv) ==
false) {
178 std::string username;
183 std::string logdirname;
185 logdirname =
"C:/temp/" + username;
187 logdirname =
"/tmp/" + username;
196 std::cerr << std::endl <<
"ERROR:" << std::endl;
197 std::cerr <<
" Cannot create " << logdirname << std::endl;
201 std::string logfilename;
202 logfilename = logdirname +
"/log.dat";
205 std::ofstream flog(logfilename.c_str());
209 std::cout << std::endl;
210 std::cout <<
"-------------------------------------------------------" << std::endl;
211 std::cout <<
" Test program for vpServo " << std::endl;
212 std::cout <<
" Eye-in-hand task control, velocity computed in the camera frame" << std::endl;
213 std::cout <<
" Simulation " << std::endl;
214 std::cout <<
" task : 3D visual servoing " << std::endl;
215 std::cout <<
"-------------------------------------------------------" << std::endl;
216 std::cout << std::endl;
229 robot.getPosition(wMc);
247 unsigned int iter = 0;
249 while (iter++ < 200) {
250 std::cout <<
"------------------------------------" <<
iter << std::endl;
253 robot.getPosition(wMc);
258 cMcd =
cMo * cdMo.inverse();
276 w = lambda * tu_cRcd;
280 for (
unsigned int i = 0;
i < 3;
i++) {
282 velocity[
i + 3] =
w[
i];
289 std::cout <<
"|| s - s* || = " << ctcd.
t() <<
" " << tu_cRcd.
t() << std::endl;
292 flog << velocity.
t() <<
" " << ctcd.
t() <<
" " << tu_cRcd.
t() << std::endl;
300 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.
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.