66 #include <visp/vpMath.h>
67 #include <visp/vpHomogeneousMatrix.h>
68 #include <visp/vpFeatureEllipse.h>
69 #include <visp/vpSphere.h>
70 #include <visp/vpServo.h>
71 #include <visp/vpRobotCamera.h>
72 #include <visp/vpFeatureBuilder.h>
76 #include <visp/vpException.h>
77 #include <visp/vpMatrixException.h>
80 #include <visp/vpDebug.h>
81 #include <visp/vpParseArgv.h>
86 #define GETOPTARGS "h"
96 void usage(
const char *name,
const char *badparam)
99 Simulation of a 2D visual servoing on a sphere:\n\
100 - eye-in-hand control law,\n\
101 - velocity computed in the camera frame,\n\
102 - without display.\n\
114 fprintf(stdout,
"\nERROR: Bad parameter [%s]\n", badparam);
127 bool getOptions(
int argc,
const char **argv)
134 case 'h': usage(argv[0], NULL);
return false;
break;
137 usage(argv[0], optarg);
142 if ((c == 1) || (c == -1)) {
144 usage(argv[0], NULL);
145 std::cerr <<
"ERROR: " << std::endl;
146 std::cerr <<
" Bad argument " << optarg << std::endl << std::endl;
154 main(
int argc,
const char ** argv)
157 if (getOptions(argc, argv) ==
false) {
164 std::cout << std::endl ;
165 std::cout <<
"-------------------------------------------------------" << std::endl ;
166 std::cout <<
" Test program for vpServo " <<std::endl ;
167 std::cout <<
" Simulation " << std::endl ;
168 std::cout <<
" task : servo a sphere " << std::endl ;
169 std::cout <<
"-------------------------------------------------------" << std::endl ;
170 std::cout << std::endl ;
173 vpTRACE(
"sets the initial camera location " ) ;
187 vpTRACE(
"sets the sphere coordinates in the world frame " ) ;
191 vpTRACE(
"sets the desired position of the visual feature ") ;
196 vpTRACE(
"project : computes the sphere coordinates in the camera frame and its 2D coordinates" ) ;
198 vpTRACE(
"sets the current position of the visual feature ") ;
204 vpTRACE(
"\t we want an eye-in-hand control law") ;
205 vpTRACE(
"\t robot is controlled in the camera frame") ;
208 vpTRACE(
"\t we want to see a sphere on a sphere..") ;
209 std::cout << std::endl ;
216 vpTRACE(
"Display task information " ) ;
219 unsigned int iter=0 ;
223 std::cout <<
"---------------------------------------------" << iter <<std::endl ;
226 if (iter==1)
vpTRACE(
"\t\t get the robot position ") ;
228 if (iter==1)
vpTRACE(
"\t\t new sphere position ") ;
234 if (iter==1)
vpTRACE(
"\t\t compute the control law ") ;
238 if (iter==1)
vpTRACE(
"\t\t send the camera velocity to the controller ") ;
245 vpTRACE(
"Display task information " ) ;
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)
Class that defines what is a sphere.
void setWorldCoordinates(const vpColVector &oP)
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...
double getTaskRank() 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)
Class required to compute the visual servoing control law.
void setServo(vpServoType _servo_type)
Choice of the visual servoing control law.