48 #include <visp/vpDebug.h>
49 #include <visp/vpConfig.h>
51 #include <visp/vpHomogeneousMatrix.h>
52 #include <visp/vpMomentObject.h>
53 #include <visp/vpMomentDatabase.h>
54 #include <visp/vpMomentCommon.h>
55 #include <visp/vpFeatureMomentCommon.h>
56 #include <visp/vpDisplayX.h>
57 #include <visp/vpDisplayGTK.h>
58 #include <visp/vpDisplayGDI.h>
59 #include <visp/vpCameraParameters.h>
60 #include <visp/vpIoTools.h>
61 #include <visp/vpMath.h>
62 #include <visp/vpHomogeneousMatrix.h>
63 #include <visp/vpServo.h>
64 #include <visp/vpDebug.h>
65 #include <visp/vpFeatureBuilder.h>
66 #include <visp/vpFeaturePoint.h>
67 #include <visp/vpSimulatorAfma6.h>
68 #include <visp/vpPlane.h>
71 #if !defined(_WIN32) && !defined(VISP_HAVE_PTHREAD)
75 std::cout <<
"Can't run this example since vpSimulatorAfma6 capability is not available." << std::endl;
76 std::cout <<
"You should install pthread third-party library." << std::endl;
79 #elif !defined(VISP_HAVE_X11) && !defined(VISP_HAVE_OPENCV) && !defined(VISP_HAVE_GDI) && !defined(VISP_HAVE_D3D9) && !defined(VISP_HAVE_GTK)
82 std::cout <<
"Can't run this example since no display capability is available." << std::endl;
83 std::cout <<
"You should install one of the following third-party library: X11, OpenCV, GDI, GTK." << std::endl;
98 void execute(
unsigned int nbIter);
101 void planeToABC(
vpPlane& pl,
double& A,
double& B,
double& C);
118 std::cout <<
"Catch an exception: " << e << std::endl;
124 #if defined VISP_HAVE_X11
126 #elif defined VISP_HAVE_OPENCV
128 #elif defined VISP_HAVE_GDI
130 #elif defined VISP_HAVE_D3D9
132 #elif defined VISP_HAVE_GTK
160 std::vector<vpPoint> src_pts;
161 std::vector<vpPoint> dst_pts;
163 double x[8] = { 1,3, 4,-1 ,-3,-2,-1,1};
164 double y[8] = { 0,1, 4, 4, -2,-2, 1,0};
167 for (
int i = 0 ; i < nbpoints ; i++){
171 src_pts.push_back(p);
176 for (
int i = 0 ; i < nbpoints ; i++){
180 dst_pts.push_back(p);
189 double A;
double B;
double C;
190 double Ad;
double Bd;
double Cd;
197 planeToABC(pl,A,B,C);
201 planeToABC(pl,Ad,Bd,Cd);
236 double x[8] = { 1,3, 4,-1 ,-3,-2,-1,1};
237 double y[8] = { 0,1, 4, 4, -2,-2, 1,0};
239 std::vector<vpPoint> cur_pts;
241 for (
int i = 0 ; i < nbpoints ; i++){
245 cur_pts.push_back(p);
257 displayInt.
init(Iint,700,0,
"Visual servoing with moments") ;
266 void execute(
unsigned int nbIter){
272 vpTRACE(
"Display task information " ) ;
276 robot.getInternalView(Iint);
281 while(iter++<nbIter ){
284 cMo = robot.get_cMo();
290 planeToABC(pl,A,B,C);
300 robot.getInternalView(Iint);
312 _error = ( task.
getError() ).sumSquare();
317 vpTRACE(
"\n\nClick in the internal view window to end...");
322 delete featureMoments;
323 delete featureMomentsDes;
349 void planeToABC(
vpPlane& pl,
double& A,
double& B,
double& C){
350 if(fabs(pl.
getD())<std::numeric_limits<double>::epsilon()){
351 std::cout <<
"Invalid position:" << std::endl;
352 std::cout << cMo << std::endl;
353 std::cout <<
"Cannot put plane in the form 1/Z=Ax+By+C." << std::endl;
364 robot.setCurrentViewColor(
vpColor(150,150,150));
365 robot.setDesiredViewColor(
vpColor(200,200,200));
367 removeJointLimits(robot);
369 robot.setConstantSamplingTimeMode(
true);
371 robot.initialiseObjectRelativeToCamera(cMo);
374 robot.setDesiredCameraPosition(cdMo);
375 robot.getCameraParameters(cam,Iint);
379 double error(){
return _error;}
The object displayed at the desired position is the same than the scene object defined in vpSceneObje...
Perspective projection without distortion model.
void setMaxTranslationVelocity(const double maxVt)
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
A plate with 8 points at coordinates (0.05,0,0), (0.15,0.05,0), (0.2,0.2,0), (-0.05,0.2,0), (-0.15,-0.1,0), (-0.1,-0.1,0), (-0.05,0.05,0) and (0.5,0,0). ach point is represented by a circle with 2cm radius.
Display for windows using GDI (available on any windows 32 platform).
Class to define colors available for display functionnalities.
Define the X11 console to display images.
void addFeature(vpBasicFeature &s, vpBasicFeature &s_star, const unsigned int select=vpBasicFeature::FEATURE_ALL)
This class allows to access common vpFeatureMoments in a pre-filled database.
error that can be emited by ViSP classes.
void setJointLimit(const vpColVector &limitMin, const vpColVector &limitMax)
void setABCD(const double a, const double b, const double c, const double d)
Class for generic objects.
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
void track(const vpHomogeneousMatrix &cMo)
static void flush(const vpImage< unsigned char > &I)
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
Class that defines what is a point.
Display for windows using Direct3D.
Initialize the velocity controller.
vpColVector getError() const
vpColVector computeControlLaw()
vpFeatureMomentAlpha & getFeatureAlpha()
void updateAll(double A, double B, double C)
void changeFrame(const vpHomogeneousMatrix &cMo)
static std::vector< double > getMu3(vpMomentObject &object)
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the opencv library.
Generic class defining intrinsic camera parameters.
Class which enables to project an image in the 3D space and get the view of a virtual camera...
Simulator of Irisa's gantry robot named Afma6.
The vpDisplayGTK allows to display image using the GTK+ library version 1.2.
void extract(vpRotationMatrix &R) const
vpServoIteractionMatrixType
void fromVector(std::vector< vpPoint > &points)
static double getSurface(vpMomentObject &object)
void setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType, const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE)
vpFeatureMomentCInvariant & getFeatureCInvariant()
static double rad(double deg)
void updateAll(vpMomentObject &object)
void setMaxRotationVelocity(const double maxVr)
This class initializes and allows access to commonly used moments.
static double getAlpha(vpMomentObject &object)
Class that provides a data structure for the column vectors as well as a set of operations on these v...
vpFeatureMomentGravityCenterNormalized & getFeatureGravityNormalized()
void setType(vpObjectType input_type)
void print(const vpServo::vpServoPrintType display_level=ALL, std::ostream &os=std::cout)
virtual bool getClick(bool blocking=true)=0
This class defines the container for a plane geometrical structure.
vpFeatureMomentAreaNormalized & getFeatureAn()
void setServo(const vpServoType &servo_type)
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &v)
Class that consider the case of a translation vector.
void setWorldCoordinates(const double ox, const double oy, const double oz)
Set the point world coordinates. We mean here the coordinates of the point in the object frame...