#include <visp/vpDebug.h>
#include <visp/vpConfig.h>
#include <iostream>
#include <visp/vpHomogeneousMatrix.h>
#include <visp/vpMomentObject.h>
#include <visp/vpMomentDatabase.h>
#include <visp/vpMomentCommon.h>
#include <visp/vpFeatureMomentCommon.h>
#include <visp/vpDisplayX.h>
#include <visp/vpDisplayGTK.h>
#include <visp/vpDisplayGDI.h>
#include <visp/vpCameraParameters.h>
#include <visp/vpIoTools.h>
#include <visp/vpMath.h>
#include <visp/vpHomogeneousMatrix.h>
#include <visp/vpServo.h>
#include <visp/vpDebug.h>
#include <visp/vpFeatureBuilder.h>
#include <visp/vpFeaturePoint.h>
#include <visp/vpSimulatorAfma6.h>
#include <visp/vpPlane.h>
void paramRobot();
void initScene();
void initFeatures();
void execute(unsigned int nbIter);
double error();
void _planeToABC(
vpPlane& pl,
double& A,
double& B,
double& C);
void paramRobot();
#if !defined(WIN32) && !defined(VISP_HAVE_PTHREAD)
int main()
{
std::cout << "Can't run this example since vpSimulatorAfma6 capability is not available." << std::endl;
std::cout << "You should install pthread third-party library." << std::endl;
}
#elif !defined(VISP_HAVE_X11) && !defined(VISP_HAVE_OPENCV) && !defined(VISP_HAVE_GDI) && !defined(VISP_HAVE_D3D9) && !defined(VISP_HAVE_GTK)
int main()
{
std::cout << "Can't run this example since no display capability is available." << std::endl;
std::cout << "You should install one of the following third-party library: X11, OpenCV, GDI, GTK." << std::endl;
}
#else
int main(){
init(cMo,cdMo);
execute(1500);
return 0;
}
#if defined VISP_HAVE_X11
#elif defined VISP_HAVE_OPENCV
#elif defined VISP_HAVE_GDI
#elif defined VISP_HAVE_D3D9
#elif defined VISP_HAVE_GTK
#endif
double _error;
void initScene(){
vector<vpPoint> src_pts;
vector<vpPoint> dst_pts;
double x[8] = { 1,3, 4,-1 ,-3,-2,-1,1};
double y[8] = { 0,1, 4, 4, -2,-2, 1,0};
int nbpoints = 8;
for (int i = 0 ; i < nbpoints ; i++){
src_pts.push_back(p);
}
for (int i = 0 ; i < nbpoints ; i++){
dst_pts.push_back(p);
}
}
void initFeatures(){
double A; double B; double C;
double Ad; double Bd; double Cd;
_planeToABC(pl,A,B,C);
_planeToABC(pl,Ad,Bd,Cd);
}
double x[8] = { 1,3, 4,-1 ,-3,-2,-1,1};
double y[8] = { 0,1, 4, 4, -2,-2, 1,0};
int nbpoints = 8;
vector<vpPoint> cur_pts;
for (int i = 0 ; i < nbpoints ; i++){
cur_pts.push_back(p);
}
}
{
cMo = _cMo;
cdMo = _cdMo;
displayInt.
init(Iint,700,0,
"Visual servoing with moments") ;
paramRobot();
initScene();
initFeatures();
}
void execute(unsigned int nbIter){
vpTRACE(
"Display task information " ) ;
robot.getInternalView(Iint);
unsigned int iter=0;
while(iter++<nbIter ){
cMo = robot.get_cMo();
double A,B,C;
_planeToABC(pl,A,B,C);
refreshScene(obj);
robot.getInternalView(Iint);
if (iter == 1)
_error = ( task.
getError() ).sumSquare();
}
vpTRACE(
"\n\nClick in the internal view window to end...");
delete moments;
delete momentsDes;
delete featureMoments;
delete featureMomentsDes;
}
}
void _planeToABC(
vpPlane& pl,
double& A,
double& B,
double& C){
if(fabs(pl.
getD())<std::numeric_limits<double>::epsilon()){
std::cout << "Invalid position:" << std::endl;
std::cout << cMo << std::endl;
std::cout << "Cannot put plane in the form 1/Z=Ax+By+C." << std::endl;
}
}
void paramRobot(){
removeJointLimits(robot);
}
double error(){return _error;}
#endif