23 #include <visp/vpCameraParameters.h>
24 #include <visp/vpDisplayX.h>
25 #include <visp/vpDot2.h>
26 #include <visp/vpFeatureBuilder.h>
27 #include <visp/vpFeatureDepth.h>
28 #include <visp/vpFeaturePoint.h>
29 #include <visp/vpHomogeneousMatrix.h>
30 #include <visp/vpImage.h>
31 #include <visp/vpImageConvert.h>
32 #include <visp/vpServo.h>
33 #include <visp/vpVelocityTwistMatrix.h>
38 #if defined( VISP_HAVE_DC1394_2 ) && defined( VISP_HAVE_X11 )
39 #define TEST_COULD_BE_ACHIEVED
42 #ifdef TEST_COULD_BE_ACHIEVED
44 main(
int argc,
char **argv )
48 vpImage< unsigned char > I;
51 double coef = 1. / 6.77;
61 vpTime::sleepMs( 3000 );
63 std::cout <<
"Robot connected" << std::endl;
66 vpCameraParameters cam;
76 cam.initPersProjWithoutDistortion( 600, 600, I.getWidth() / 2, I.getHeight() / 2 );
81 vpDisplayX
d( I, 10, 10,
"Current frame" );
82 vpDisplay::display( I );
83 vpDisplay::flush( I );
87 dot.setGraphics(
true );
88 dot.setComputeMoments(
true );
89 dot.setEllipsoidShapePrecision( 0. );
90 dot.setGrayLevelPrecision( 0.9 );
91 dot.setEllipsoidBadPointsPercentage( 0.5 );
92 dot.initTracking( I );
93 vpDisplay::flush( I );
96 task.setServo( vpServo::EYEINHAND_L_cVe_eJe );
97 task.setInteractionMatrixType( vpServo::DESIRED, vpServo::PSEUDO_INVERSE );
98 task.setLambda( lambda );
99 vpVelocityTwistMatrix cVe;
100 cVe = robot.get_cVe();
103 std::cout <<
"cVe: \n" << cVe << std::endl;
108 std::cout <<
"eJe: \n" << eJe << std::endl;
111 vpFeaturePoint s_x, s_xd;
114 vpFeatureBuilder::create( s_x, cam,
dot );
117 s_xd.buildFrom( 0, 0, depth );
120 task.addFeature( s_x, s_xd );
123 vpFeatureDepth s_Z, s_Zd;
125 double surface = 1. / sqrt(
dot.m00 / ( cam.get_px() * cam.get_py() ) );
132 std::cout <<
"Z " << Z << std::endl;
133 s_Z.buildFrom( s_x.get_x(), s_x.get_y(), Z, 0 );
134 s_Zd.buildFrom( s_x.get_x(), s_x.get_y(), Zd, 0 );
137 task.addFeature( s_Z, s_Zd );
147 vpDisplay::display( I );
152 vpFeatureBuilder::create( s_x, cam,
dot );
155 surface = 1. / sqrt(
dot.m00 / ( cam.get_px() * cam.get_py() ) );
157 s_Z.buildFrom( s_x.get_x(), s_x.get_y(), Z, log( Z / Zd ) );
159 robot.get_cVe( cVe );
166 v = task.computeControlLaw();
168 std::cout <<
"Send velocity to the pionner: " << v[0] <<
" m/s " << vpMath::deg( v[1] ) <<
" deg/s" << std::endl;
174 vpDisplay::displayLine( I, 0, 320, 479, 320, vpColor::red );
175 vpDisplay::flush( I );
178 if ( vpDisplay::getClick( I,
false ) )
182 std::cout <<
"Ending robot thread..." << std::endl;
188 catch ( vpException e )
190 std::cout <<
"Catch an exception: " << e << std::endl;
198 std::cout <<
"You don't have the right 3rd party libraries to run this example..." << std::endl;