23 #include <visp/vpRobotPioneer.h> 24 #include <visp/vpCameraParameters.h> 25 #include <visp/vpDisplayX.h> 26 #include <visp/vpDot2.h> 27 #include <visp/vpFeatureBuilder.h> 28 #include <visp/vpFeatureDepth.h> 29 #include <visp/vpFeaturePoint.h> 30 #include <visp/vpHomogeneousMatrix.h> 31 #include <visp/vpImage.h> 32 #include <visp/vpImageConvert.h> 33 #include <visp/vp1394TwoGrabber.h> 34 #include <visp/vpServo.h> 35 #include <visp/vpVelocityTwistMatrix.h> 37 #if defined(VISP_HAVE_DC1394_2) && defined(VISP_HAVE_X11) || defined(VISP_HAVE_PIONEER) 38 # define TEST_COULD_BE_ACHIEVED 42 #ifdef TEST_COULD_BE_ACHIEVED 43 int main(
int argc,
char **argv)
46 vpImage<unsigned char> I;
49 double coef = 1./6.77;
52 ArArgumentParser
parser(&argc, argv);
53 parser.loadDefaultArguments();
57 ArRobotConnector robotConnector(&parser, &robot);
58 if(!robotConnector.connectRobot())
60 ArLog::log(ArLog::Terse,
"Could not connect to the robot.");
61 if(parser.checkHelpAndWarnUnparsed())
67 if (!Aria::parseArgs())
78 vpTime::sleepMs(3000);
80 std::cout <<
"Robot connected" << std::endl;
83 vpCameraParameters cam;
86 vp1394TwoGrabber g(
false);
87 g.setVideoMode(vp1394TwoGrabber::vpVIDEO_MODE_640x480_MONO8);
88 g.setFramerate(vp1394TwoGrabber::vpFRAMERATE_30);
90 cam.initPersProjWithoutDistortion(800, 795, 320, 216);
95 vpDisplayX
d(I, 10, 10,
"Current frame");
96 vpDisplay::display(I);
101 dot.setGraphics(
true);
102 dot.setComputeMoments(
true);
103 dot.setEllipsoidShapePrecision(0.);
104 dot.setGrayLevelPrecision(0.9);
105 dot.setEllipsoidBadPointsPercentage(0.5);
110 task.setServo(vpServo::EYEINHAND_L_cVe_eJe) ;
111 task.setInteractionMatrixType(vpServo::DESIRED, vpServo::PSEUDO_INVERSE) ;
112 task.setLambda(lambda) ;
113 vpVelocityTwistMatrix cVe ;
114 cVe = robot.get_cVe() ;
117 std::cout <<
"cVe: \n" << cVe << std::endl;
122 std::cout <<
"eJe: \n" << eJe << std::endl;
125 vpFeaturePoint s_x, s_xd;
128 vpFeatureBuilder::create(s_x, cam, dot);
131 s_xd.buildFrom(0, 0, depth);
134 task.addFeature(s_x, s_xd) ;
137 vpFeatureDepth s_Z, s_Zd;
139 double surface = 1./sqrt(dot.m00/(cam.get_px()*cam.get_py()));
146 std::cout <<
"Z " << Z << std::endl;
147 s_Z.buildFrom(s_x.get_x(), s_x.get_y(), Z , 0);
148 s_Zd.buildFrom(s_x.get_x(), s_x.get_y(), Zd , 0);
151 task.addFeature(s_Z, s_Zd) ;
161 vpDisplay::display(I);
166 vpFeatureBuilder::create(s_x, cam, dot);
169 surface = 1./sqrt(dot.m00/(cam.get_px()*cam.get_py()));
171 s_Z.buildFrom(s_x.get_x(), s_x.get_y(), Z, log(Z/Zd)) ;
180 v = task.computeControlLaw() ;
182 std::cout <<
"Send velocity to the pionner: " << v[0] <<
" m/s " 183 << vpMath::deg(v[1]) <<
" deg/s" << std::endl;
186 robot.setVelocity(vpRobot::REFERENCE_FRAME, v);
189 vpDisplay::displayLine(I, 0, 320, 479, 320, vpColor::red);
193 if ( vpDisplay::getClick(I,
false) )
197 std::cout <<
"Ending robot thread..." << std::endl;
201 robot.waitForRunExit();
207 catch(vpException e) {
208 std::cout <<
"Catch an exception: " << e << std::endl;
215 std::cout <<
"You don't have the right 3rd party libraries to run this example..." << std::endl;
int main(int argc, char **argv)
TFSIMD_FORCE_INLINE tfScalar dot(const Quaternion &q1, const Quaternion &q2)