64 #include <visp/vpMath.h>
65 #include <visp/vpHomogeneousMatrix.h>
66 #include <visp/vpFeatureEllipse.h>
67 #include <visp/vpCircle.h>
68 #include <visp/vpServo.h>
69 #include <visp/vpRobotCamera.h>
70 #include <visp/vpFeatureBuilder.h>
74 #include <visp/vpException.h>
75 #include <visp/vpMatrixException.h>
78 #include <visp/vpDebug.h>
79 #include <visp/vpParseArgv.h>
84 #define GETOPTARGS "h"
94 void usage(
const char *name,
const char *badparam)
97 Simulation of a 2D visual servoing on a circle:\n\
98 - eye-in-hand control law,\n\
99 - velocity computed in the camera frame,\n\
100 - without display.\n\
112 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
124 bool getOptions(
int argc,
const char **argv)
131 case 'h': usage(argv[0], NULL);
return false;
break;
134 usage(argv[0], optarg);
139 if ((c == 1) || (c == -1)) {
141 usage(argv[0], NULL);
142 std::cerr <<
"ERROR: " << std::endl;
143 std::cerr <<
" Bad argument " << optarg << std::endl << std::endl;
151 main(
int argc,
const char ** argv)
154 if (getOptions(argc, argv) ==
false) {
161 std::cout << std::endl ;
162 std::cout <<
"-------------------------------------------------------" << std::endl ;
163 std::cout <<
" Test program for vpServo " <<std::endl ;
164 std::cout <<
" Simulation " << std::endl ;
165 std::cout <<
" task : servo a circle " << std::endl ;
166 std::cout <<
"-------------------------------------------------------" << std::endl ;
167 std::cout << std::endl ;
170 vpTRACE(
"sets the initial camera location " ) ;
184 vpTRACE(
"sets the circle coordinates in the world frame " ) ;
188 vpTRACE(
"sets the desired position of the visual feature ") ;
193 vpTRACE(
"project : computes the circle coordinates in the camera frame and its 2D coordinates" ) ;
195 vpTRACE(
"sets the current position of the visual feature ") ;
201 vpTRACE(
"\t we want an eye-in-hand control law") ;
202 vpTRACE(
"\t robot is controlled in the camera frame") ;
205 vpTRACE(
"\t we want to see a circle on a circle..") ;
206 std::cout << std::endl ;
213 vpTRACE(
"Display task information " ) ;
216 unsigned int iter=0 ;
220 std::cout <<
"---------------------------------------------" << iter <<std::endl ;
223 if (iter==1)
vpTRACE(
"\t\t get the robot position ") ;
225 if (iter==1)
vpTRACE(
"\t\t new circle position ") ;
231 if (iter==1)
vpTRACE(
"\t\t compute the control law ") ;
234 std::cout << task.
rankJ1 <<std::endl ;
235 if (iter==1)
vpTRACE(
"\t\t send the camera velocity to the controller ") ;
243 vpTRACE(
"Display task information " ) ;
unsigned int rankJ1
Rank of the task Jacobian.
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
void addFeature(vpBasicFeature &s, vpBasicFeature &s_star, const unsigned int select=vpBasicFeature::FEATURE_ALL)
create a new ste of two visual features
void setLambda(double _lambda)
set the gain lambda
void track(const vpHomogeneousMatrix &cMo)
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &vel)
static bool parse(int *argcPtr, const char **argv, vpArgvInfo *argTable, int flags)
void kill()
destruction (memory deallocation if required)
vpColVector computeControlLaw()
compute the desired control law
Class that defines the simplest robot: a free flying camera.
void getPosition(vpColVector &q)
void setPosition(const vpRobot::vpControlFrameType, const vpColVector &)
Set a displacement (frame has to be specified) in position control.
Class that provides a data structure for the column vectors as well as a set of operations on these v...
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)
Class required to compute the visual servoing control law.
Class that defines what is a circle.
void setServo(vpServoType _servo_type)
Choice of the visual servoing control law.
void setWorldCoordinates(const vpColVector &oP)