65 #include <visp/vpConfig.h>
66 #include <visp/vpDebug.h>
70 #if (defined (VISP_HAVE_AFMA6) && defined (VISP_HAVE_DC1394_2))
72 #include <visp/vp1394TwoGrabber.h>
73 #include <visp/vpImage.h>
74 #include <visp/vpDisplay.h>
75 #include <visp/vpDisplayX.h>
76 #include <visp/vpDisplayOpenCV.h>
77 #include <visp/vpDisplayGTK.h>
79 #include <visp/vpMath.h>
80 #include <visp/vpHomogeneousMatrix.h>
81 #include <visp/vpFeatureEllipse.h>
82 #include <visp/vpServo.h>
83 #include <visp/vpFeatureBuilder.h>
85 #include <visp/vpRobotAfma6.h>
88 #include <visp/vpException.h>
89 #include <visp/vpMatrixException.h>
90 #include <visp/vpServoDisplay.h>
92 #include <visp/vpDot.h>
111 vpDisplayX display(I,100,100,
"Current image") ;
112 #elif defined(VISP_HAVE_OPENCV)
114 #elif defined(VISP_HAVE_GTK)
121 std::cout << std::endl ;
122 std::cout <<
"-------------------------------------------------------" << std::endl ;
123 std::cout <<
" Test program for vpServo " <<std::endl ;
124 std::cout <<
" Eye-in-hand task control, velocity computed in the camera frame" << std::endl ;
125 std::cout <<
" Simulation " << std::endl ;
126 std::cout <<
" task : servo a point " << std::endl ;
127 std::cout <<
"-------------------------------------------------------" << std::endl ;
128 std::cout << std::endl ;
136 std::cout <<
"Click on an ellipse..." << std::endl;
151 vpTRACE(
"sets the current position of the visual feature ") ;
156 std::cout <<
" Learning 0/1 " <<std::endl ;
158 std::cin >> learning ;
159 char name[FILENAME_MAX] ;
160 sprintf(name,
"dat/ellipse.dat") ;
164 vpTRACE(
"Save the location of the object in a file dat/ellipse.dat") ;
165 std::ofstream f(name) ;
172 vpTRACE(
"sets the desired position of the visual feature ") ;
174 std::ifstream f(
"dat/ellipse.dat") ;
175 double x,y,mu20,mu11,mu02 ;
176 f >> x ; f >> y ; f >> mu20 ; f >> mu11 ; f >> mu02 ;
189 unsigned int iter=0 ;
190 double lambda_av =0.01;
194 std::cout <<
"alpha 0.7" << std::endl;
196 std::cout <<
"beta 5" << std::endl;
200 std::cout <<
"---------------------------------------------" << iter++ <<std::endl ;
217 if (std::fabs(alpha) <= std::numeric_limits<double>::epsilon())
221 gain = alpha * exp (-beta * ( task.
getError() ).sumSquare() ) + lambda_av;
224 else gain = lambda_av ;
231 std::cout <<
"rank " << task.
getTaskRank() << std::endl ;
240 vpTRACE(
"Display task information " ) ;
256 vpERROR_TRACE(
"You do not have an afma6 robot or a firewire framegrabber connected to your computer...");
static void display(vpServo &s, const vpCameraParameters &cam, vpImage< unsigned char > &I, vpColor currentColor=vpColor::green, vpColor desiredColor=vpColor::red, unsigned int thickness=1)
void setMaxDotSize(double percentage)
void getCameraParameters(vpCameraParameters &cam, const unsigned int &image_width, const unsigned int &image_height)
Define the X11 console to display images.
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 vpImage< unsigned char > &I)
static const vpColor green
void acquire(vpImage< unsigned char > &I)
static void flush(const vpImage< unsigned char > &I)
Control of Irisa's gantry robot named Afma6.
void open(vpImage< unsigned char > &I)
vpImagePoint getCog() const
void kill()
destruction (memory deallocation if required)
Initialize the velocity controller.
vpColVector getError() const
vpColVector computeControlLaw()
compute the desired control law
static void display(const vpImage< unsigned char > &I)
The vpDisplayOpenCV allows to display image using the opencv library.
vpRowVector t() const
transpose of Vector
virtual void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)=0
Generic class defining intrinsic camera parameters.
The vpDisplayGTK allows to display image using the GTK+ library version 1.2.
vpRobot::vpRobotStateType setRobotState(vpRobot::vpRobotStateType newState)
void setABC(const double A, const double B, const double C)
void setInteractionMatrixType(const vpServoIteractionMatrixType &interactionMatrixType, const vpServoInversionType &interactionMatrixInversion=PSEUDO_INVERSE)
Set the type of the interaction matrix (current, mean, desired, user).
Class that provides a data structure for the column vectors as well as a set of operations on these v...
void setFramerate(vp1394TwoFramerateType fps)
double getTaskRank() const
void setVideoMode(vp1394TwoVideoModeType videomode)
void print(const vpServo::vpServoPrintType display_level=ALL, std::ostream &os=std::cout)
This tracker is meant to track a dot (connected pixels with same gray level) on a vpImage...
void setComputeMoments(const bool activate)
void buildFrom(const double x, const double y, const double mu20, const double mu11, const double mu02)
Class for firewire ieee1394 video devices using libdc1394-2.x api.
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &velocity)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
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 descbribed in and .
vpColVector get_s(unsigned int select=FEATURE_ALL) const
Get the feature vector .
void initTracking(const vpImage< unsigned char > &I)
void setServo(vpServoType _servo_type)
Choice of the visual servoing control law.
static const vpColor blue