57 #include <visp/vpFeatureBuilder.h>
58 #include <visp/vpFeatureEllipse.h>
59 #include <visp/vpHomogeneousMatrix.h>
60 #include <visp/vpMath.h>
61 #include <visp/vpParseArgv.h>
62 #include <visp/vpRobotCamera.h>
63 #include <visp/vpServo.h>
64 #include <visp/vpSphere.h>
65 #include <visp/vpSimulatorCamera.h>
68 #define GETOPTARGS "h"
70 void usage(
const char *name,
const char *badparam);
71 bool getOptions(
int argc,
const char **argv);
81 void usage(
const char *name,
const char *badparam)
84 Simulation of a 2D visual servoing on a sphere:\n\
85 - eye-in-hand control law,\n\
86 - velocity computed in the camera frame,\n\
88 - a secondary task is the added.\n\
100 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
113 bool getOptions(
int argc,
const char **argv)
120 case 'h': usage(argv[0], NULL);
return false;
break;
123 usage(argv[0], optarg_);
128 if ((c == 1) || (c == -1)) {
130 usage(argv[0], NULL);
131 std::cerr <<
"ERROR: " << std::endl;
132 std::cerr <<
" Bad argument " << optarg_ << std::endl << std::endl;
140 main(
int argc,
const char ** argv)
144 if (getOptions(argc, argv) ==
false) {
151 std::cout << std::endl ;
152 std::cout <<
"-------------------------------------------------------" << std::endl ;
153 std::cout <<
" Test program for vpServo " <<std::endl ;
154 std::cout <<
" Simulation " << std::endl ;
155 std::cout <<
" task : servo a sphere with a secondary task" << std::endl ;
156 std::cout <<
"-------------------------------------------------------" << std::endl ;
157 std::cout << std::endl ;
196 std::cout << std::endl ;
205 unsigned int iter=0 ;
209 std::cout <<
"---------------------------------------------" << iter <<std::endl ;
229 std::cout <<
"de2dt :"<< de2dt.
t() << std::endl;
232 std::cout <<
"(I-WpW)de2dt :"<< sec.
t() << std::endl;
234 if (iter>20) v += sec ;
239 std::cout <<
"|| s - s* || = " << ( task.
getError() ).sumSquare() <<std::endl ;
248 std::cout <<
"Catch a ViSP exception: " << e << std::endl;
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
Class that defines the simplest robot: a free flying camera.
void addFeature(vpBasicFeature &s, vpBasicFeature &s_star, const unsigned int select=vpBasicFeature::FEATURE_ALL)
error that can be emited by ViSP classes.
void track(const vpHomogeneousMatrix &cMo)
Class that defines what is a sphere.
void setWorldCoordinates(const vpColVector &oP)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
vpColVector secondaryTask(const vpColVector &de2dt)
vpColVector getError() const
vpColVector computeControlLaw()
vpRowVector t() const
Transpose of a vector.
void getPosition(vpHomogeneousMatrix &wMc) const
Class that provides a data structure for the column vectors as well as a set of operations on these v...
vpHomogeneousMatrix inverse() const
void print(const vpServo::vpServoPrintType display_level=ALL, std::ostream &os=std::cout)
Class that defines 2D ellipse visual feature.
static void create(vpFeaturePoint &s, const vpCameraParameters &cam, const vpDot &d)
void setServo(const vpServoType &servo_type)