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...");