28#include <yarp/cv/Cv.h>
29#include <opencv2/imgproc/imgproc_c.h>
30#include <yarp/math/Math.h>
31#include <yarp/math/Rand.h>
32#include <yarp/math/NormRand.h>
40using namespace yarp::cv;
41using namespace yarp::math;
50 module->onRead(imgIn);
63 return this->
yarp().attachAsServer(source);
70 if ((c.length()<3) || (size.length()<2))
73 double a=std::max(fabs(size[0]),0.04);
74 double b=std::max(fabs(size[1]),0.02);
80 Matrix
H=axis2dcm(ax1);
87 for (
int i=0; i<2; i++)
89 for (
double theta=0.0; theta<=2.0*
M_PI; theta+=(2.0*
M_PI)/50.0)
99 yInfo(
"created point #%d=(%s)",(
int)
targets.size(),
x.toString(3,3).c_str());
105 H=axis2dcm(ax2)*axis2dcm(ax1);
120 return ((type==
"se3") || (type==
"se3+scale") ||
121 (type==
"affine") || (type==
"lssvm"));
129 if ((type==
"se3") || (type==
"se3+scale") || (type==
"affine"))
131 else if (type==
"lssvm")
142 if (!v.check(
"arm") || !v.check(
"type"))
145 string arm=v.find(
"arm").asString();
146 string type=v.find(
"type").asString();
147 if ((
arm!=
"left") && (
arm!=
"right"))
153 info.fromString(v.toString());
159 yInfo(
"loaded %s calibrator: %s",
arm.c_str(),info.toString().c_str());
171 const Vector &c, Vector &px)
173 cv::Mat imgInMat=toCvMat(imgIn);
176 imgOut.resize(imgIn);
177 cv::Mat imgOutMat=toCvMat(imgOut);
180 if ((c[0]<10.0) || (c[0]>imgIn.width()-10) ||
181 (c[1]<10.0) || (c[1]>imgIn.height()-10))
183 cv::cvtColor(imgInMat,imgOutMat,CV_GRAY2BGR);
189 cv::Point ct((
int)c[0],(
int)c[1]);
190 cv::Point tl((
int)(c[0]-roi_side2),(
int)(c[1]-roi_side2));
191 cv::Point br((
int)(c[0]+roi_side2),(
int)(c[1]+roi_side2));
192 tl.x=std::max(1,tl.x); tl.x=std::min(tl.x,(
int)imgIn.width()-1);
193 tl.y=std::max(1,tl.y); tl.y=std::min(tl.y,(
int)imgIn.height()-1);
194 br.x=std::max(1,br.x); br.x=std::min(br.x,(
int)imgIn.width()-1);
195 br.y=std::max(1,br.y); br.y=std::min(br.y,(
int)imgIn.height()-1);
196 cv::Rect rect(tl,br);
199 cv::Mat imgInMatRoi(imgInMat,rect);
200 cv::threshold(imgInMatRoi,imgInMatRoi,0,255,cv::THRESH_BINARY|cv::THRESH_OTSU);
201 cv::cvtColor(imgInMat,imgOutMat,CV_GRAY2BGR);
205 for (
int y=tl.y;
y<br.y;
y++)
207 for (
int x=tl.x;
x<br.x;
x++)
214 cv::circle(imgOutMat,cv::Point(
x,
y),5,cv::Scalar(0,0,255),-1);
224 cv::circle(imgOutMat,ct,5,cv::Scalar(0,255,0),-1);
225 cv::rectangle(imgOutMat,tl,br,cv::Scalar(255,255,255),4);
234 igaze->getInfo(info);
235 return info.find(
"min_allowed_vergence").asFloat64();
242 if (((eye!=
"left") && (eye!=
"right")) ||
243 ((type!=
"intrinsics") && (type!=
"extrinsics")))
247 igaze->getInfo(info);
248 if (Bottle *pB=info.find(
"camera_"+type+
"_"+eye).asList())
250 M.resize((type==
"intrinsics")?3:4,4);
253 for (
int r=0; r<M.rows(); r++)
254 for (
int c=0; c<M.cols(); c++)
255 M(r,c)=pB->get(cnt++).asFloat64();
267 if ((eye!=
"left") && (eye!=
"right"))
271 Bottle &ext=options.addList();
272 ext.addString(eye==
"left"?
"camera_extrinsics_left":
"camera_extrinsics_right");
273 Bottle &val=ext.addList();
274 for (
int r=0; r<
H.rows(); r++)
275 for (
int c=0; c<
H.cols(); c++)
276 val.addFloat64(
H(r,c));
278 return igaze->tweakSet(options);
286 cmd.addInt32((
int)px[0]);
287 cmd.addInt32((
int)px[1]);
295 x[0]=reply.get(0).asFloat64();
296 x[1]=reply.get(1).asFloat64();
297 x[2]=reply.get(2).asFloat64();
298 pxr[0]=reply.get(3).asInt32();
299 pxr[1]=reply.get(4).asInt32();
301 return (
norm(
x)>0.0);
307 const int maxSamples)
314 for (
int i=0; i<maxSamples; i++)
339 poss[0]=20.0; vels[0]=50.0;
340 poss[1]=90.0; vels[1]=50.0;
341 poss[2]=0.0; vels[2]=50.0;
342 poss[3]=0.0; vels[3]=50.0;
343 poss[4]=0.0; vels[4]=50.0;
344 poss[5]=0.0; vels[5]=50.0;
345 poss[6]=0.0; vels[6]=50.0;
346 poss[7]=0.0; vels[7]=50.0;
347 poss[8]=0.0; vels[8]=100.0;
349 yInfo(
"opening hand");
350 int i0=
nEncs-(int)poss.length();
351 for (
int i=i0; i<
nEncs; i++)
352 imod->setControlMode(i,VOCAB_CM_POSITION);
354 for (
int i=i0; i<
nEncs; i++)
356 ipos->setRefAcceleration(i,std::numeric_limits<double>::max());
357 ipos->setRefSpeed(i,vels[i-i0]);
358 ipos->positionMove(i,poss[i-i0]);
365 const Matrix &targetR)
368 IPositionControl *ipos;
369 ICartesianControl *icart;
373 yInfo(
"looking at target");
374 igaze->lookAtAbsAngles(gaze_ang);
383 icart->storeContext(&ctxtL);
386 icart->setDOF(dof,dof);
387 icart->setLimits(0,0.0,0.0);
388 icart->setLimits(1,0.0,0.0);
389 icart->setLimits(2,0.0,0.0);
390 icart->setTrajTime(1.0);
392 yInfo(
"reaching for left target");
393 icart->goToPoseSync(targetL.getCol(3),dcm2axis(targetL));
403 icart->storeContext(&ctxtR);
406 dof[0]=dof[1]=dof[2]=0.0;
407 icart->setDOF(dof,dof);
408 icart->setTrackingMode(
true);
409 icart->setTrajTime(1.0);
411 yInfo(
"reaching for right target");
412 icart->goToPoseSync(targetR.getCol(3),dcm2axis(targetR));
414 yInfo(
"waiting for right arm... ");
415 icart->waitMotionDone();
423 yInfo(
"waiting for left arm... ");
424 icart->waitMotionDone();
427 icart->restoreContext(ctxtL);
428 icart->deleteContext(ctxtL);
434 icart->restoreContext(ctxtR);
435 icart->deleteContext(ctxtR);
443 Vector gaze_ang(3,0.0);
444 Matrix targetL=
zeros(4,4);
445 Matrix targetR=
zeros(4,4);
446 targetL(3,3)=targetR(3,3)=1.0;
450 targetL(0,0)=targetR(0,0)=-1.0;
451 targetL(2,1)=targetR(2,1)=-1.0;
452 targetL(1,2)=targetR(1,2)=-1.0;
454 targetL(0,3)=targetR(0,3)=-0.25;
455 targetL(2,3)=targetR(2,3)=0.0;
460 else if (type==
"look_hands")
493 igaze->stopControl();
497 cmd.addString(
"calibrate");
499 if (reply.get(0).asString()==
"ACK")
502 cmd.addString(
"save");
504 if (reply.get(0).asString()==
"ACK")
520 poss[0]=40.0; vels[0]=50.0;
521 poss[1]=30.0; vels[1]=50.0;
522 poss[2]=20.0; vels[2]=50.0;
523 poss[3]=90.0; vels[3]=50.0;
524 poss[4]=00.0; vels[4]=50.0;
525 poss[5]=00.0; vels[5]=50.0;
526 poss[6]=70.0; vels[6]=50.0;
527 poss[7]=100.0; vels[7]=50.0;
528 poss[8]=200.0; vels[8]=100.0;
530 yInfo(
"configuring hand... ");
531 int i0=
nEncs-(int)poss.length();
532 for (
int i=i0; i<
nEncs; i++)
533 imods->setControlMode(i,VOCAB_CM_POSITION);
535 for (
int i=i0; i<
nEncs; i++)
537 iposs->setRefAcceleration(i,std::numeric_limits<double>::max());
538 iposs->setRefSpeed(i,vels[i-i0]);
539 iposs->positionMove(i,poss[i-i0]);
543 double t0=Time::now();
544 while (!
done && (Time::now()-t0<3.0))
551 iencs->getEncoders(encs.data());
552 poss=encs.subVector(i0,
nEncs-1);
555 Vector analogs(
iencarray->getEncoderArraySize(0));
556 iencarray->getEncoderArrayMeasure(0,analogs,stamp);
569 iarm->setDOF(dof,dof);
572 iarm->getLimits(0,&min,&max);
573 iarm->setLimits(0,0.0,0.5*max);
576 iarm->setTrajTime(1.0);
577 iarm->attachTipFrame(xf,Vector(4,0.0));
580 igaze->getNeckPitchRange(&min,&max);
581 igaze->bindNeckPitch(0.9*min,max);
582 igaze->blockNeckRoll(0.0);
583 igaze->setNeckTrajTime(0.8);
594 deque<Vector> p_depth, p_kin;
598 Vector
e(p_depth.size());
599 for (
size_t i=0; i<p_depth.size(); i++)
608 set<size_t>
idx=detector.
detect(
e,Property(
"(recursive)"));
614 for (
size_t i=0; i<p_depth.size(); i++)
615 if (
idx.find(i)==
idx.end())
619 return (
int)
idx.size();
643 igaze->stopControl();
662 Matrix Hd=
zeros(4,4);
664 Hd(1,1)=(
arm==
"left"?-1.0:1.0);
665 Hd(2,2)=(
arm==
"left"?1.0:-1.0);
672 Vector od=dcm2axis(axis2dcm(rot_y)*Hd);
673 yInfo(
"moving to xd=(%s); od=(%s); #%d remaining points",
674 xd.toString(3,3).c_str(),od.toString(3,3).c_str(),(
int)
targetsConsumed.size());
676 iarm->goToPoseSync(xd,od);
677 igaze->lookAtFixationPoint(xd);
688 igaze->stopControl();
706 Matrix Hd=
zeros(4,4);
708 Hd(1,1)=(
arm==
"left"?-1.0:1.0);
709 Hd(2,2)=(
arm==
"left"?1.0:-1.0);
712 Vector od=dcm2axis(Hd);
713 igaze->setTrackingMode(
true);
714 igaze->lookAtFixationPoint(xd);
716 Vector
x=xd;
x[2]+=0.05;
717 yInfo(
"moving to xd=(%s); od=(%s)",
x.toString(3,3).c_str(),od.toString(3,3).c_str());
718 iarm->goToPoseSync(
x,od);
719 iarm->waitMotionDone();
721 yInfo(
"moving to xd=(%s); od=(%s)",xd.toString(3,3).c_str(),od.toString(3,3).c_str());
723 iarm->goToPoseSync(xd,od);
724 iarm->waitMotionDone(0.1,5.0);
728 yInfo(
"moving to xd=(%s); od=(%s)",
x.toString(3,3).c_str(),od.toString(3,3).c_str());
730 iarm->goToPoseSync(
x,od);
731 iarm->waitMotionDone();
734 x[1]=(
arm==
"left"?-0.2:0.2);
736 yInfo(
"moving to xd=(%s); od=(%s)",
x.toString(3,3).c_str(),od.toString(3,3).c_str());
737 iarm->setLimits(0,0.0,0.0);
738 iarm->setLimits(2,0.0,0.0);
739 iarm->goToPoseSync(
x,od);
740 iarm->waitMotionDone();
745 igaze->stopControl();
754 yInfo(
"running test #%d",
test);
765 Vector x_deg=x_rad.subVector(0,2);
768 Matrix invH=SE3inv(
H);
776 yInfo(
"#0a \"check solver's robustness against seg-fault\"");
777 yInfo(
"#0b \"check correctness of first-order derivative\"");
779 Vector p2d(2); p2d[0]=160.0; p2d[1]=120.0;
780 Vector p3d(4); p3d[0]=-0.5; p3d[1]=0.0; p3d[2]=0.34; p3d[3]=1.0;
792 yInfo(
"#1a \"check solver's functionality\"");
796 for (
int i=0; i<100; i++)
799 p3d[0]=Rand::scalar(-0.5,0.5);
800 p3d[1]=Rand::scalar(-0.5,0.5);
801 p3d[2]=Rand::scalar(0.1,1.0);
804 Vector p2d=Prj*invH*p3d;
807 p2d+=NormRand::vector(2,0.0,5.0);
812 Matrix H1;
double error;
814 Vector
x1=cat(H1.getCol(3).subVector(0,2),
817 yInfo(
"x=(%s)",x_deg.toString(5,5).c_str());
818 yInfo(
"H\n%s",
H.toString(5,5).c_str());
819 yInfo(
"solution_x=(%s)",
x1.toString(5,5).c_str());
820 yInfo(
"solution_H\n%s",H1.toString(5,5).c_str());
821 yInfo(
"error=%g",
error);
829 yInfo(
"#2a \"check exploration space\"");
838 yInfo(
"#3a \"check saving data\"");
841 for (
int i=0; i<10; i++)
844 p[0]=Rand::scalar(-0.5,0.5);
845 p[1]=Rand::scalar(-0.5,0.5);
846 p[2]=Rand::scalar(0.1,1.0);
856 yInfo(
"H\n%s",
H.toString(5,5).c_str());
857 yInfo(
"calibration output: %s",ret.toString().c_str());
860 yInfo(
"#3b \"check retrieving data\"");
871 yInfo(
"in=(%s); out=H*in=(%s); pred=(%s)",
872 in.subVector(0,2).toString(3,3).c_str(),
873 out.subVector(0,2).toString(3,3).c_str(),
874 pred.toString(3,3).c_str());
876 yInfo(
"#3c \"check logging data\"");
881 yInfo(
"test #%d %s!",
test,
ok?
"passed":
"failed/unknown");
893 string robot=
rf.check(
"robot",Value(
"icub")).asString();
894 string name=
rf.check(
"name",Value(
"depth2kin")).asString();
895 string type=
rf.check(
"type",Value(
"se3+scale")).asString();
896 test=
rf.check(
"test",Value(-1)).asInt32();
897 max_dist=fabs(
rf.check(
"max_dist",Value(0.25)).asFloat64());
898 roi_side=abs(
rf.check(
"roi_side",Value(100)).asInt32());
899 block_eyes=fabs(
rf.check(
"block_eyes",Value(5.0)).asFloat64());
916 yError(
"Unknown method %s!",type.c_str());
923 Vector min(6),max(6);
924 min[0]=-0.005; max[0]=0.005;
925 min[1]=-0.005; max[1]=0.005;
926 min[2]=-0.01; max[2]=0.01;
936 K(0,0)=257.34; K(1,1)=257.34;
937 K(0,2)=160.0; K(1,2)=120.0;
944 Property optionArmL(
"(device remote_controlboard)");
945 optionArmL.put(
"remote",
"/"+robot+
"/left_arm");
946 optionArmL.put(
"local",
"/"+name+
"/joint/left");
948 yWarning(
"Position left_arm controller not available!");
950 Property optionArmR(
"(device remote_controlboard)");
951 optionArmR.put(
"remote",
"/"+robot+
"/right_arm");
952 optionArmR.put(
"local",
"/"+name+
"/joint/right");
954 yWarning(
"Position right_arm controller not available!");
956 Property optionMAIS_L(
"(device multipleanalogsensorsclient)");
957 optionMAIS_L.put(
"remote",
"/"+robot+
"/left_hand/MAIS");
958 optionMAIS_L.put(
"local",
"/"+name+
"/MAIS/left");
960 yWarning(
"MAIS left_hand sensor not available!");
962 Property optionMAIS_R(
"(device multipleanalogsensorsclient)");
963 optionMAIS_R.put(
"remote",
"/"+robot+
"/right_hand/MAIS");
964 optionMAIS_R.put(
"local",
"/"+name+
"/MAIS/right");
966 yWarning(
"MAIS right_hand sensor not available!");
968 Property optionCartL(
"(device cartesiancontrollerclient)");
969 optionCartL.put(
"remote",
"/"+robot+
"/cartesianController/left_arm");
970 optionCartL.put(
"local",
"/"+name+
"/cartesian/left");
972 yWarning(
"Cartesian left_arm controller not available!");
974 Property optionCartR(
"(device cartesiancontrollerclient)");
975 optionCartR.put(
"remote",
"/"+robot+
"/cartesianController/right_arm");
976 optionCartR.put(
"local",
"/"+name+
"/cartesian/right");
978 yWarning(
"Cartesian right_arm controller not available!");
980 Property optionGaze(
"(device gazecontrollerclient)");
981 optionGaze.put(
"remote",
"/iKinGazeCtrl");
982 optionGaze.put(
"local",
"/"+name+
"/gaze");
984 yWarning(
"Gaze controller not available!");
994 yError(
"Something wrong occured while configuring drivers... quitting!");
1004 IControlLimits *ilim;
1017 yError(
"Intrinsic parameters for left camera not available!");
1024 deque<IControlLimits*> lim;
1025 lim.push_back(ilim);
1032 yWarning(
"blockEyes saturated at minimum allowed vergence angle %g",
block_eyes);
1039 rpcPort.open(
"/"+name+
"/rpc");
1052 lock_guard<mutex> lck(
mtx);
1055 iarm->getPose(kinPoint,o);
1057 Vector c,tipl(2,0.0),tipr(2,0.0);
1058 igaze->get2DPixel(0,kinPoint,c);
1060 ImageOf<PixelBgr> imgOut;
1066 cv::Scalar color=cv::Scalar(0,0,255);
1067 string tag=
"discarded";
1075 double dist=
norm(depthPoint-kinPoint);
1078 color=cv::Scalar(0,255,0);
1084 yInfo(
"collecting calibration points: p_depth=(%s); p_kin=(%s);",
1085 depthPoint.toString(3,3).c_str(),kinPoint.toString(3,3).c_str());
1092 Vector kinPoint4=kinPoint;
1093 kinPoint4.push_back(1.0);
1095 Vector xe,oe,kinPoint_e;
1098 igaze->getLeftEyePose(xe,oe);
1102 kinPoint_e=SE3inv(He)*kinPoint4;
1105 yInfo(
"collecting points for aligning eye: tip=(%s); p_kin=(%s);",
1106 tipl.toString(3,3).c_str(),kinPoint_e.toString(3,3).c_str());
1112 yInfo(
"discarding calibration points: p_depth=(%s); p_kin=(%s); (|p_depth-p_kin|=%g)>%g",
1113 depthPoint.toString(3,3).c_str(),kinPoint.toString(3,3).c_str(),dist,
max_dist);
1117 yInfo(
"unavailable depth; discarding...");
1122 cv::Mat img=toCvMat(imgOut);
1123 cv::putText(img,tag,cv::Point(rect.x+5,rect.y+15),CV_FONT_HERSHEY_SIMPLEX,0.5,color);
1142 lock_guard<mutex> lck(
mtx);
1150 lock_guard<mutex> lck(
mtx);
1159 string fileName=
rf->findFile(
"calibrationFile");
1160 if (fileName.empty())
1162 yWarning(
"calibration file not found");
1166 Property
data;
data.fromConfigFile(fileName);
1167 Bottle b; b.read(
data);
1169 lock_guard<mutex> lck(
mtx);
1170 yInfo(
"loading experts from file: %s",fileName.c_str());
1171 for (
int i=0; i<b.size(); i++)
1180 lock_guard<mutex> lck(
mtx);
1184 string contextPath=
rf->getHomeContextPath();
1185 string fileName=
rf->find(
"calibrationFile").asString();
1186 fileName=contextPath+
"/"+fileName;
1188 yInfo(
"saving experts into file: %s",fileName.c_str());
1189 fout.open(fileName.c_str());
1197 info.put(
"arm",
"left");
1198 ostringstream entry;
1199 entry<<
"expert_left_"<<i;
1200 fout<<entry.str()<<
" "<<info.toString()<<endl;
1207 info.put(
"arm",
"right");
1208 ostringstream entry;
1209 entry<<
"expert_right_"<<i;
1210 fout<<entry.str()<<
" "<<info.toString()<<endl;
1225 if ((type!=
"experts") && (type!=
"calibrator"))
1231 lock_guard<mutex> lck(
mtx);
1232 deque<Vector> p_depth, p_kin;
1236 string contextPath=
rf->getHomeContextPath();
1237 string fileName=contextPath+
"/points_"+
arm+
"_"+type+
".log";
1239 yInfo(
"logging data into file: %s",fileName.c_str());
1240 fout.open(fileName.c_str());
1243 bool useExperts=(type==
"experts");
1247 for (i=0; i<p_depth.size(); i++)
1254 fout<<p_depth[i].toString(3,3);
1256 fout<<p_kin[i].toString(3,3);
1258 fout<<
x.toString(3,3);
1260 fout<<
norm(p_kin[i]-
x);
1265 ret=(i>=p_depth.size());
1287 lock_guard<mutex> lck(
mtx);
1288 yInfo(
"received stop command => stopping exploration...");
1348 return igaze->waitMotionDone();
1357 return igaze->clearEyes();
1412 lock_guard<mutex> lck(
mtx);
1423 reply.put(
"calibrator",
error);
1430 reply.put(
"aligner",
error);
1436 cmd.addString(
"getH");
1438 Matrix HRL; reply.write(HRL);
1439 Matrix HLR=SE3inv(HRL);
1442 igaze->getLeftEyePose(
x,o);
1443 Matrix TL=axis2dcm(o);
1444 TL.setSubcol(
x,0,3);
1446 igaze->getRightEyePose(
x,o);
1447 Matrix TR=axis2dcm(o);
1448 TR.setSubcol(
x,0,3);
1451 HR=SE3inv(TR)*(TL*HL*HLR);
1465 lock_guard<mutex> lck(
mtx);
1480 if ((sw!=
"on") && (sw!=
"off"))
1502 yInfo(
"received touch request for pixel=(%d %d);",u,v);
1507 yInfo(
"=> p_depth=(%s);",in.toString(3,3).c_str());
1512 yInfo(
"=> apply correction;");
1514 yWarning(
"no experts available!");
1517 yInfo(
"=> p_kin=(%s);",
out.toString(3,3).c_str());
1524 yInfo(
"unavailable depth; discarding...");
1557 const vector<double> &coordinates)
1560 vector<PointReq> reply;
1562 for (
size_t i=0; (i<coordinates.size()) && (i+2<coordinates.size()); i+=3)
1565 in[0]=coordinates[i];
1566 in[1]=coordinates[i+1];
1567 in[2]=coordinates[i+2];
1570 PointReq point(
"fail",in[0],in[1],in[2]);
1579 reply.push_back(point);
1589 if ((v!=
"on") && (v!=
"off"))
1592 if (
exp==
"depth2kin")
1597 else if (
exp==
"aligneyes")
1610 if (
exp==
"depth2kin")
1612 else if (
exp==
"aligneyes")
1623 Vector reply(6,0.0);
1625 reply=cat(
H.getCol(3).subVector(0,2),
1686 const double cz,
const double a,
1689 Vector c(3),size(2);
1702 const double dcz,
const double da,
1705 Vector dc(3),dsize(2);
1712 Vector c(3),size(2);
1713 c[0]=-0.4; c[1]=0.0; c[2]=0.05;
1714 size[0]=0.10; size[1]=0.05;
1722 lock_guard<mutex> lck(
mtx);
1726 reply.put(
"total_points",(
int)
targets.size());
1738 lock_guard<mutex> lck(
mtx);
1777 if (touchData->size()>=2)
1778 touch(touchData->get(0).asInt32(),touchData->get(1).asInt32());
bool attach(RpcServer &source)
bool motorExplorationAsyncStop
void openHand(IControlMode *imod, IPositionControl *ipos)
enum CalibModule::@38 motorExplorationState
IEncoderArrays * iencarray
double getExplorationWait()
Return the current wait timeout used during exploration between two consecutive data points.
bool setTouchWithExperts(const string &sw)
Enable/disable the use of experts for touch test.
double getExplorationInTargetTol()
Return the current cartesian tolerance used during exploration.
bool explore()
Start the exploration phase.
void doTouch(const Vector &xd)
bool getGazeParams(const string &eye, const string &type, Matrix &M)
void doMotorExploration()
Vector curExplorationCenter
double getTouchInTargetTol()
Return the current cartesian tolerance used during touch actions.
string getCalibrationType()
Return the current calibration type.
PointReq getPoint(const string &arm, const double x, const double y, const double z)
Retrieve the compensated kinematic point corresponding to the input depth point.
void onRead(ImageOf< PixelMono > &imgIn)
bool posture(const string &type)
Make the robot reach a predefined posture.
bool stop()
Yield an asynchronous stop of the exploration phase.
bool load()
Reload the list of experts stored within the configuration file.
Vector getExtrinsics(const string &eye)
Retrieve the current extrinsics camera parameters.
double exploration_intargettol
bool setMaxDist(const double max_dist)
Set the maximum allowed distance between the depth point and kinematic prediction to enable data coll...
bool quit()
Quit the module.
string getExperiment(const string &exp)
Return the current status of the experiment.
double getMaxDist()
Return the maximum allowed distance between depth point and kinematic prediction to enable data colle...
bool pushExtrinsics(const string &eye, const Matrix &H)
bool setRoi(const int side)
@ motorExplorationStateTrigger
@ motorExplorationStateLog
@ motorExplorationStateReach
@ motorExplorationStateIdle
bool setArm(const string &arm)
Select the arm to deal with.
bool setBlockEyes(const double block_eyes)
Set the vergence angle used to keep the gaze fixed.
DisparityProcessor depthInPort
bool clearExperts()
Clear the list of currently available experts.
bool pushCalibrator()
Push the current calibrator in the list of experts.
bool clearExplorationData()
Clean up the internal list of explored points pairs.
bool setCalibrationType(const string &type, const string &extrapolation)
Set up the calibrator type.
bool setExplorationInTargetTol(const double tol)
Set up the cartesian tolerance used during exploration.
bool setExplorationSpace(const double cx, const double cy, const double cz, const double a, const double b)
Set up the internally coded exploration space composed by two co-centered ellipses,...
bool setExplorationWait(const double wait)
Set up the wait timeout used during exploration between two consecutive data points.
int getNumExperts()
Return the number of available experts.
bool setExperiment(const string &exp, const string &v)
Set on/off an experiment.
LocallyWeightedExperts expertsR
bool getDepthAveraged(const Vector &px, Vector &x, Vector &pxr, const int maxSamples=5)
Property calibrate(const bool rm_outliers)
Ask the current calibrator to carry out the calibration.
bool log(const string &type)
Store on file the log of system response computed out of the explored set of input-output pairs.
bool clearEyes()
Remove the block on the eyes.
bool blockEyes()
Tell the gaze to immediately steer the eyes to the stored vergence angle and stay still.
bool isTypeValid(const string &type)
bool setTouchInTargetTol(const double tol)
Set up the cartesian tolerance used during a touch actions.
BufferedPort< ImageOf< PixelBgr > > depthOutPort
vector< PointReq > getPoints(const string &arm, const vector< double > &coordinates)
Retrieve the compensated kinematic points corresponding to the input depth points.
string getTouchWithExperts()
Return the current status of the switch for experts usage during touch test.
bool setExplorationSpaceDelta(const double dcx, const double dcy, const double dcz, const double da, const double db)
Set up the exploration space in terms of differences with respect to the internally coded couple of e...
Property getExplorationData()
Return some progress about the ongoing exploration.
bool resetExtrinsics(const string &eye)
Reset the extrinsics matrix to default eye matrix.
BufferedPort< Bottle > touchInPort
Calibrator * factory(const string &type)
bool save()
Save the current list of experts into the configuration file.
bool touch(const int u, const int v)
LocallyWeightedExperts * experts
deque< Vector > targetsConsumed
string getArm()
Return the current arm.
bool createTargets(const Vector &c, const Vector &size)
bool configure(ResourceFinder &rf)
double getBlockEyes()
Return the current angle to keep the vergence at.
cv::Rect extractFingerTip(ImageOf< PixelMono > &imgIn, ImageOf< PixelBgr > &imgOut, const Vector &c, Vector &px)
int getRoi()
Return the side of the squared window used to filter data collection in the image plane.
bool getDepth(const Vector &px, Vector &x, Vector &pxr)
LocallyWeightedExperts expertsL
void postureHelper(const Vector &gaze_ang, const Matrix &targetL, const Matrix &targetR)
bool calibrateDepth()
Put the robot in a suitable predefined posture and then execute depth calibration.
virtual bool clearPoints()=0
virtual bool retrieve(const yarp::sig::Vector &in, yarp::sig::Vector &out)=0
virtual bool toProperty(yarp::os::Property &info) const
virtual bool getPoints(std::deque< yarp::sig::Vector > &in, std::deque< yarp::sig::Vector > &out) const =0
virtual bool addPoints(const yarp::sig::Vector &in, const yarp::sig::Vector &out)=0
virtual void setExtrapolation(const bool extrapolation)
virtual bool fromProperty(const yarp::os::Property &info)
virtual bool calibrate(double &error)=0
virtual size_t getNumPoints() const
virtual std::string getType() const
DisparityProcessor(CalibModule *module)
CalibModule *void onRead(ImageOf< PixelMono > &imgIn)
bool setInitialGuess(const yarp::sig::Matrix &H)
size_t getNumPoints() const
void setBounds(const yarp::sig::Vector &min, const yarp::sig::Vector &max)
bool calibrate(yarp::sig::Matrix &H, double &error, const int max_iter=ALIGN_IPOPT_MAX_ITER, const int print_level=0, const std::string &derivative_test="none")
bool addPoints(const yarp::sig::Vector &p2di, const yarp::sig::Vector &p3di)
bool setProjection(const yarp::sig::Matrix &Prj)
yarp::sig::Matrix getProjection() const
virtual size_t size() const
virtual bool retrieve(const yarp::sig::Vector &in, yarp::sig::Vector &out)
PointReq IDL structure to send/receive points.
double y
the y-coordinate.
std::string result
contain [ok]/[fail] on success/failure.
double x
the x-coordinate.
double z
the z-coordinate.
Perform modified Thompson tau technique for outlier detection.
std::set< size_t > detect(const yarp::sig::Vector &data, const yarp::os::Property &options)
Perform outliers detection over the provided data.
A class for defining the iCub Finger.
virtual bool alignJointsBounds(const std::deque< yarp::dev::IControlLimits * > &lim)
Alignes the finger joints bounds with current values set aboard the iCub.
virtual bool getChainJoints(const yarp::sig::Vector &motorEncoders, yarp::sig::Vector &chainJoints)
Retrieves the vector of actual finger's joint values (to be used in conjuction with the iKinLimb meth...
yarp::sig::Matrix getH(const unsigned int i, const bool allLink=false)
Returns the rigid roto-translation matrix from the root reference frame to the ith frame in Denavit-H...
static uint32_t idx[BOARD_NUM]
double norm(const yarp::sig::Matrix &M, int col)
Returns the norm of the vector given in the form: matrix(:,col).
Matrix computeH(const Vector &x)
Copyright (C) 2008 RobotCub Consortium.
#define ALIGN_IPOPT_MAX_ITER